text
stringlengths
11
4.05M
package usecase import ( models "github.com/OopsMouse/arbitgo/models" ) type Exchange interface { GetFee() float64 GetBalances() ([]*models.Balance, error) GetQuotes() []string GetSymbols() []models.Symbol GetDepth(symbol models.Symbol) (*models.Depth, error) GetDepthOnUpdate() chan *models.Depth SendOrder(or...
package three import ( "fmt" "os" "regexp" "strconv" "strings" ) func RunDay(filename string, part string) { var file, _ = os.ReadFile("three/" + filename + ".txt") var lines = strings.Split(string(file), "\n") var parts = make(map[string]func(lines []string)) parts["one"] = partTwo parts["two"] = partTwo ...
package cbs import ( "bytes" "encoding/binary" ) // There is better implementation! func uint16ToBytes(v interface{}) []byte { return anyToBytes(v) } func uint32ToBytes(v interface{}) []byte { return anyToBytes(v) } func anyToBytes(v interface{}) []byte { var buf bytes.Buffer err := binary.Write(&buf, binary....
package main import ( "fmt" "time" ) func main(){ timer1 := time.NewTimer(2*time.Second) t1 := time.Now() fmt.Printf("t1: %v\n",t1) t2 := <- timer1.C fmt.Printf("t2: %v\n",t2) time.After() }
package util import "testing" func TestFileDoesNotExist(t *testing.T) { t.Parallel() if FileExists("i would be surprised to discover that this file exists") { t.Fail() } }
package main type Point struct { x, y int } func (point *Point) Add(another *Point) *Point { return NewPoint(point.x + another.x, point.y + another.y) } func NewPoint(x, y int) *Point { return &Point{x, y} }
package document import ( "fmt" "io" "sigs.k8s.io/kustomize/v3/k8sdeps/kunstruct" "sigs.k8s.io/kustomize/v3/k8sdeps/transformer" "sigs.k8s.io/kustomize/v3/k8sdeps/validator" "sigs.k8s.io/kustomize/v3/pkg/fs" "sigs.k8s.io/kustomize/v3/pkg/gvk" "sigs.k8s.io/kustomize/v3/pkg/loader" "sigs.k8s.io/kustomize/v3/pk...
package bitbucket import ( "testing" ) func Test_Emails(t *testing.T) { const dummyEmail = "dummy@localhost.com" // CREATE an email entry if _, err := client.Emails.Find(testUser, dummyEmail); err != nil { _, cerr := client.Emails.Create(testUser, dummyEmail) if cerr != nil { t.Error(cerr) return } ...
package dbsrv import ( "time" "gopkg.in/doug-martin/goqu.v3" "github.com/chanxuehong/wechat.v2/mch/core" "github.com/empirefox/esecend/cerr" "github.com/empirefox/esecend/front" "github.com/empirefox/esecend/models" "github.com/empirefox/esecend/wx" "github.com/empirefox/reform" "github.com/golang/glog" ) ...
// +build !test package testws import ( "path/filepath" "bldy.build/build/label" ) type TestWS struct { WD string } func (t *TestWS) AbsPath() string { panic("not implemented") } func (t *TestWS) Buildfile(label.Label) string { panic("not implemented") } func (t *TestWS) File(lbl label.Label) string { if e...
package migrations import ( "database/sql" "github.com/DemoHn/obsidian-panel/pkg/dbmigrate" ) func init() { dbmigrate.AddMigration("20190209212436_create_account", UpT20190209212436, DownT20190209212436) } // UpT20190209212436 - migration up script func UpT20190209212436(db *sql.DB) error { // Add Up Logic Here...
/* Copyright 2021 The KubeVela 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, softw...
package schema import ( "themis/models" ) func createLinkTypeRelated() []models.LinkType { linkTypes := []models.LinkType { createLinkTypeRelatedStoryToTask(), createLinkTypeRelatedBugToTask(), createLinkTypeRelatedStoryToBug(), } return linkTypes } func createLinkTypeRelatedStoryToTask() models.LinkType {...
package model type ViewClubMember struct { Id int64 Uid int64 Nickname string Status int CreatedAt int64 }
package oauthstore import ( "context" "golang.org/x/oauth2" ) type storageTokenSource struct { *Config oauth2.TokenSource } // Token satisfies the TokenSource interface func (s *storageTokenSource) Token() (*oauth2.Token, error) { if token, err := s.Config.Storage.GetToken(); err == nil && token.Valid() { re...
/* Copyright 2020 Cornelius Weig. 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, software...
package solution02 import ( "adventofcode/inputs/input02" "fmt" "time" ) var opcodes []int func init(){ fmt.Println("Continue on:",time.Now()) } func Run(){ // 100*noun + verb result := -1 for noun :=0; noun <=99; noun++{ if result >= 0 { break } for verb :=0; verb <=99; verb++{ opcodes = input02....
package middlerware import ( "fmt" "github.com/lestrrat-go/file-rotatelogs" "github.com/rifflock/lfshook" "github.com/sirupsen/logrus" "os" "time" "../config" "../config/bean" ) var logLevels = map[bean.LogLevel]logrus.Level{ bean.Debug: logrus.DebugLevel, bean.Info: logrus.InfoLevel, bean.Wa...
/* * Copyright 2019-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 applicable law ...
// DON'T EDIT *** generated by scaneo *** DON'T EDIT // package model import "database/sql" func ScanCategory(r *sql.Row) (Category, error) { var s Category if err := r.Scan( &s.ID, &s.Name, &s.ImageUrl, ); err != nil { return Category{}, err } return s, nil } func ScanCategorys(rs *sql.Rows) ([]Catego...
package controllers import ( "net/http" "strings" "time" "user/common" "user/models" "user/util" "github.com/astaxie/beego" ) type ThirdloginController struct { beego.Controller } const ( //H5_APP_ID = "wx87f81569b7e4b5f6" //H5_APP_SECRET = "8421fd4781b1c29077c2e82e71ce3d2a" WEIXIN_URL = "https://api...
package main func letterCasePermutation(s string) []string { bs := []byte(s) n := len(bs) r := []string{} loopLetterCase(0, n, &bs, &r) return r } func loopLetterCase(l int, n int, bs *[]byte, r *[]string) { if l < n { loopLetterCase(l+1, n, bs, r) if (*bs)[l] >= 'a' && (*bs)[l] <= 'z' { tmp := (*bs)[l] ...
package easypost_test import ( "reflect" "strings" "github.com/EasyPost/easypost-go/v3" ) func (c *ClientTests) TestParcelCreate() { client := c.TestClient() assert, require := c.Assert(), c.Require() parcel, err := client.CreateParcel(c.fixture.BasicParcel()) require.NoError(err) assert.Equal(reflect.Type...
package demo import ( "fmt" "sync" ) var num int var wq sync.WaitGroup // 使用 waitGroup 确保线程运行完 var lock sync.Mutex // 使用互斥锁 func add() { for i := 0; i < 5000; i++ { lock.Lock() num++ lock.Unlock() } wq.Done() } func Test() { wq.Add(2) go add() go add() wq.Wait() fmt.Println("num=", num) }
package logger import ( "context" "fmt" "github.com/mingo-chen/wheel-minirpc/logger" "gopkg.in/yaml.v3" ) type LoggerPlugin struct { } // load config by plugin name func (l LoggerPlugin) Startup(cfg yaml.Node) { var log miniLog if err := cfg.Decode(&log.config); err != nil { panic(fmt.Errorf("decode plugin ...
//+ build js,wasm package gobridge import ( "syscall/js" "github.com/pkg/errors" ) var bridgeRoot js.Value const ( bridgeJavaScriptName = "__gobridge__" ) func registrationWrapper(fn func(this js.Value, args []js.Value) (interface{}, error)) func(this js.Value, args []js.Value) interface{} { return func(this j...
package gen type GoBaseType int const ( GoUnknown GoBaseType = iota GoBool GoInt64 GoFloat64 GoString GoEmpty GoSlice GoArray GoMap GoStruct ) func (g GoBaseType) ReferenceType() bool { return g == GoSlice || g == GoMap } func (g GoBaseType) ScalarType() bool { return g >= GoBool && g < GoEmpty }
package promise import ( "bytes" "encoding/json" "errors" "testing" "time" ) func TestPromiseExecutorExecResolve(t *testing.T) { e := StartExecutor(4, 100) defer e.Stop() expectedValue := "hello world" p := e.Exec(func() (interface{}, error) { return expectedValue, nil }) v, err := p.Result() if err ...
package storage import "fmt" type NotFoundError struct { Key string } func (nf *NotFoundError) Error() string { return fmt.Sprintf("%v does not exist", nf.Key) }
package main import "fmt" func main() { var n byte fmt.Printf("Бүхэл тоо оруулна уу? ") fmt.Scanf("%d", &n) fmt.Printf("Дээд 4 бит = %d\n", (n&0xF0)>>4) fmt.Printf("Доод 4 бит = %d\n", (n & 0x0F)) }
package inc import ( "encoding/json" "testing" ) func Test_NewConfig_1(t *testing.T) { config, err := NewConfig("../conf/config.json") if err != nil { t.Error(err) return } json, err := json.Marshal(config) if err != nil { t.Error(err) return } t.Log(string(json)) }
// Copyright 2020 astaxie // // 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,...
package main import ( "os" "bufio" "fmt" "strconv" "strings" "github.com/Amertz08/EECS560-go/Lab01/LinkedList" "io" "path/filepath" ) func main() { if len(os.Args) == 1 { fmt.Println("Please provide an input file") os.Exit(1) } fileName := os.Args[1] fullPath, err := filepath.Abs(fileName) check(er...
package lccu_strings import ( "fmt" "github.com/satori/go.uuid" "strings" ) func RandomUUIDString() string { return fmt.Sprintf("%s", uuid.NewV4()) } func RandomUUIDStringNoLine() string { return strings.ReplaceAll(fmt.Sprintf("%s", uuid.NewV4()), "-", "") }
package main import ( "fmt" "math" ) type Vertex struct { X, Y float64 } // Remember: a method is just a function with a receiver argument. func (v Vertex) Abs() float64 { return math.Sqrt(v.X*v.X + v.Y*v.Y) } func main() { j := Vertex{3, 4} fmt.Println(j.Abs()) }
/* * Copyright 2019 Dgraph Labs, Inc. and Contributors * * 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 appli...
package cmd import ( "fmt" "net/http" "net/http/httputil" "net/url" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) func newServerCmd(cfg *Config) *cobra.Command { return &cobra.Command{ Use: "serve", Short: "", Long: ``, RunE:...
package server import ( "context" "net/http" "github.com/danielkvist/botio/proto" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/pkg/errors" "google.golang.org/grpc" ) func (s *server) jsonGateway() error { ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() mu...
package haymakerengines import ( "errors" "fmt" "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ecr" ) var ecrInstance *ecr.ECR var repoName string var imageTAG string func createRepositoryStub(repositoryName *string) (*ecr.CreateRepositoryOu...
package day10 import ( "sort" "strconv" "../utils" ) var input, _ = utils.ReadFile("day10/input.txt") // ParseLines parses the file input func ParseLines(input []string) []int { var data []int for _, line := range input { v, _ := strconv.Atoi(line) data = append(data, v) } sort.Ints(data) return data } ...
package main import ( "fmt" "strconv" ) //条件分岐 //エラーハンドリング func main() { var s string = "A" //var s string = "1000" //i, _ := strconv.Atoi(s) //fmt.Printf("i = %T\n", i) i, err := strconv.Atoi(s) if err != nil { fmt.Println(err) } fmt.Printf("i = %T\n", i) }
package model import "gorm.io/gorm" type User struct { gorm.Model Username string `json:"username" validate:"required,min=1,max=30"` Email string `json:"email" validate:"required,email,unique"` Password string `json:"password" validate:"required"` Role string `json:"role" gorm:"default=USER" validate:"on...
package reading import ( "time" "github.com/kapmahc/axe/plugins/nut" ) // Book book type Book struct { tableName struct{} `sql:"reading_books"` ID uint Author string Publisher string Title string Type string Lang string File string Subject string Descripti...
package backend_controller import ( "2021/yunsongcailu/yunsong_server/common" "github.com/gin-gonic/gin" "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/disk" "github.com/shirou/gopsutil/v3/host" "github.com/shirou/gopsutil/v3/mem" "net" "os" "path/filepath" "time" ) type ServerInfo struc...
func addBinary(a string, b string) string { a_len := len(a) b_len := len(b) max_len := a_len if a_len > b_len { for i := 0; i < a_len-b_len; i++ { b = "0" + b } } else if b_len > a_len { max_len = b_len for i := 0; i < b_len-a_len; i++ { a = "0" + a } } carry := 0 result := "" a_int := 0 b_i...
package manager import ( "encoding/json" "github.com/gin-gonic/gin" "github.com/golang/glog" "io/ioutil" "net/http" "regexp" "strings" "sub_account_service/order_server_zhengdao/client" "sub_account_service/order_server_zhengdao/db" "sub_account_service/order_server_zhengdao/lib" "sub_account_service/order_...
package beatmanage import ( "github.com/beatwatcher/conf" "bufio" "bytes" "encoding/json" "fmt" "github.com/bitly/go-simplejson" "github.com/ghodss/yaml" "io/ioutil" "log" "net" "os" "os/exec" "strconv" "strings" "time" ) // Name of this beat type collectionStatus struct { Agentuuid string `json:"a...
package main import ( "io" "log" "net" "fmt" "os" ) func connectTwoConn(conn1 net.Conn,conn2 net.Conn){ if conn1==nil || conn2==nil{return } go func() { io.Copy(conn1,conn2) }() go func() { io.Copy(conn2,conn1) }() } func server(portStr string) net.Listener{ listener, err := net.Listen("tcp",fmt.Sprin...
//////////////////////////////////////////////////////////////////////////////// // // // Copyright 2019 Dell, Inc. // // ...
package integration_test import ( "github.com/cloudfoundry/libbuildpack/cutlass" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("deploy a staticfile app", func() { var app *cutlass.App var app_name string AfterEach(func() { if app != nil { app.Destroy() } app = nil app_name...
package main import ( "log" "net/http" "github.com/doniacld/outdoorsight/internal/routers" ) const ( asciiOutdoorsight = " ____ __ __ _____ __ __ \n / __ \\__ __/ /____/ /__ ___ ____/ __(_)__ _/ / / /_\n/ /_/ / // / __/ _ / _ \\/ _ \\/ __/\\ \\/ / _ `/ _ \\/ __/\n\\____/\\_,_/\...
package tumblr // Post is tumblr post struct type Post struct { BlogName string `json:"blog_name"` ID int64 `json:"id"` PostURL string `json:"post_url"` Slug string `json:"slug"` Type string `json:"type"` Timestamp int64 `json:"timestamp"` Date string `json:"date"` Form...
package polymorphism func process(iduck Iduck) { iduck.Quack() }
package main import ( "context" kafka "github.com/segmentio/kafka-go" ) /* topic and broker addresses assuming the below brokers are already configured and the topic is created if you need more info on how to run these check this blog https://www.sohamkamani.com/blog/2017/11/22/how-to-install-and-run-kafka/ */ cons...
/* * Minio Cloud Storage, (C) 2016 Minio, 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 la...
package models import ( "github.com/astaxie/beego/logs" "math" "strconv" "strings" ) //TemplateGet func func TemplateGet(page, limit, templates string) ([]Template, int64, error) { par := []string{"host", "name", "templateid"} hostspar := []string{"host", "name", "hostid"} rep, err := API.Call("template.get", ...
package datatype import ( "database/sql" "database/sql/driver" "errors" "server/libs/log" ) var ( objects = make(map[string]func() Entity) ErrRowError = errors.New("row index out of range") ErrColError = errors.New("col index out of range") ErrTypeMismatch ...
package pg import ( "github.com/kyleconroy/sqlc/internal/sql/ast" ) type TableFunc struct { NsUris *ast.List NsNames *ast.List Docexpr ast.Node Rowexpr ast.Node Colnames *ast.List Coltypes *ast.List Coltypmods *ast.List Colcollations *ast.List Colexprs *ast.List C...
// Copyright © 2020 Attestant Limited. // 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 ...
package activity import ( "errors" "fmt" "testing" "github.com/aws/aws-sdk-go/service/swf" . "github.com/sclasen/swfsm/sugar" ) func TestInterceptors(t *testing.T) { calledFail := false calledBefore := false calledComplete := false calledCanceled := false task := &swf.PollForActivityTaskOutput{ Activity...
package controllers import "server/src/services/interfaces" type ExerciseController struct { exerciseService interfaces.ExerciseServiceProvider } func NewExerciseController(exerciseService interfaces.ExerciseServiceProvider) *ExerciseController{ return &ExerciseController{exerciseService: exerciseService} }
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //420. Strong Password Checker //A password is considered strong if below conditions are all met: //It has at least 6 characters and at most 20 charact...
package bitmap import "testing" func TestBitma(t *testing.T) { bitmap := NewBitmap(19) t.Logf("%+v", bitmap) bitmap.SetBit(13, 1) t.Logf("%b", bitmap.data) t.Log(bitmap.GetBit(1)) }
package gin import ( "context" "github.com/game-explorer/animal-chess-server/internal/pkg/log" "github.com/gin-gonic/gin" "net/http" "time" ) type Engine struct { *gin.Engine httpServer *http.Server } func NewGin(debug bool) *Engine { if debug { gin.SetMode(gin.ReleaseMode) } else { gin.SetMode(gin.Debu...
package main import "fmt" type Stack []int func (s *Stack) pop() int { if len(*s) == 0 { return -1 } tmp := *s result := tmp[len(*s)-1] *s = tmp[:len(*s)-1] return result } func (s *Stack) push(data int) { *s = append(*s, data) } func main() { stack := Stack{} stack.push(1) stack.push(2) stack.push(3)...
package processor import ( "github.com/bitmaelum/bitmaelum-suite/internal/account" "github.com/bitmaelum/bitmaelum-suite/internal/api" "github.com/bitmaelum/bitmaelum-suite/internal/config" "github.com/bitmaelum/bitmaelum-suite/internal/container" "github.com/bitmaelum/bitmaelum-suite/internal/message" "github.c...
package eea import ( "math/rand" "reflect" "github.com/renproject/shamir/poly" ) // Generate implements the quick.Generator interface. func (eea Stepper) Generate(rand *rand.Rand, size int) reflect.Value { size = size / 8 rPrev := poly.Poly{}.Generate(rand, size).Interface().(poly.Poly) rNext := poly.Poly{}.Ge...
package main import ( "fmt" "strconv" ) func main() { //fmt.Println(translateNum(12258)) fmt.Println(translateNum(322)) fmt.Println(translateNum(444)) //fmt.Println(translateNum(25)) } func translateNum(num int) int { nums := strconv.Itoa(num) dp := make([]int, len(nums)+1) dp[0] = 1 dp[1] = 1 for i :=...
package main import ( "fmt" ) func main() { for number := 1; number <= 20; number++ { if number%2 == 0 { fmt.Printf("%d %s\n", number, "is even.") } else { fmt.Printf("%d %s\n", number, "is odd.") } } }
package api import ( "fmt" "io" "log" workerpool "pn/pool" "pn/reader" "sync" "time" ) const ( goRoutines = 1000 ) func Search(id, filepath string) string { start := time.Now() jobs := make(chan []string, 1000) results := make(chan string, 4000) var wg sync.WaitGroup pool := workerpool.New(id, goRouti...
package main import ( "database/sql" "fmt" _ "github.com/lib/pq" ) const ( host = "localhost" port = 5432 user = "postgres" password = "postgres" dbname = "postgres" ) func main() { psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+ "password=%s dbname=%s sslmode=disable", host, port, us...
package aoc2015 import ( "fmt" "strconv" "strings" aoc "github.com/janreggie/aoc/internal" "github.com/pkg/errors" ) // racingReindeer is a reindeer that participates in the Reindeer Olympics type racingReindeer struct { name string flyingSpeed uint flyingTime uint restingTime uint } // reindeerOly...
// Copyright 2015 The Chromium 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 internal import ( "fmt" "time" "golang.org/x/net/context" "golang.org/x/oauth2" ) type userAuthTokenProvider struct { oauthTokenProvider ...
package main import "fmt" func main() { var name = "Gello" runes := []rune(name) runes[0] = 'H' //name = string(runes) fmt.Println(string(runes), name) }
package main import ( "bytes" "context" "encoding/json" "errors" "fmt" "io" "io/ioutil" "log" "net/http" "os" "os/exec" "path/filepath" "strings" "time" "github.com/satori/go.uuid" "golang.org/x/net/websocket" ) // domain is default jupyter kernel gateway listening address // TODO: port should not be...
package config import ( "github.com/caarlos0/env/v6" ) type Config struct { Env string `env:"TODO_ENV" envDefault:"dev"` Port int `env:"PORT" envDefault:"80"` DBHost string `env:"TODO_DB_HOST" envDefault:"127.0.0.1"` DBPort int `env:"TODO_DB_PORT" envDefault:"3306"` DBUser string ...
package backoff import ( "math" "time" ) // Backoff keeps track of connection retry attempts and calculates the delay between each one. type Backoff struct { attempt, MaxAttempts float64 // Increment factor for each time step. Factor float64 // Min and max intervals allowed for backoff intervals. MinInterval...
package main import ( "errors" "io/ioutil" "log" "os" "regexp" ) var ( hasPkgPat = regexp.MustCompile("(?m)^ii") ) func main() { f, err := os.Open("./dpkg.txt") if err != nil { log.Fatal(err) } defer f.Close() out, err := ioutil.ReadAll(f) if err != nil { log.Fatal(err) } if !hasPkgPat.Match(out) {...
/* * Copyright 2017 the original author or 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 applica...
package models import "encoding/json" type PaymentCodec struct{} func (c *PaymentCodec) Encode(value interface{}) ([]byte, error) { return json.Marshal(value) } func (c *PaymentCodec) Decode(data []byte) (interface{}, error) { var p Payment return &p, json.Unmarshal(data, &p) } type PaymentListCodec struct{} ...
package web_controller import ( "2021/yunsongcailu/yunsong_server/common" "2021/yunsongcailu/yunsong_server/param/web_param" "2021/yunsongcailu/yunsong_server/tools" "2021/yunsongcailu/yunsong_server/web/web_model" "2021/yunsongcailu/yunsong_server/web/web_service" "errors" "fmt" "github.com/gin-gonic/gin" "s...
package tournament import ( "bufio" "fmt" "io" "sort" "strings" ) const header string = "Team | MP | W | D | L | P" type team struct { name string wins int losses int draws int } func (t *team) points() int { return (t.wins * 3) + t.draws } func (t *team) matchesPlayed(...
package ds import ( "database/sql" "time" ) type File struct { Id int `json:"-"` Bin string `json:"-"` Filename string `json:"filename"` InStorage bool `json:"-"` Mime string `json:"content-type"` Category s...
package handler import ( "HumoAcademy/models" "fmt" "github.com/gin-gonic/gin" "log" "net/http" "net/smtp" "strconv" ) const ( UsersCVDirectory = `images/users_cv/%s_%s` ) //func getNewUsersCV(c *gin.Context) (string, error) { // cv, err := c.FormFile("cv") // if err != nil { // log.Println("Error while rec...
package v1 import "github.com/julienschmidt/httprouter" var( getDataByCategory GetDataByCategoryRouter ) type Router struct { } func (r Router)RegisterRouter(mux *httprouter.Router){ getDataByCategory.RegisterHandler(mux) }
// Copyright 2017 Jeff Foley. All rights reserved. // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. package sources import ( "fmt" "github.com/OWASP/Amass/amass/core" "github.com/OWASP/Amass/amass/utils" ) // Censys is data source object type that implements the D...
package hydrator import ( "context" "net/http" "net/url" httpclient "github.com/asecurityteam/component-httpclient" ) // NexposeConfig holds configuration to connect to Nexpose // and make a call to the fetch assets API type NexposeConfig struct { HTTPClient *httpclient.Config `description:"The HTTP client conf...
package main import ( "errors" "image" "image/draw" "image/png" "os" "github.com/go-gl/gl/v4.1-core/gl" ) func textureFromData(img image.Image, id uint32) (uint32, error) { rgba := image.NewRGBA(img.Bounds()) draw.Draw(rgba, rgba.Bounds(), img, image.Pt(0, 0), draw.Src) if rgba.Stride != rgba.Rect.Size().X*...
package domain import ( "context" "github.com/go-kit/log" "github.com/google/uuid" ) // ServiceInterface defines the domains Service interface type ServiceInterface interface { Course(ctx context.Context, id uuid.UUID) (Course, error) Courses(ctx context.Context) ([]Course, error) CreateCourse(ctx context.Cont...
/* Description A 3x3 magic square is a 3x3 grid of the numbers 1-9 such that each row, column, and major diagonal adds up to 15. Here's an example: 8 1 6 3 5 7 4 9 2 The major diagonals in this example are 8 + 5 + 2 and 6 + 5 + 4. (Magic squares have appeared here on r/dailyprogrammer before, in #65 [Difficult] in ...
package command import "errors" // ErrNotJSONFile represents not JSON file error var ErrNotJSONFile = errors.New("Not JSON file") // GsonNvim is GsonNvim base struct type GsonNvim struct{}
package strategy import ( "sync" ) /*** *双向链表 */ type Node struct { data interface{} prev *Node next *Node } type ListObj struct { head *Node tail *Node length uint mutex *sync.RWMutex } func ListInstance() *ListObj { return &ListObj{mutex: new(sync.RWMutex)} } //尾部压入数据 func (this *ListObj) Append(...
package model import ( "github.com/smartystreets/assertions" "testing" ) func TestUtils(t *testing.T) { fromString, err := GetSexTypeFromString("man") assertions.ShouldEqual(fromString, Male) assertions.ShouldBeNil(err) male, err2 := GetSexTypeFromString("female") assertions.ShouldEqual(male, FEMALE) assertio...
package main /** *本题题意:给出一个int,反轉整形數 */ func reverse(x int) int { var( y int re int = 0 maxint int = 2147483647 ) if x < 0{ y = -x } else { y = x } for y > 0{ if re != 0 && maxint / re < 10{ return 0 } re *= 10 re += y%10 y /= 10 } if x < 0{ return...
package storage const ( queryFmtRenameTable = ` ALTER TABLE %s RENAME TO %s;` queryFmtMySQLRenameTable = ` ALTER TABLE %s RENAME %s;` queryFmtPostgreSQLLockTable = `LOCK TABLE %s IN %s MODE;` queryFmtSelectRowCount = ` SELECT COUNT(id) FROM %s;` )
package main type Dimension struct { x int64 y int64 }
package models import ( "github.com/astaxie/beego/orm" _ "github.com/go-sql-driver/mysql" "time" ) type User struct { Id int UserName string `orm:"unique"` Pwd string Articles []*Article `orm:"reverse(many)"`//设置多对多反向关系(可互换) } //rel(fk) reverse(many) rel(m2m) reverse(many) rel reverse type Artic...
package mykafka import ( "context" "fmt" "github.com/Shopify/sarama" "github.com/spaolacci/murmur3" "log" "os" "os/signal" "strings" "sync" "syscall" "testing" "time" ) func TestComsumerGroup(t *testing.T) { assignor := "sticky" brokers := "192.168.182.132:9092" group := "group1" topics := "sun" olde...
/* Matryoshka dolls are traditionally wooden dolls that can be nested by fitting smaller dolls into larger ones. Suppose arrays can be nested similarly, placing smaller arrays into larger ones, in the following sense: Array A can be nested inside Array B if: min(array A) > min(array B) max(array A) < max(arr...
/* Copyright © 2020 The PES Open Source Team pesos@pes.edu 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 agree...