text
stringlengths
11
4.05M
package parser const AristocratsMain = "http://aristocrats.fm/playlists/" //const ARISTOCRATS_MUSIC = "http://aristocrats.fm/playlist-amusic/"
package main import ( "fmt" "github.com/pkg/errors" ) var ErrNameEmpty = errors.New("Name can't be empty!") func (s *Student) SetName(newName string) (err error) { if newName == "" || s.Name == "" { return ErrNameEmpty } else { s.Name = newName return nil } } type Student struct { Name string Age int ...
package controllers import ( "ibgamemanage/models" "github.com/astaxie/beego" "github.com/beego/wetalk/modules/utils" ) type IndexController struct { beego.Controller } func (this *IndexController) Get() { count := models.GetPlayerInfoCount() if count > 0 { pagesize := 12 p := utils.NewPaginator(this.Ctx...
package proto // go:generate make generate import ( "encoding/json" "fmt" "runtime/debug" "time" "github.com/MagalixTechnologies/uuid-go" "github.com/golang/snappy" "k8s.io/apimachinery/pkg/runtime/schema" ) const ( ResourceRequirementKindSet = "set" ResourceRequirementKindDe...
package cli import ( "flag" "fmt" "os" "runtime" ) // COMMAND LINE INTERFACE const ( LISTEN_MODE = 1 CONNECT_MODE = 2 ) type Option struct { LocalPort int RemoteIP string RemotePort int Mode int } // Args var Args Option func init() { flag.IntVar(&Args.LocalPort, "lport", 0, "Listen a local `...
package main import ( "os" "runtime" "sort" "strings" "time" colorable "github.com/mattn/go-colorable" log "github.com/sirupsen/logrus" cli "gopkg.in/urfave/cli.v2" ) // App Properties var appName = "EnvCLI Utility" var appVersion = "v0.2.0" // Configuration var configurationLoader = ConfigurationLoader{} v...
package bgControllers import ( "github.com/astaxie/beego" "GiantTech/models" "GiantTech/controllers/tools" ) type SetupController struct { beego.Controller } func checkAdminUser() error { query := make(map[string]string) query["UserLevel"] = "0" departments, err := models.GetAllTUsers(query, nil, nil, nil, 0,...
package leap // testVersion should match the targetTestVersion in the test file. const testVersion = 2 // IsLeapYear return true when input value is leap year. func IsLeapYear(year int) bool { // Write some code here to pass the test suite. if year%100 != 0 && year%4 == 0 || year%400 == 0 { return true } re...
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. // vespa status command // author: bratseth package cmd import ( "fmt" "log" "strconv" "time" "github.com/fatih/color" "github.com/spf13/cobra" "github.com/vespa-engine/vespa/client/go/vespa" ) func newSt...
package problem1764 import "testing" func TestSolve(t *testing.T) { t.Log(canChoose([][]int{ []int{1, -1, -1}, []int{3, -2, 0}, }, []int{1, -1, 0, 1, -1, -1, 3, -2, 0})) t.Log(canChoose([][]int{ []int{10, -2}, []int{1, 2, 3, 4}, }, []int{1, 2, 3, 4, 10, -2})) t.Log(canChoose([][]int{ []int{1, 2, 3}, ...
package main import "math" func main() { println(int64(math.Mod(-10, 7))) }
// Types infers source locations and types from Go expressions. // and allows enumeration of the type's method or field members. package types import ( "bytes" "container/list" "fmt" "go/build" "log" "os" "path/filepath" "runtime" "strconv" "strings" "github.com/npat-efault/godef/exp-go/ast" "github.com/n...
package main import "net" import "strconv" import "bufio" import "fmt" type increment struct { amount int response chan<- int } func main() { listener, err := net.Listen("tcp", "0.0.0.0:3333") if err != nil { return } defer listener.Close() var value int connectionRoutine := func(conn net.Conn, outgoing...
package controllers import ( "encoding/json" "fmt" "github.com/jinzhu/gorm" ) type Conta2 struct { Email string Password string } func Login(db *gorm.DB, data []byte) string { var c Conta2 err := json.Unmarshal(data, &c) if err != nil { fmt.Println("Deu pau no json: ") fmt.Print(err) } fmt.Print...
// Copyright (c) 2020 TomoChain package main import ( "github.com/tomochain/tomochain-rosetta-gateway/common" "github.com/tomochain/tomochain-rosetta-gateway/config" "github.com/tomochain/tomochain-rosetta-gateway/services" tc "github.com/tomochain/tomochain-rosetta-gateway/tomochain-client" "log" "net/http" "...
package kyu8 import "strings" func AbbrevName(name string) string { var parts []string stringList := strings.Split(name, " ") for _, str := range stringList { firstLetter := str[:1] parts = append(parts, strings.ToUpper(firstLetter)) } return strings.Join(parts, ".") } func AbbrevNameOld(name string) string...
package login var List = map[string]string{"installation": `{{define "installation"}} <html> <head> <title>GoAdmin Install</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> <link rel="stylesheet" href="../../ass...
/* * Copyright @ 2020 - present Blackvisor Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable l...
package model import ( "encoding/json" ) type Gallery struct { id int64 name string photos []int64 } type GalleryJSON struct { Id int64 Name string Photos []int64 } func (g *Gallery)MarshalJSON() ([]byte, error){ return json.Marshal(GalleryJSON{ g.id, g.name, g.photos, }) } func (g *Gallery)Unmarsha...
package ini_configer_test import ( "fmt" "github.com/ztxmao/vii/library" "testing" ) var ( configFile = "app.conf" configIniFile = "app.ini" c = library.Configer ce = library.ConfigerExt p = fmt.Println ) func init() { c.Init(configFile) ce.Init(configIniFile, "dev") }...
/* What are type Methods? Type methods are go functions with some special reciever argument. implementation of function is exactly the same as the implementation of methods ! */ package main import ( "fmt" ) type twoPoint struct { X int64 Y int64 } func normal(a, b twoPoint) twoPoint { num := twoPoint{X: a.X...
/* Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0. Example 1: Input: nums = [21,4,7] Output: 32 Explanation: 21 has 4 divisors: 1, 3, 7, 21 4 has 3 divisors: 1, 2, 4 7 has 2 divisors: 1, 7 The a...
package store import "errors" var ( ErrNotFound = errors.New("not found") ErrExist = errors.New("exist") ) type Book struct { Id string `json:"id"` // 图书ISBBN ID Name string `json:"name"` // 图书名称 Authors []string `json:"authors"` // 图书作者 Press string `json:"press"` // 出版社 } type S...
package services import ( "fmt" "testing" currency "github.com/chutommy/metal-price/currency/service/protos/currency" "google.golang.org/grpc" "gopkg.in/go-playground/assert.v1" ) func TestCurrency(t *testing.T) { // >>>>>>>>>>>>>>> NewCurrency currencyConn, err := grpc.Dial("localhost:10501", grpc.WithInsec...
package main import ( "encoding/json" "fmt" "net/http" ) type helloWorldResponse struct { Message string `json:"message"` } func main() { http.HandleFunc("/helloworld", helloWorldHandler) http.ListenAndServe(":8080", nil) } func helloWorldHandler(w http.ResponseWriter, r *http.Request) { response := helloWor...
package colar import ( "github.com/abnersun2016/colar" "log" "net/http" "testing" ) func TestRouter_AddMethod(t *testing.T) { route := colar.New() route.AddMethod("*", "gitchat/posts", handle1) route.AddMethod("post", "gitchat/posts/:Id", handle2) route.AddMethod("*", "gitchat/posts/Gomments/ID", handle3) ro...
package appdynamics import ( "fmt" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "os" "strconv" "strings" "testing" ) func TestAccAppDAction_basicSMS(t *testing.T) { phoneNumber := ...
// Copyright 2022 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package cli import ( "github.com/stretchr/testify/assert" "testing" ) const terraformCodeExampleOutputOnly = ` output "hello" { value = "Hello, World" } ` const terraformCodeExampleGcpProvider = ` provider "google" { credentials = file("account.json") project = "my-project-id" region = "us-central...
package exoscale import ( "context" "fmt" "regexp" "github.com/exoscale/egoscale" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" cloudprovider "k8s.io/cloud-provider" ) var labelInvalidCharsRegex *regexp.Regexp = regexp.MustCompile(`([^A-Za-z0-9][^-A-Za-...
package c27_cbc_iv_equal_key import ( "bytes" "crypto/aes" "errors" "unicode" "github.com/vodafon/cryptopals/set1/c2_fixed_xor" "github.com/vodafon/cryptopals/set2/c09_pkcs7_padding" "github.com/vodafon/cryptopals/set2/c10_implement_cbc_mode" ) type Enc struct { key []byte head []byte tail []byte } func ...
package main import ( "fmt" "os" "github.com/AlexAkulov/clickhouse-backup/config" // "github.com/AlexAkulov/clickhouse-backup/internal/logfmt" "github.com/AlexAkulov/clickhouse-backup/internal/logcli" "github.com/AlexAkulov/clickhouse-backup/pkg/backup" "github.com/AlexAkulov/clickhouse-backup/pkg/server" "g...
package nfs import ( "context" "fmt" nfsstoragev1alpha1 "github.com/johandry/nfs-operator/api/v1alpha1" "github.com/johandry/nfs-operator/resources" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/co...
// DO NOT EDIT. This file was generated by "github.com/frk/gosql". package testdata import ( "github.com/frk/gosql" ) func (q *InsertOnConflictConstraintIgnoreSingle1Query) Exec(c gosql.Conn) error { const queryString = `INSERT INTO "test_onconflict" AS k ( "key" , "name" , "fruit" , "value" ) VALUES ( ...
package helpers import ( "fmt" "os" "os/signal" "strings" "syscall" "time" ui "github.com/gizak/termui/v3" "github.com/gizak/termui/v3/widgets" ) var ( nodesTable *widgets.Table resourcesGrid, syncGrid *ui.Grid syncGauges []*widgets.Gauge cpuLoadGauge, memLoadGauge *wid...
package cmd import ( "github.com/spf13/cobra" "github.com/yugabyte/yugabyte-db/managed/yba-installer/common" log "github.com/yugabyte/yugabyte-db/managed/yba-installer/logging" "github.com/yugabyte/yugabyte-db/managed/yba-installer/preflight" ) var upgradeCmd = &cobra.Command{ Use: "upgrade", Short: "The upgr...
package rpcretry import ( "bytes" "context" "fmt" "regexp" "strings" "testing" "time" "github.com/MakeNowJust/heredoc/v2" "go.mercari.io/datastore" "go.mercari.io/datastore/dsmiddleware/dslog" "go.mercari.io/datastore/internal/testutils" "google.golang.org/api/iterator" ) func TestRPCRetry_waitDuration(t...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //525. Contiguous Array //Given a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1. //Example 1: //Input: [0...
package domain type SecuritySpaceUser struct { Email string Password string CreationDate string }
package tag import ( "github.com/go-jar/goerror" "github.com/go-jar/gohttp/query" "blog/errno" ) func (tc *TagController) DeleteAction(context *TagContext) { if err := tc.VerifyToken(context.ApiContext); err != nil { context.ApiData.Err = goerror.New(errno.EUserUnauthorized, err.Error()) return } id, err ...
/* * VMaaS Webapp * * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * * API version: 1.3.2 * Generated by: OpenAPI Generator (https://openapi-generator.tech) */ package vmaas import ( _context "context" _ioutil "io/ioutil" _nethttp "net/http" _ne...
/* Your spouse tells you that one of the items on the list wasn't stolen, it is in your castle in Transilvania. Given an object of the stolen items and an item name, return a copy without that item on the list. Examples { piano: 300, tv: 100, skate:50 } ➞ { piano: 300, tv: 100 } { mirror: 500, painting: 1 } ➞ { pai...
package common import ( "encoding/json" "fmt" "github.com/APTrust/exchange/network" "github.com/APTrust/exchange/util" "strings" "time" ) type DownloadResult struct { Region string `json:"region"` Bucket string `json:"bucket"` Key str...
package left import ( "github.com/therecipe/qt/quick" "github.com/therecipe/qt/internal/examples/showcases/wallet/view/left/controller" ) func init() { progressBarTemplate_QmlRegisterType2("LeftTemplate", 1, 0, "ProgressBarTemplate") } type progressBarTemplate struct { quick.QQuickItem _ func() `c...
package entrance import ( "fmt" "time" "github.com/meidoworks/nekoq-api/env" ) func GenerateRequestId() string { t := time.Now() return fmt.Sprint(env.GetNodeId(), ".", t.Unix(), ".", t.UnixNano()) }
package v1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // KeystoneAPISpec defines the desired state of KeystoneAPI // +k8s:openapi-gen=true type KeystoneAPISpec struct { // Keystone Database Password String DatabasePassword string `json:"databasePassword,omitempty"` // Keystone Database Hostname Stri...
package socket import ( "fmt" "strings" socketio "github.com/googollee/go-socket.io" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" ) var Sockets []socketio.Conn func Start(port string) { server := socketio.NewServer(nil) server.OnConnect("/", func(s socketio.Conn) error { s.SetCo...
package ibeplus import ( "encoding/xml" "fmt" "strconv" "github.com/otwdev/ibepluslib/models" "github.com/otwdev/galaxylib" "github.com/asaskevich/govalidator" golinq "github.com/ahmetb/go-linq" ) type AirFarePriceResponse struct { PNR *models.PnrInfo RQ *FareRoot } func NewFarePriceResponse(pnr *model...
package model import ( // "time" ) type Relation struct { Id string `json:"id"` UserId int `json:"user_id"` OtherUserId int `json:"other_user_id"` State string `json:"state"` Type string `json:"type"` // CreateTime time.Time `json:"create_time"` // UpdateTime time.Time `json:"update_...
package Test import ( "fmt" "io" "log" "net/http" "os" "path" "strings" "sync" "github.com/k0kubun/go-ansi" "github.com/schollz/progressbar/v3" ) type Downloader struct { concurrency int resume bool bar *progressbar.ProgressBar } func NewDownloader(concurrency int, resume bool) *Downloader { ret...
package server import ( "net/http/httptest" "testing" "github.com/calvinmclean/automated-garden/garden-app/pkg" "github.com/rs/xid" ) func TestPlantRequest(t *testing.T) { tests := []struct { name string pr *PlantRequest err string }{ { "EmptyRequest", nil, "missing required Plant fields", ...
// // date : 2014-06-04 // author: xjdrew // package tunnel import ( "bufio" "encoding/binary" "fmt" "io" "net" "sync" "time" ) var Timeout int64 // tunnel read/write timeout type Payload struct { linkid uint16 data []byte } type Tunnel struct { conn *net.TCPConn // low level conn writer *bufi...
// Package house provides functions for retrieving the inputed auctions, // the winning bids and some stats package house import ( "log" "strconv" "strings" ) //Auction stores details of the incoming auction type Auction struct { StartTime int64 UserID int ActionType string Item string Price f...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //188. Best Time to Buy and Sell Stock IV //Say you have an array for which the ith element is the price of a given stock on day i. //Design an algorit...
/* * @lc app=leetcode id=76 lang=golang * * [76] Minimum Window Substring * * https://leetcode.com/problems/minimum-window-substring/description/ * * algorithms * Hard (31.33%) * Likes: 2467 * Dislikes: 165 * Total Accepted: 252.5K * Total Submissions: 806K * Testcase Example: '"ADOBECODEBANC"\n"ABC...
package main import ( tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" log "github.com/sirupsen/logrus" "sync" "time" ) type ChatAction struct { tgbotapi.ChatActionConfig Count int } type ChatActionManager struct { ChatActionList []ChatAction Lock sync.Mutex } func (cal *ChatActionManager) ActionL...
package manage import ( "KServer/library/kiface/iserver" "KServer/library/server" "KServer/manage/config" "KServer/manage/discover" "KServer/manage/pack" "KServer/manage/pack/socket" "KServer/manage/pack/websocket" ) type IManage interface { // 服务器管理 Server() iserver.IServer // 通信协议 Message() pack.IMessage...
package instance_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/pivotal-cf/spring-cloud-services-cli-plugin/serviceutil" "bytes" "errors" "github.com/pivotal-cf/spring-cloud-services-cli-plugin/httpclient/httpclientfakes" "github.com/pivotal-cf/spring-cloud-services-cli-plugin/...
/* A binary convolution is described by a number M, and is applied to a number N. For each bit in the binary representation of M, if the bit is set (1), the corresponding bit in the output is given by XORing the two bits adjacent to the corresponding bit in N (wrapping around when necessary). If the bit is not set (0)...
// Copyright 2015 Alexey Martseniuk. All rights reserved. // Use of this source code is governed by a MIT license // that can be found in the LICENSE file. package linq import ( "container/list" ) func newSet(eq func(T, T) bool) *hashSet { if eq == nil { eq = func(l, r T) bool { return l == r } } s := new...
package models import ( "mime/multipart" ) type FileDownloadRequest struct { Namespace string `uri:"namespace" binding:"required"` Name string `uri:"name" binding:"required"` Version string `uri:"version" binding:"required,version|eq=latest"` FullNames []string } // ToSnapshot creates snapshot func (f *F...
package parser1c import ( "fmt" "regexp" "parser1c/internal/storage" "strings" ) var pattern string //ImportData Преобразуем текст файла с реестром в нашу структуру документа func ImportData(data string) (doc *storage.File1C, err error) { doc = storage.NewFile1C() lines := strings.SplitN(data, "\n", 2) if ...
package body import ( "encoding/json" "github.com/imulab/coldcall" ) // JSONMarshal option marshals the given body into JSON and sets it // as the body on http.Request. // // The supplied body parameter must not be nil, otherwise ErrNoBody // error is returned. In addition, the body parameter must be capable of // ...
package globalError import ( "github.com/gin-gonic/gin" "net/http" ) const ( InvalidExpression = 1001 //表达式不合法 IllegalSymbol = 10011 //出现非法字符 HeadOperator = 10012 //表达式首字符为运算符 EndOperator = 10013 //表达式最后一个字符为运算符 SuccessiveOperator = 10014 //连续出现运算符 ExpIsEmpty = 10015 //表达式为空 ) ty...
package models import ( "compress/gzip" "crypto/tls" "github.com/astaxie/beego" "github.com/astaxie/beego/logs" "io" "io/ioutil" "net/http" "net/url" "os" "strings" ) //Jar struct type Jar struct { cookies []*http.Cookie } //SetCookies a func (jar *Jar) SetCookies(u *url.URL, cookies []*http.Cookie) { ja...
package fakes import ( bmdepl "github.com/cloudfoundry/bosh-micro-cli/deployment" bmstemcell "github.com/cloudfoundry/bosh-micro-cli/stemcell" bmvm "github.com/cloudfoundry/bosh-micro-cli/vm" ) type CreateVMInput struct { StemcellCID bmstemcell.CID Deployment bmdepl.Deployment } type createVMOutput struct { c...
package es import ( "context" "fmt" "github.com/olivere/elastic/v7" "strings" ) type LogData struct { Topic string `json:"topic"` data string `json:"data"` } var ( client *elastic.Client ch = make(chan LogData, 100000) ) // 初始化ES,准备接受Kafka那边发来的数据 func Init(address string)(err error) { if !strings.HasPrefix(...
package main import "fmt" func main() { //x :=[]float64 {43 ,99 ,99 ,97 ,88} var xa[5]float64 for i :=0; i<5 ;i++{ // Why not able to take input and run the same logic ?? fmt.Scanf("%f",&xa[i]) } x :=xa[2:4] // able to take input , save it ...
package arrays import "testing" func TestIsMonotonic(t *testing.T) { if !isMonotonic([]int{1, 1, 2, 3, 4, 5, 7, 7, 7}) { t.Fail() } } func TestIsMonotonic1(t *testing.T) { if isMonotonic([]int{2, 1, 2, 3, 4, 5, 7, 7, 7}) { t.Fail() } }
package route import ( "github.com/gorilla/mux" "go_web/app/http/middlewares" "go_web/app/http/views" "net/http" ) func RegisterWebRoutes(r *mux.Router) { pc := new(views.PagesController) // home 首页 r.HandleFunc("/", pc.Home).Methods("GET").Name("home") // 自定义 404 页面 r.NotFoundHandler = http.HandlerFunc(pc...
package xml import ( "fmt" "strings" "testing" ) const readerXml = "<root k='v' kk='vv'><child>text</child></root>" func TestReadSE(t *testing.T) { fmt.Println("testReadSE") r := NewReader(strings.NewReader(readerXml)) f := r.ReadStartElement() f.inspect() } func TestReadE(t *testing.T) { fmt.Println("test...
package p import ( "path" "testing" ) func TestClean(t *testing.T) { unix := `/../test` t.Log("unix:", unix, "to", path.Clean(unix)) win := `c:\windows\..\path` t.Log("windows:", win, "to", path.Clean(win)) } func TestJoin(t *testing.T) { ss := []string{ "hello", "world", } t.Log(path.Join(ss...)) ss...
//go:build ignore // +build ignore package main import ( "context" "fmt" "github.com/looplab/fsm" ) func main() { fsm := fsm.NewFSM( "closed", fsm.Events{ {Name: "open", Src: []string{"closed"}, Dst: "open"}, {Name: "close", Src: []string{"open"}, Dst: "closed"}, }, fsm.Callbacks{}, ) fmt.Print...
package main import ( "fmt" "github.com/streadway/amqp" "log" "encoding/json" "time" //"net/url" "io/ioutil" ) type RabbitClient struct { ch *amqp.Channel } func failOnError(err error, msg string) { if err != nil { log.Fatalf("%s: %s", msg, err) panic(fmt.Sprintf("%s: %s", msg, err)) } } ...
package libsignal /* #cgo CFLAGS: -W #cgo LDFLAGS: -L. ./lib/libsignal_ffi.a -lpthread -ldl -lm #include "lib/signal_ffi.h" //returns the size of a character array using a pointer to the first element of the character array */ import "C" import ( "crypto/rand" "unsafe" ) func cBytes(b []byte) *C.uchar { return (...
// is map reference?? // yes!! package main import "fmt" func main() { var m = map[string]int{"one" : 1, "two" : 2, "three" : 3} printMap(m) modifyMap(m) printMap(m) } func modifyMap(m map[string]int) { m["four"] = 4 m["five"] = 5 } func printMap(m map[string]int) { fmt.Printf("type = %...
// Copyright 2023 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package rpc import ( "log" ) type InputHandler struct { ViewID string FilePath string Xi *Connection } func (ih *InputHandler) edit(params Object) { params["view_id"] = ih.ViewID if _, ok := params["params"]; !ok { params["params"] = &Object{} } ih.Xi.Notify(&Request{ Method: "edit", Params: p...
// Copyright (c) 2020 Blockwatch Data Inc. package index import ( "context" "errors" "fmt" "github.com/jinzhu/gorm" "github.com/zyjblockchain/sandy_log/log" "tezos_index/chain" "tezos_index/puller/models" "tezos_index/rpc" ) const ContractIndexKey = "contract" var ( ErrNoContractEntry = errors.New("contrac...
package lang import ( "testing" assert "github.com/go-playground/assert/v2" ) // GetLangs func Test_GetLangs_givenSingleLanguage_expectListWithOneItem(t *testing.T) { given := "java" actual, err := GetLangs(given) assert.Equal(t, err, nil) assert.Equal(t, len(actual), 1) assert.Equal(t, actual[0].GetInfo()....
package main import "regexp" // DataPoint is a typle of [UNIX timestamp, value]. This has to use floats // because the value could be non-integer. type DataPoint [2]float64 type Metric struct { Metric string `json:"metric,omitempty"` Points []DataPoint `json:"points,omitempty"` Type string `json:"type...
package main import ( "bufio" "errors" "fmt" "log" "os" "strconv" "strings" ) const ( defaultLines = 10 ) type config struct { lines int files []string } // 出力内容を出力する func printLines(file *os.File) error { b := bufio.NewReader(file) for { line, err := b.ReadString('\n') if err != nil { fmt.Prin...
package octopus import( "time" "math" "runtime" "sync" "sync/atomic" ) type dataWorker struct { pool *DataProcessPool jobChannel chan Future stop chan bool } func (w *dataWorker) getStopChannel() chan bool { return w.stop } func (w *dataWorker) getJobChannel() chan Future { return w.jobChannel } func exe...
package util import ( "fmt" "strings" ) // Beautify takes a table and returns well inlined rows. func Beautify(rows [][]string, space int) ([]string, error) { if rows == nil || len(rows) == 0 { return nil, fmt.Errorf("Input is nil or empty") } max := make([]int, len(rows[0])) var l int for rk, rv := range...
package main import ( "encoding/csv" "encoding/json" "fmt" "io" "os" ) type Person struct { FirstName string `json:"firstname"` LastName string `json:"lastname"` DOB string `json:"dob"` Address *Address `json:address` } type Address struct { Country string `json:"country"`...
// chan project main.go package main import ( "fmt" "time" //"time" ) func main() { ch := make(chan int) // go func() { // for i := 0; i < 5; i++ { // time.Sleep(time.Duration(5-i) * time.Second) // fmt.Println("go inner 前", i) // ch <- i // fmt.Println("go inner 后", i) // } // }() go test1(ch...
package objs import ( "errors" "github.com/devplayg/ipas-mcs/libs" "regexp" "strings" "time" "unicode" "unicode/utf8" ) type Member struct { MemberId int `json:"member_id" form:"member_id"` Username string `json:"username" form:"username"` Password string `...
package multiple import ( "bytes" "errors" "sync" "time" "ucp/common" ) const ( MAXID uint32 = 0xFFFFFFFF ) var ( PROTOCOL = []byte{0, 'u', 'c', 'p'} PHEAD = len(PROTOCOL) HEADER_LEN = PHEAD + 4 + 2 + 2 MAXMTU = 1500 UCPMTU = MAXMTU - 20 - 8 - HEADER_LEN pool = sync.Pool{ New: func() in...
package main import ( "fmt" "io" "os" "debug/elf" ) func check(e error) { if e != nil { panic(e) } } func ioReader(file string) io.ReaderAt { r, err := os.Open(file) check(err) return r } func main() { _elf, err := elf.Open(os.Args[1]) if err != nil { panic(err) } var arch string switch _elf.Cla...
// Copyright 2015 The Go Circuit Project // Use of this source code is governed by the license for // The Go Circuit Project, found in the LICENSE file. // // Authors: // 2015 Petar Maymounkov <p@gocircuit.org> package use import ( "github.com/gocircuit/runtime/sys" "github.com/gocircuit/runtime/sys/backdial" "g...
package main import ( _ "./src/server" "log" ) func init() { log.SetPrefix("INFO") log.SetFlags(log.Ldate | log.Lmicroseconds | log.Llongfile) } func main() { log.Println("med sunny server is running ...") }
package main func init() { Register("chord", "chord", ` <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> #tooltip { color: white; opacity: .9; background: #333; padding: 5px; bo...
package commands import ( "errors" "fmt" "math/big" "github.com/qlcchain/go-qlc/common/types" "github.com/qlcchain/go-qlc/rpc/api" rpc "github.com/qlcchain/jsonrpc2" "github.com/qlcchain/go-qlc/cmd/util" "github.com/abiosoft/ishell" "github.com/spf13/cobra" ) func minerHistory() { var coinbaseP string ...
package main import ( "context" "google.golang.org/grpc" "google.golang.org/grpc/reflection" "grpc-demo/api" "grpc-demo/internal/service" "log" "net" ) const ( port = ":22222" ) func main() { ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() lis, err := net.Listen("tcp", ...
package main import ( "errors" "fmt" "log" "os" "github.com/albarin/jit/pkg/command" ) const initCommand = "init" func run() error { gc, err := getCommand() if err != nil { return err } switch gc { case initCommand: wd, err := os.Getwd() if err != nil { return errors.New("cannot get current work...
package app import ( "github.com/gin-gonic/gin" "github.com/yjagdale/siem-data-producer/utils/logger" "log" ) var router *gin.Engine func StartApp() { logger.InitLogger() MigrateDB() MapUrls() startApplication() } func startApplication() { err := router.Run(":8080") if err != nil { log.Fatalln("failed to...
package stockcode import ( "fmt" "realStock/config" "strconv" "strings" "sync" "time" "github.com/gocolly/colly" ) type TradeInfo struct { stockCodeArray [] StockInfo mutex sync.Mutex } func (info * TradeInfo) SetTradeInfo() { info.stockCodeArray = GetStockInfo() } func (info * TradeInfo)GetTradeInfo()...
package server import ( "github.com/naughtydevelopment/todo-go/config" ) func Init() { c := config.GetConfig() port := c.GetString("server.port") r := NewRouter() r.Run(port) }
package cos import ( "context" "fmt" "io" "github.com/pengsrc/go-shared/convert" "github.com/sirupsen/logrus" "github.com/tencentyun/cos-go-sdk-v5" "github.com/yunify/qscamel/model" "github.com/yunify/qscamel/utils" ) // Name implement base.Read func (c *Client) Name(ctx context.Context) (name string) { re...
package entranceserver import ( "encoding/binary" "net" "github.com/Andoryuuta/Erupe/common/stringsupport" "github.com/Andoryuuta/Erupe/config" "github.com/Andoryuuta/byteframe" ) func paddedString(x string, size uint) []byte { out := make([]byte, size) copy(out, x) // Null terminate it. out[len(out)-1] =...