text
stringlengths
11
4.05M
package chainclient import ( "github.com/iotaledger/wasp/client/multiclient" "github.com/iotaledger/wasp/packages/coretypes" "github.com/iotaledger/wasp/packages/coretypes/requestargs" "github.com/iotaledger/wasp/packages/hashing" "github.com/iotaledger/wasp/packages/kv/dict" "github.com/iotaledger/wasp/packages...
package problem0172 func trailingZeroes(n int) int { result := 0 bound := n for bound > 0 { bound = bound / 5 result += bound } return result }
package main import ( f "fmt" ) func main() { f.Println("Hello, World") }
package j2rpc import ( "reflect" ) // SnakeOption ... var SnakeOption = &Option{SnakeNamespace: true} // Option ... type Option struct { SnakeNamespace bool BeforeMid []middleInfo } //AddBeforeMiddleware ... /** * @Description: * @receiver o * @param method * @param fn: //参数顺序: ctx,method,writer,request...
package findgameusecase import ( "backend/internal/adapters/brokenrepo" "backend/internal/adapters/inmemoryrepo" "backend/internal/domain" "github.com/stretchr/testify/assert" "testing" ) func Test_Game_found(t *testing.T) { givenGame := domain.NewGame() gameRepository := inmemoryrepo.NewGameRepository() _ = ...
package rbt import ( "testing" ) var tree = NewTree(func(f, s interface{}) Comparison { intF, _ := f.(string) intS, _ := s.(string) switch { case intF < intS: return IsLesser case intF > intS: return IsGreater } return AreEqual }) func TestTreeInsert(t *testing.T) { tree.Insert("A", nil) t.Log(tree) t...
package subscan_plugin import ( "github.com/social-network/subscan-plugin/router" "github.com/social-network/subscan-plugin/storage" "github.com/shopspring/decimal" ) type Plugin interface { InitDao(d storage.Dao) InitHttp() []router.Http ProcessExtrinsic(*storage.Block, *storage.Extrinsic, []storage.Event) e...
package config import ( "context" "errors" "github.com/kataras/golog" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "time" ) type DB string const ( POST DB = "gnemes_post" USER DB = "gnemes_user" ) func GetGnemesDBClient(db DB, logger *golog.Logger) (*mongo.Client, error) {...
package ospafLib import ( "bytes" "crypto/md5" "fmt" "io" "os" "path" "regexp" "strconv" "strings" ) func ReadFile(file_url string) (content string, err error) { _, err = os.Stat(file_url) if err != nil { content = fmt.Sprintf("Cannot find the file %s.", file_url) return content, err } file, err := o...
// Copyright 2023 Google LLC. All Rights Reserved. // // 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 applica...
package main import "fmt" func callByValue(i int) { i += 1 } func callByReference(i *int) { *i += 1 } func main(){ p := fmt.Println i := 1 p(i) callByValue(i) p(i) callByReference(&i) p(i) callByReference(&i) p(i) }
package adnetwork import ( "github.com/econnelly/myrevenue" "io" "time" ) type Request interface { Initialize() error Fetch() ([]myrevenue.Model, error) GetStartDate() time.Time GetEndDate() time.Time GetName() string GetReport() interface{} } type DirectlyParsable interface { ParseRevenue(reader io.Reader...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/12/26 11:57 上午 # @File : lt_35_搜索插入位置.go # @Description : # @Attention : */ package hot100 // 关键: 题目需要转换为:「在一个有序数组中找第一个大于等于 target的下标 (相当于是找第一个出现的位置) func searchInsert(nums []int, target int) int { left, right := 0, len(nums)-1 for left+1 < right { mid :=...
package labelblocker import ( "fmt" "regexp" "strings" "github.com/sirupsen/logrus" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/test-infra/prow/config" "k8s.io/test-infra/prow/github" "k8s.io/test-infra/prow/pluginhelp" "k8s.io/test-infra/prow/pluginhelp/externalplugins" "k8s.io/test-infra/prow/plugins" t...
package store import ( "encoding/json" "strings" "github.com/micro/go-micro/v2/auth" "github.com/micro/go-micro/v2/store" ) // Rule is an access control rule type Rule struct { Role string `json:"rule"` Resource *auth.Resource `json:"resource"` } // Key to be used when written to the store func (r...
package main import ( "crypto/md5" "fmt" "io" "os" ) func main() { testFile := "./glog.go" file, inerr := os.Open(testFile) if inerr == nil { md5h := md5.New() io.Copy(md5h, file) fmt.Printf("%x %s\n", md5h.Sum([]byte("")), testFile) //md5 } }
package quoterequest import ( "github.com/shopspring/decimal" "github.com/quickfixgo/quickfix" "github.com/quickfixgo/quickfix/enum" "github.com/quickfixgo/quickfix/field" "github.com/quickfixgo/quickfix/fix40" "github.com/quickfixgo/quickfix/tag" ) //QuoteRequest is the fix40 QuoteRequest type, MsgType = R ty...
package parquet_test import ( "testing" "github.com/segmentio/parquet-go" ) func TestFilterRowReader(t *testing.T) { rows := []parquet.Row{ {parquet.Int64Value(0)}, {parquet.Int64Value(1)}, {parquet.Int64Value(2)}, {parquet.Int64Value(3)}, {parquet.Int64Value(4)}, } want := []parquet.Row{ {parquet....
package helper //// #include <stdio.h> //// #include <stdlib.h> import ( "encoding/base64" "crypto/md5" "fmt" "os" "time" //"unsafe" ) const ( base64Table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ) var Base64_ = base64.NewEncoding(base64Table) /* func Alloc(size uintptr) *byte...
package types const ( // EventTypeScopeCreated is the event type generated when new scopes are created. EventTypeScopeCreated string = "scope_created" // EventTypeScopeUpdated is the event type generated when existing scopes are updated. EventTypeScopeUpdated string = "scope_updated" // EventTypeScopeOwnership is...
package core import ( "fmt" "net/http" "reflect" "strings" "time" "github.com/google/uuid" "gopkg.in/jeevatkm/go-model.v1" ) // Builder Object for RepositoryService type repositoryServiceBuilder struct { tableName string userIdKey string model Entitier queryRepository queryRe...
package webauthn import ( "glsamaker/pkg/app/handler/authentication/auth_session" "glsamaker/pkg/app/handler/authentication/utils" "encoding/json" "fmt" "github.com/duo-labs/webauthn.io/session" webauthn_lib "github.com/duo-labs/webauthn/webauthn" "glsamaker/pkg/config" "log" "net/http" ) var ( WebAuthn ...
package drobox import ( "bytes" "encoding/json" "fmt" "net/http/httptest" "testing" ) func TestDownloadDoc(t *testing.T) { t.Run("factory method success", func(t *testing.T) { owner := "fscoward" title := "download markdown" revision := 100 mimeType := "text/x-markdown" body := "test" jsonString :...
// The weave command is a simple preprocessor for markdown files. // It builds a table of contents and processes %include directives. // // Example usage: // // $ go run internal/cmd/weave go-types.md > README.md // // The weave command copies lines of the input file to standard output, with two // exceptions: // // If...
package main import ( "fmt" "sort" ) type Mass float64 type Miles float64 /*// class Employee type Employee struct { Name string ID string SSN int Age int } // ToString method func (employee Employee) ToString() string { return fmt.Sprintf("%s: %d,%s,%d", employee.Name, employee.Age, employee.ID, employe...
package manager import ( "github.com/labstack/echo" "net/http" ) type api struct { name string get string handlerFunc echo.HandlerFunc } func newApi() *api { return &api{ name:"", } } // setDefaultHeader 는 모든 response 의 default 로 추가 / 제거 되어야하는 헤더를 설정한다. func setDefaultHeader(c *echo.Context) { ct...
package main import ( "time" "fmt" ) // select,如果有default子句,则执行该子句 // 如果没有default子句,select将阻塞,直到某个通道返回 // 如果有多个case可以运行,select会随机选出一个执行。其他不会执行 func main() { c1 := make(chan string) c2 := make(chan string) go func() { time.Sleep(time.Second * 5) c1 <- "first chan" }() go func() { time.Sleep(time.Second ...
package pollbot import ( "database/sql" "github.com/malware-unicorn/go-keybase-chat-bot/kbchat/types/chat1" "github.com/malware-unicorn/managed-bots/base" ) type TallyResult struct { choice int votes int } type Tally []TallyResult type DB struct { *base.DB } func NewDB(db *sql.DB) *DB { return &DB{ DB: ...
package hello func GetHelloText() string { return "text hello" }
package channelserver import ( "math/rand" "github.com/Andoryuuta/Erupe/network/mhfpacket" "github.com/Andoryuuta/byteframe" "go.uber.org/zap" ) func handleMsgMhfMercenaryHuntdata(s *Session, p mhfpacket.MHFPacket) {} func handleMsgMhfEnumerateMercenaryLog(s *Session, p mhfpacket.MHFPacket) {} func handleMsgMh...
package shims import ( "os" "path/filepath" ) const ( shimDirOSX = "/usr/local/bin" ) // OSX can Link and Unlink files to the system path for MacOS. type OSX struct{} // Link creates a symlink in /usr/local/bin similar to Homebrew. func (shim OSX) Link(target string) error { if err := os.MkdirAll(shimDirOSX, 07...
package database import ( "errors" "strconv" kciv1alpha1 "github.com/kloeckner-i/db-operator/pkg/apis/kci/v1alpha1" "github.com/kloeckner-i/db-operator/pkg/utils/kci" proxy "github.com/kloeckner-i/db-operator/pkg/utils/proxy" "github.com/kloeckner-i/db-operator/pkg/utils/proxy/proxysql" "github.com/sirupsen/l...
package auth import "github.com/KubeOperator/KubeOperator/pkg/permission" type Credential struct { Username string `json:"username"` Password string `json:"password"` Language string `json:"language"` } type SessionUser struct { UserId string `json:"userId"` Name string `json:"name"` Email string `jso...
package cmd import ( "context" "encoding/hex" "fmt" "log" "net" "os" "path" "strings" "golang.org/x/sync/errgroup" "github.com/grrtrr/clcv2" "github.com/grrtrr/clcv2/utils" "github.com/pkg/errors" "github.com/spf13/cobra" ) /* * Helper Functions */ // die is like die in Perl func die(format string, ...
package main import ( "fmt" "io/ioutil" "os/exec" "path" "runtime" ) func main() { i := 5 if i == 0 { return } _, filename, _, _ := runtime.Caller(0) if path.Base(filename) != "Sully.go" { i-- } s := fmt.Sprintf("Sully_%d.go", i) v := `package main import ( "fmt" "io/ioutil" "os/exec" "path" "r...
package main import ( "fmt" "math/rand" "time" ) func randomCancel(done chan struct{}) { go func() { max := rand.Intn(1000) + 1000 <-time.After(time.Duration(max) * time.Millisecond) close(done) }() } // START OMIT func Gen(done chan struct{}) <-chan int { out := make(chan int) go func() { defer close...
package middleware import ( "fmt" "github.com/dgrijalva/jwt-go" "github.com/sirupsen/logrus" "net/http" "os" "time" ) //自定义一个字符串 var jwtkey = []byte("*.audit.test.com") var sessionCookieName = os.Getenv("SessionCookieName") type Claims struct { UserName string jwt.StandardClaims } func CreateToken(userName ...
package main import ( "bytes" "io/ioutil" "reflect" "strings" "testing" ) type buffer struct { bytes.Buffer } func (b *buffer) Close() error { return nil } func TestTransformToJSON(t *testing.T) { type testCase struct { testDescription string yaml string expected string shouldErro...
package main import ( "fmt" "strings" ) /** * created: 2019/5/8 14:55 * By Will Fan */ func main() { str := "HI, I'M UPPER CASE!" lower := strings.ToLower(str) fmt.Println(lower) if strings.Contains(str, "case") { fmt.Println("Yes, exists!") } str = "abcdefghijklmnopqrstuvwxyz" fmt.Println("Char 3-1...
package gowf import ( "fmt" "net/http" ) func (app *App) Run() { addr := app.Config.HttpAddr if app.Config.HttpPort != 0 { addr = fmt.Sprintf("%s:%d", app.Config.HttpAddr, app.Config.HttpPort) } s := &http.Server{ Addr: addr, Handler: app.Handlers, } app.Logger.Printf("Running on %s", addr) err :...
/* The Universal Product Code (UPC-A) is a bar code used in many parts of the world. The bars encode a 12-digit number used to identify a product for sale, for example: 042100005264 The 12th digit (4 in this case) is a redundant check digit, used to catch errors. Using some simple calculations, a scanner can determi...
package problem0468 import "testing" func TestSolve(t *testing.T) { t.Log(poorPigs(1000, 15, 60)) t.Log(poorPigs(4, 15, 15)) t.Log(poorPigs(4, 15, 30)) t.Log(poorPigs(100, 15, 1500)) }
package fetch import ( "fmt" "io/ioutil" "net/http" "net/http/httptest" "net/url" "strconv" "testing" "time" "github.com/gorilla/mux" "github.com/slotix/dataflowkit/splash" "github.com/spf13/viper" "github.com/stretchr/testify/assert" ) func TestAssembleRobotstxtURL(t *testing.T){ res, err := AssembleR...
package usecases_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/golang/mock/gomock" "github.com/onsi/ginkgo/reporters" "testing" ) var mockCtrl *gomock.Controller var _ = BeforeEach(func() { defer GinkgoRecover() mockCtrl = gomock.NewController(GinkgoT()) }) var _ = AfterEac...
package slacker import ( "context" "github.com/slack-go/slack" ) // A BotContext interface is used to respond to an event type BotContext interface { Context() context.Context Event() *slack.MessageEvent RTM() *slack.RTM Client() *slack.Client GetUserName() (string, error) GetChannelName() (string, error) } ...
package alertmanager import ( "context" "time" "github.com/prometheus/alertmanager/api/v2/client/alert" "github.com/prometheus/alertmanager/types" "github.com/prometheus/common/model" ) func (c *Client) ListAlerts(ctx context.Context, receiver string, silenced bool) ([]*types.Alert, error) { getAlerts, err := ...
package chapter4 import ( "fmt" "os" "runtime" ) func init(){ test_init = 10 fmt.Println("Init_var:",c,test_init) } func init(){ fmt.Println("Init_var2:",c) } var test_init int //声明变量的一般形式是使用var 关键字 //var identifier type //不同于const不能省略type,注意不能省略这只是针对只声明变量,而const声明的同时必须赋值 //同时不同于常量,可以先只声明而不初始化 //const dddd int ...
/* Copyright 2019 The Kubernetes Authors. 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 in writing, ...
// +build jwkohnen_airac_proto /* * Copyright (c) 2020 Johannes Kohnen <jwkohnen-github@ko-sys.com> * * 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/licen...
package main import ( "fmt" "sort" ) // https://leetcode-cn.com/problems/3sum/ func threeSum0(nums []int) [][]int { var res [][]int sort.Ints(nums) for i, prei := 0, -1; i < len(nums)-2 && nums[i] <= 0; i++ { if prei >= 0 && nums[prei] == nums[i] { continue } for j, prej := i+1, -1; j < len(nums)-1 && ...
/* * EVE Swagger Interface * * An OpenAPI for EVE Online * * OpenAPI spec version: 0.4.1.dev1 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ package swagger // 200 ok object type GetDogmaEffectsEffectIdOk struct { // description string Description string `json:"description,omitem...
package main import ( "fmt" "pub/app" "pub/app/helpers/confighelper" "pub/app/helpers/loghelper" "pub/app/models" "pub/app/utils" "github.com/streadway/amqp" ) // init all stuffs required to project here... func init() { var err error // to set application configs from appConfig.yaml file err = setconfig...
/* Copyright © 2021 Denis Belyatsky <denis.bel@gmail.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, ...
package user import ( "fmt" "reflect" "github.com/go-jar/crypto" "github.com/go-jar/mysql" "github.com/go-jar/redis" "github.com/go-jar/sqlredis" "blog/conf" "blog/entity" "blog/resource" "blog/svc" ) type Svc struct { *svc.BaseSvc *sqlredis.SqlRedis RedisKeyPrefix string EntityName string } fun...
package sheet_logic import ( "hub/sheet_logic/sheet_logic_types" "math" "testing" ) func TestIntToStringConversion(t *testing.T) { uut := NewIntToStringConversion(variableName) grammarElementScenario(t, uut.GrammarElement, sheet_logic_types.IntToStringConversion) assertCalculatesToStringFails( t, uut, no...
package main import ( "fmt" "io/ioutil" "net/http" "regexp" "strconv" "time" ) var ( /** <img src="http://pic1.win4000.com/pic/c/26/8df58fd858_250_350.jpg" data-original="http://pic1.win4000.com/pic/c/26/8df58fd858_250_350.jpg" alt="巨乳美女睡衣诱惑性感私房写真图片" title="巨乳美女睡衣诱惑性感私房写真图片" style="display: inline;"> <img cl...
package main import ( "fmt" ) func renderArray(arrayPtr *[5]int) { fmt.Printf("%v\n", *arrayPtr) } func main() { // ====================================================== 1 声明会直接初始化 var array1 [5]int fmt.Printf("%v\n", array1) renderArray(&array1) // 数组指针作为参数 // ==============================================...
// Copyright 2021-present Open Networking Foundation. // // 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 applica...
package queue import "context" // Message represents a message received from a queue (or similar channel) of // some (presumably asynchronous) messaging system. type Message struct { // Message is an unstructured, textual representation of the data. Message string // Ack is a function that may be invoked to (if ap...
package serverutil import ( "fmt" "github.com/go-martini/martini" "golang.org/x/net/websocket" "log" "os" "sync" ) var logger = log.New(os.Stdout, "[Server]", 0) func newSessionManager() (sm *SessionManager) { sm = &SessionManager{} sm.sessions = make(map[int64]Session) sm.rwm = &sync....
package esm import ( "../driver/elevio" . "../config" ) //Function that remove element from queue: func remove_elem(index int) { for i := index; i < (len(queue) - 1); i++ { queue[i] = queue[i+1] if queue[i].Floor == empty_order.Floor { break } } } //Inserts element in the front of queue func insert_front...
package kata import( "strings" ) func isMoreThanFive(str string)bool{ if len(str)>=5{ return true } return false } func spin(str string)string{ result:="" for i:=len(str)-1;i>=0;i--{ result+=string(str[i]) } return result } func SpinWords(str string) string { //one or more //more than five ...
// Copyright 2021 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...
// Copyright 2018 the u-root Authors. All rights reserved // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package wifi import ( "bytes" "testing" ) func TestNative(t *testing.T) { // Some things may fail as there may be no wlan or we might not // have the r...
package loki import ( "errors" "fmt" "github.com/stretchr/testify/assert" "io/ioutil" "os" "testing" "time" ) var testFilePath = "test.log" func TestLoggerExample(t *testing.T) { SetLevel(DEBUG) SetFormatter(NewStandardFormatter()) msg := "Hi, I'm loki! 你好,我是洛基!" Debug("msg: %s", msg) Info("msg: %s", ms...
package main import ( "fmt" "sync" "time" ) var wg sync.WaitGroup var notify = make(chan bool, 1) func main() { wg.Add(1) go p() time.Sleep(time.Second * 5) notify <- true wg.Done() } func p() { defer wg.Done() LOOP: for { fmt.Println("孙世军") time.Sleep(time.Millisecond * 1000) select { case <-not...
package piksele import ( "encoding/xml" "errors" "image" "os" "path/filepath" _ "image/png" "github.com/faiface/pixel" "github.com/lafriks/go-tiled" ) type Spriteset struct { Sprites map[uint32]*pixel.Sprite Tileset *tiled.Tileset basePath string } func NewSpriteset() Spriteset { t := Spriteset{} t....
func maxSubArray(nums []int) int { s:=0 res:=math.MinInt32 for _,v:=range nums{ if s+v>v{ s=s+v }else{ s=v } if s>res{ res=s } } return res }
package quic import ( "errors" "fmt" "math" "github.com/golang/mock/gomock" "gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/flowcontrol" "gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/handshake" "gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/i...
package cmd import ( "fmt" "os" "os/signal" "syscall" "github.com/spf13/cobra" "github.com/ubclaunchpad/pinpoint/core/service" "github.com/ubclaunchpad/pinpoint/libcmd" "github.com/ubclaunchpad/pinpoint/utils" ) func (c *CoreCommand) getRunCommand() *cobra.Command { run := &cobra.Command{ Use: "run", ...
package freshbooks import ( "encoding/xml" "log" ) func ListProjects() (projectList ProjectList, err error) { projectListBytes, err := Do(Request{ Method: "project.list", }) err = xml.Unmarshal(projectListBytes, &projectList) if err != nil { log.Println(string(projectListBytes)) } return } func ListTasks...
package main import ( "fmt" "testing" ) func Test_AddMarkdown_1(t *testing.T) { input := "我和我妈说,我哥若是有了孩子后,你的生活更加累。我妈回我,若是我哥不要孩子,那以后她看到别人有孙子就会很寂寞。\n\n" + "让我有种感觉 老一辈的人,很少能离开社会寻找真正的快乐" fmt.Println(AddMarkdown(input)) }
package benchs import ( "database/sql" "fmt" "os" ) type Model struct { Id int `db:"id,pk",qbs:"pk" sql:"pk"` Name string Title string Fax string Web string Age int Right bool Counter int64 } func NewModel() *Model { m := new(Model) m.Name =...
package tempconv0 // Celsius ... type Celsius float64 // Fahrenheit ... type Fahrenheit float64 const ( // AbsoluteZeroC ... AbsoluteZeroC Celsius = -273.15 // FreezingC ... FreezingC Celsius = 0 // BoilingC ... BoilingC Celsius = 100 ) // CToF Converts Celsius to Fahrenheit func CToF(c Celsius) Fahrenheit { ...
package imagemanipulation import ( "image" "image/color" "strconv" "github.com/nfnt/resize" ) func Manipulate(collage *image.RGBA, gray bool, width string) (image.Image, error) { resizedCollage := resize.Thumbnail(1920, 1080, collage, resize.Lanczos3) if len(width) > 0 { width, err := strconv.ParseUint(width...
package env import ( "os" "strings" "testing" "gopkg.in/src-d/go-billy.v4/memfs" ) func TestTempDir(t *testing.T) { mfs := memfs.New() mfs.MkdirAll("/tmp", os.ModePerm) td, err := tempDir(mfs, "", "foo-") if err != nil { t.Fatalf("should have succeeded: %v", err) } if !strings.HasPrefix(td, "/tmp/foo-") ...
package pointers import ( "fmt" ) func TestPointer() { fmt.Println("Pointer test.......................") var t *int i := 100 t = &i fmt.Print("t = ") fmt.Print(t) fmt.Println("\nChaning i via t") *t = 200 fmt.Println(*t) fmt.Println(".......................") }
package handlers import ( "net/http" "gopkg.in/gin-gonic/gin.v1" ) // GetTempGraph ... func (d *Data) GetTempGraph(c *gin.Context) { var image []byte for _, sensor := range d.Data.CachedSensors { if sensor.ID == c.Param("sensorid") { image = sensor.TempGraph } } c.Header("Content-Type", "image/svg+xml"...
package pg import ( "github.com/kyleconroy/sqlc/internal/sql/ast" ) type DropRoleStmt struct { Roles *ast.List MissingOk bool } func (n *DropRoleStmt) Pos() int { return 0 }
package token type TokenType string type Token struct { Type TokenType Literal string } const ( ILLEGAL = "ILLEGAL" EOF = "EOF" ASSIGN = "=" KEY = "KEY" // add, foobar, x, y, ... INT = "INT" // 1343456 STRING = "STRING" // "foobar" LPAREN = "(" RPAREN = ")" LBRACE = "{" RBRACE = "}"...
package rpc import ( "testing" ) func Test_Client(t *testing.T) { c := NewClient() c.DailHTTP("127.0.0.1:9999") }
package bbir import ( "encoding/csv" "io" "strings" ) func NewCSVReader(r io.Reader) *CSVReader { reader := csv.NewReader(r) reader.Comma = ',' reader.LazyQuotes = true return &CSVReader{reader} } type CSVReader struct { *csv.Reader } func (r *CSVReader) ReadAll() (size int, lines []*Line, err error) { he...
package server import ( "iv-code-challenge/api/services" "iv-code-challenge/api/handlers" "log" "net/http" // "os" "github.com/rs/cors" // "github.com/gorilla/handlers" "github.com/gorilla/mux" ) type Server struct { router *mux.Router } func NewServer(ss services.ISubmissionService) *Server { s := Server{...
package constants const ( EmptyString = "" Success = "success" Failed = "failed" Pending = "pending" HealthCheckSuccess = "Health check successful" HealthCheckFailed = "Health check failed" Unauthorized = "unauthorized" Welcome = "Welcome to Wallet as ...
package hc import ( "bytes" "crypto/tls" "encoding/json" "fmt" "net" "net/http" u "net/url" "strings" "time" ) var tr = &http.Transport{ Proxy: http.ProxyFromEnvironment, TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, MaxIdleConns: 200, MaxIdleConnsPerHost: 100, IdleCon...
package powervs import ( "context" "sync" "github.com/IBM-Cloud/bluemix-go/crn" "github.com/pkg/errors" "github.com/openshift/installer/pkg/types" ) //go:generate mockgen -source=./metadata.go -destination=./mock/powervsmetadata_generated.go -package=mock // MetadataAPI represents functions that eventually ca...
package timeutil import ( "testing" "time" ) func TestFormatConciseDate(t *testing.T) { tm, _ := time.Parse(time.RFC3339, "2017-05-29T16:49:52+00:00") expected := "20170529" actual := FormatConciseDate(tm) if expected != actual { t.Errorf("expected:%s, actual:%s", expected, actual) } }
// Copyright 2020 Google LLC // // 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 in ...
package main import "fmt" func split(sum int)(x, y int){ x = sum * 4 / 9 y = sum - x return } func main(){ x,y := split(10); fmt.Println(x) fmt.Println(y) }
package dto import "github.com/KubeOperator/KubeOperator/pkg/model" type UserMessageDTO struct { model.UserMessage } type UserMessageOp struct { Operation string `json:"operation"` Items []UserMessageDTO `json:"items"` }
package 滑动窗口 func minWindow(s string, t string) string { ans := s + "0" // 为了判断是否存在答案,我采用这种方式初始化ans /* 1. 初始化窗口数据结构,用于记录窗口内的信息 */ windowMap := make(map[uint8]int) // 窗口内的字符映射, key是字符, value是出现次数 tMap := make(map[uint8]int) // t的字符映射, key是字符, value是出现次数 for i := 0; i < len(t); i++ { tMap[t[i]]++ } first, la...
package service import ( "fmt" "goldnoti/model" "goldnoti/repository" "log" "os" "time" "github.com/dustin/go-humanize" "github.com/line/line-bot-sdk-go/linebot" "github.com/spf13/viper" ) const ( timestampFormat = "2006-01-02T15:04:05Z" ) var ( // TimeZone : Bangkok Thailand TimeZone string ) // Setup...
package util import ( "bytes" "compress/gzip" "crypto/tls" "crypto/x509" "encoding/base64" "fmt" "io" "io/ioutil" "math/rand" "os" "strconv" "strings" "time" "github.com/nats-io/nats.go" "github.com/nats-io/nkeys" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/batchcorp/plumber-sc...
package pg import ( "github.com/kyleconroy/sqlc/internal/sql/ast" ) type AlterTableCmd struct { Subtype AlterTableType Name *string Newowner *RoleSpec Def ast.Node Behavior DropBehavior MissingOk bool } func (n *AlterTableCmd) Pos() int { return 0 }
package xml import ( "strings" "testing" ) func checkXML(t *testing.T, xmlStr, eName string, attMap map[string]string, hasEnd bool) { r := NewReader(strings.NewReader(xmlStr)) if !r.Next() { t.Fatal("Next() == false") } e := r.Element() if se, ok := e.(*StartElement); !ok { t.Fatal("Element() != *StartEle...
package collectors_test import ( "net/http" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/onsi/gomega/ghttp" cfclient "github.com/cloudfoundry-community/go-cfclient" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/log" . "github.com/bosh-prometheus/cf_expor...
package astutil import ( "fmt" "go/ast" "strings" ) //ExprString generates code by ast.Expr like printer.Fprint() // 经过拼装,可能与源码不完全一致 // TODO 2019.9.28 最开始不知道有 printer 这个包,手写了一坨,后面可能会直接接过去。。 // Deprecated func ExprString(expr ast.Expr) (name string) { switch exp := expr.(type) { // 字面值 literal case *ast.BasicLi...
package panels import ( "testing" "github.com/stretchr/testify/assert" ) func TestFilteredListGet(t *testing.T) { tests := []struct { f *FilteredList[int] args int want int }{ { f: &FilteredList[int]{allItems: []int{1, 2, 3}, indices: []int{0, 1, 2}}, args: 1, want: 2, }, { f: &F...
package universal import ( . "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo/extensions/table" . "github.com/onsi/gomega" config_core "github.com/kumahq/kuma/pkg/config/core" . "github.com/kumahq/kuma/test/framework" ) func MTLSUniversal() { var universalCluster Cluster E2EBeforeSuite(func() { universal...
package main import "fmt" func sliceQueue() { // 2. 通过切片模拟队列 queue := make([]int, 0) // 入队 queue = append(queue, 10, 20, 30) // 出队 v := queue[0] // 30 queue = queue[1:] fmt.Println("pop value: ", v, "\nnew queue: ", queue) }