text
stringlengths
11
4.05M
package main import ( "fmt" "testing" ) func TestNumTree(t *testing.T) { num := numTrees(3) fmt.Println(num) if num != 5 { t.Errorf("results error") } num = numTrees(5) fmt.Println(num) if num != 42 { t.Errorf("results error") } }
package wallpager import ( "wallpager/db" "fmt" ) func Select(start string, mType string) ([]*WallPager, error) { res := make([]*WallPager, 0) sql := `SELECT wp,tag FROM wallpager ORDER BY %s LIMIT %s,30 ` if mType == "rank" { sql = fmt.Sprintf(sql, "rank", start) } else { sql = fmt.Sprintf(sql, "uid", star...
package 深度优先搜索 func makesquare(nums []int) bool { isUsed = 0 isVisit = make(map[int]bool) sum := 0 for i := 0; i < len(nums); i++ { sum += nums[i] } if sum%4 != 0 || sum == 0 { return false } length := sum / 4 return makeSequareExec(nums, length, 0, 0) } var isUsed int // 利用位运算来实现map,isUsed的二进制每一位表示的是使用情...
package utils import ( "github.com/babyboy/babyboy/frontsection" "github.com/babyboy/babyboy/log" "github.com/babyboy/babyboy/node" "github.com/babyboy/babyboy/urfave/cli" "os" "path/filepath" ) var ( CommandHelpTemplate = `{{.cmd.Name}}{{if .cmd.Subcommands}} command{{end}}{{if .cmd.Flags}} [command options]{...
package service import "TruckMonitor-Backend/model" type AuthenticationService interface { Authenticate(email string, password string) (*model.Employee, error) CreateToken(email string, password string) (string, error) ResolveToken(sessionToken string) (*model.Employee, error) } type authenticationService struct ...
package stripchar import ( "bytes" "fmt" "strings" "unicode/utf16" "unicode/utf8" "golang.org/x/text/transform" "golang.org/x/text/unicode/norm" ) func DecodeUTF16(b []byte) (string, error) { if len(b)%2 != 0 { return "", fmt.Errorf("Must have even length byte slice") } u16s := make([]uint16, 1) ret :=...
package Structs type EBR struct { Status byte Fit byte Start int64 Size int64 Name [16]byte Next int64 } type Partition struct { Status byte Type byte Fit byte Start int64 Size int64 Name [16]byte Ebr EBR } type ParticionMontada struct { Identificador string Path, Name string...
// 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
package dns import ( "github.com/Sirupsen/logrus" "os" "strconv" "strings" ) var ( RootDomainName string TTL int ) type DnsRecord struct { Fqdn string Records []string Type string TTL int } type ServiceDnsRecord struct { Fqdn string ServiceName string StackName string } f...
package arrays import ( "testing" ) var rotateTests = []struct { a [][]int result [][]int }{ { [][]int{ {1}, }, [][]int{ {1}, }, }, { [][]int{ {1, 2}, {3, 4}, }, [][]int{ {2, 4}, {1, 3}, }, }, } func compareMatrix(a [][]int, b [][]int) bool { n := len(a) for i := 0;...
package api import ( "fmt" "net/http" "strconv" "github.com/MarcelCode/ROWA/src/db" "github.com/labstack/echo" ) func GetHarvestablePlantsHandler(c echo.Context) (err error) { plantsToHarvest, err := db.FunctionStore.GetPlantsPerType("harvestable") if err != nil { return c.JSON(http.StatusNotFound, "Harves...
package main import "fmt" func main() { s0 := []int{0, -1, 54, 33} s1 := append(s0, 41, 53, 74) f0 := func(i int) int { return i + i } f1 := func(i int) int { return i * i } all_slices := [][]int{s0, s1} all_functions := []func(int) int{f0, f1} for _, sl := range all_slices { for fi, f := range all...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //230. Kth Smallest Element in a BST //Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. //Note: //You m...
package compress import ( "bytes" "github.com/stretchr/testify/assert" "io/ioutil" "testing" ) var src = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sagittis sapien non risus sollicitudin malesuada." var dst = []byte{0x78, 0xda, 0x14, 0xc6, 0xd1, 0x89, 0x3, 0x31, 0xc, 0x4, 0xd0, 0x56, 0xa6,...
/* Copyright © 2020 elonzh 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, publish, distribute, sublicense...
package interfaces import ( "bytes" "io" "testing" ) func TestCopy(t *testing.T) { type args struct { in io.ReadSeeker } tests := []struct { name string args args wantOut string wantErr bool }{ { name: "base-case", args: args{bytes.NewReader([]byte("example"))}, wantOut: "examp...
package login import "net/http" const loginPage = `<html> <head> <title>Login</title> </head> <body></body> </html>` func NewLoginHandler() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(loginPage)) } }
package librarypanels import ( "context" "time" "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/services/sqlstore" ) // createLibraryPanel function adds a Library Panel func (lps *LibraryPanelService) createLibraryPanel(c *models.ReqContext, cmd addLibraryPanelCommand) (LibraryPanel, err...
package slashing import ( sdk "github.com/irisnet/irishub/types" ) // TODO Any invariants to check here? // AllInvariants tests all slashing invariants func AllInvariants() sdk.Invariant { return func(ctx sdk.Context) error { return nil } }
package loger_test import ( "fmt" "github.com/ztxmao/vii/library" "testing" ) var ( logFile = "./" l = library.Logger p = fmt.Println ) func init() { l.Init(logFile, "TEST", 0) } func TestLogger(t *testing.T) { l.Access("test", "just loger access test") l.Debug("test", "just loger debug test") ...
package editor import ( "fmt" "io/ioutil" "os" "os/exec" ) // Basic is an editor without special abilities. We can't detect whether the // user saved the file or not. type Basic struct { name string path string } // NewBasic builds a new basic editor. func NewBasic(name string) (*Basic, error) { path, err := ...
package tpi_data import ( "google.golang.org/appengine" "reflect" "time" ) type Venue struct { Id int64 `json:"id" schema:"-"` Name string `json:"name" schema:"name"` Submitted time.Time `json:"submitted"` //Latitude float64 `json:"latitude" schema:"latitude"` //Longitude float64 `json:"lo...
package jarviscore import ( "context" "github.com/zhs007/jarviscore/base" pb "github.com/zhs007/jarviscore/proto" "go.uber.org/zap" ) // Ctrl - type Ctrl interface { Run(ctx context.Context, jarvisnode JarvisNode, srcAddr string, msgid int64, ci *pb.CtrlInfo) []*pb.JarvisMsg } // BuildReply2ForCtrl - build Rep...
package vrf import ( "math/big" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/pkg/errors" "github.com/smartcontractkit/chainlink/core/services/signatures/secp256k1" "github.com/smartcontractkit/chainlink/core/services/vrf" ) // Key defines VRF private key type Ke...
package migrations import ( "database/sql" "os" "path" _ "github.com/mutecomm/go-sqlcipher" ) type Minor004 struct{} func (Minor004) Up(repoPath string, pinCode string, testnet bool) error { var dbPath string if testnet { dbPath = path.Join(repoPath, "datastore", "testnet.db") } else { dbPath = path.Join...
package integrationtest import ( "testing" "github.com/PuerkitoBio/goquery" "github.com/seiichi3141/gompleapp/app/helper" ) func assertSelect(t *testing.T, doc *goquery.Document, query string) { var found = false doc.Find(query).Each(func(i int, s *goquery.Selection) { found = true }) if found != true { t...
package main import "fmt" func notaParaConceito(n float64) string { var nota = int(n) switch nota { case 10: return "10" case 9, 8: return "A" case 7, 6: return "B" default: return "Nota Invalida" } } func main() { fmt.Println(notaParaConceito(9.8)) fmt.Println(notaParaConceito(-1)) }
package classifier import ( "bytes" "io/ioutil" "mime/multipart" "net/http" "net/url" "path" ) type Vision struct { url *url.URL apiKey string client *http.Client } func NewVision(uri, apiKey string) (*Vision, error) { client := &http.Client{} v := Vision{apiKey: apiKey, client: client} u, err := url...
package main import ( "encoding/json" "flag" "fmt" "log" "os" "strconv" "sync" "time" //导入mqtt包 MQTT "github.com/eclipse/paho.mqtt.golang" ) var pingMap sync.Map var fcallback MQTT.MessageHandler = func(client MQTT.Client, msg MQTT.Message) { rtc := time.Now().UnixNano() / 1000000 m := make(map[string]interface{})...
package uaa import ( "bytes" "encoding/json" "errors" "fmt" "net/http" ) // GroupsEndpoint is the path to the groups resource. const GroupsEndpoint string = "/Groups" // paginatedGroupList is the response from the API for a single page of groups. type paginatedGroupList struct { Page Resources []Group `json:...
package dbinstance import ( "testing" "github.com/stretchr/testify/assert" ) // TestMysqlGenericInstanceUpdateNoError if upgrading mysql generic instance works as expected func TestMysqlGenericInstanceUpdateNoError(t *testing.T) { mysqlInstance := testGenericMysqlInstance() _, err := Update(mysqlInstance) asser...
// Package dfc provides distributed file-based cache with Amazon and Google Cloud backends. /* * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. * */ package dfc import ( "encoding/json" "flag" "fmt" "io/ioutil" "os" "strings" "time" "github.com/golang/glog" ) // checksums: xattr, http header...
package domain // DeprovisionRequest encapsulates the request payload for a // deprovision request. type DeprovisionRequest struct { // InstanceID is the ID value for the service instance to // be deprovisioned. InstanceID string // ServiceID is the ID value of the service provided in // the service catalog. Thi...
/* 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, so...
package templatecode const ( template = `package filetype import "github.com/kdada/tinygo" // target type target struct{ child } // Add() 添加 func (this *target)Add(){ } // Get() 查询单条记录 func (this *target)Get(){ } // All() 查询多条记录 func (this *target)All(){ } // Update() 更新 func (this *target)Update(){ } // ...
package main import ( "fmt" "math" ) type Point struct { x int y int } func sum(x, y int) int { return x + y } func swap(x, y int) (int, int) { return y, x } func main() { summe := sum(2, 3) fmt.Printf("Sum: %v\n", summe) var x, y int x = 4 y = 8 x, y = swap(x, y) fmt.Printf("X: %v, Y: %v\n", x, y) ...
// Copyright 2019 Google Inc. 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 applicable...
package terraform import ( "io" "os" "path/filepath" "sync" "time" "github.com/mattermost/mattermost-load-test/ltops" "github.com/mattermost/mattermost-load-test/sshtools" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) func (c *Cluster) loadtestInstance(addr string, resultsOutput io.Writer) error {...
package controllers import ( "github.com/astaxie/beego" "nepliteApi/comm" "nepliteApi/models" ) type CardsController struct { beego.Controller } func (cardsobj *CardsController)Get() { result := comm.Result{Ret: map[string]interface{}{"err": "aaa", "num": 0, "result": ""}} id := cardsobj.GetString("id") if l...
/* Copyright 2018-2020 The Nori 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, soft...
package main import ( "fmt" "net/http" "os" docker "github.com/docker/docker/client" "github.com/google/go-github/github" "github.com/ubclaunchpad/inertia/common" "github.com/ubclaunchpad/inertia/daemon/inertiad/project" ) var webhookSecret = "inertia" // gitHubWebHookHandler writes a response to a request i...
package model // Department 部门列表 type Department struct { ID int64 `json:"id"` // 部门id Name string `json:"name"` // 部门名称 ParentID int64 `json:"parentid"` // 父部门id,根部门为1 CreateDeptGroup bool `json:"createDeptGroup"` // 是否同步创建一个关联此部门的企业群,true表示是,false...
/* HNdb is intended to provide a stripped down interface customized to use specifically with Hacker News firbase. It has been adapted from https://github.com/easyCZ/grpc-web-hacker-news/blob/master/server/hackernews/api.go. */ package hnapi import ( "fmt" "log" "sync" "gopkg.in/zabawaba99/firego.v1" ) const base...
package mqtt import ( "errors" "io" "time" "mqtt-adapter/src/logger" "github.com/eclipse/paho.mqtt.golang" "github.com/sirupsen/logrus" "github.com/surgemq/surgemq/service" ) type TestMQTTClient struct { needErr bool } func (t *TestMQTTClient) IsConnected() bool { return true } func (t *TestMQTTClient) Con...
package model import ( "github.com/SergeyShpak/owngame/server/src/model/builder" "github.com/SergeyShpak/owngame/server/src/model/layers" ) type DataLayer struct { Rooms layers.RoomsDataLayer WebsocketConnection layers.WebsocketConnectionLayer } func NewDataLayer() (*DataLayer, error) { b, err := ...
package web import ( "bytes" "encoding/json" "html/template" "math" "net/http" "net/url" "path/filepath" "sort" "strconv" "strings" "time" "cloud.google.com/go/datastore" "github.com/99designs/basicauth-go" "github.com/Jleagle/steam-go/steam" "github.com/derekstavis/go-qs" "github.com/dustin/go-humani...
package handlers import ( "github.com/SergeyShpak/owngame/server/src/model" "github.com/SergeyShpak/owngame/server/src/types" ) func prepareConnection(dl *model.DataLayer, token string, roomName string, login string) error { connMeta := &types.ConnectionMeta{ RoomName: roomName, Login: login, } if err := ...
package exoscale import ( "fmt" "io" "os" "k8s.io/client-go/kubernetes" cloudprovider "k8s.io/cloud-provider" ) var ( version string commit string versionString = fmt.Sprintf("%s/%s", version, commit) ) const ( providerName = "exoscale" providerPrefix = "exoscale://" ) type cloudProvider struct { cl...
package owner type protected struct{} func (_ protected) SayHello() string { return "Hello, world!" } type Protected interface { SayHello() string } type protector struct { impl Protected } var Protector = &protector{impl: protected{}} func SayHelloThrice() { Protector.impl.SayHello() Protector.impl.SayHello...
package filestoresql import ( "bytes" "context" "fmt" "io" "path/filepath" "github.com/direktiv/direktiv/pkg/refactor/filestore" "github.com/google/uuid" "gorm.io/gorm" ) type FileQuery struct { file *filestore.File checksumFunc filestore.CalculateChecksumFunc db *gorm.DB } func (q *Fil...
package solutions import ( "fmt" "testing" ) func TestMaxProfit(t *testing.T) { t.Run("Test Hello", func(t *testing.T) { var tests = []struct { input []int want int }{ {[]int{7, 1, 5, 3, 6, 4}, 5}, {[]int{7, 6, 4, 3, 1}, 0}, {[]int{1, 2}, 1}, } for _, v := range tests { t.Run(fmt.Sprintf...
package dashboard import ( "strings" "sync" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/wasp/packages/coretypes" "github.com/iotaledger/wasp/packages/publisher" "github.com/labstack/echo/v4" "golang.org/x/net/websocket" ) // ChainID -> *sync.Map{} (map of connected clients) var wsClients = s...
package main import ( "database/sql" "fmt" "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql" "github.com/gorilla/mux" "html/template" "log" "net/http" "net/url" "strconv" "strings" "time" "unicode/utf8" ) var router = mux.NewRouter() var db *sql.DB var test string type ArticleFormData ...
package main import ( proxy "github.com/lzxm160/ethpoolmock/src" ) func main() { proxy.NewProxy() }
package factories import ( "github.com/barrydev/api-3h-shop/src/model" ) func FindAllCategoryTree() ([]*model.CategoryTree, error) { allCategory, err := FindCategory(nil) if err != nil { return nil, err } tree := MakeCategoryTree(allCategory) return tree, nil } func MakeCategoryTree(all []*model.Category)...
// Package cmdos defines basic command-line flags package cmdos import "flag" // Flags are the available fill-fields type Flags struct { Names *string Surnames *string Reviews *string BasePath *string RandomPath *string RandomQuant *string PerformCrunch *bool StartWebserver...
package gsv import ( cryptoRand "crypto/rand" "testing" ) var visName string var sorterMap map[string]Sorter func init() { test = true sorterMap = map[string]Sorter{ "bogo": BogoSort, "bubble": BubbleSort, "cocktail": CocktailSort, "comb": CombSort, "counting": CountingSort, "cycle": ...
package core import ( "context" "os" "os/signal" "syscall" "time" "github.com/google/uuid" kube_log "sigs.k8s.io/controller-runtime/pkg/log" kuma_log "github.com/kumahq/kuma/pkg/log" ) var ( // TODO remove dependency on kubernetes see: https://github.com/kumahq/kuma/issues/2798 Log = kub...
/** * @program: Go * * @description:iris入门一 * * @author: Mr.chen * * @create: 2020-03-05 09:34 **/ package services import ( "iris_demo/datamodels" "iris_demo/repositories" ) type IProductService interface { GetProductByID(int64) (*datamodels.Product,error) GetAllProduct() ([]*datamodels.Product,error) DeletePro...
package main import ( "fmt" ) type person struct { first string last string age int } func (p person) speak() { fmt.Printf("may name is %v %v and my age is %v", p.first, p.last, p.age) } func main() { p1 := person{ first: "tom", last: "greene", age: 33, } p1.speak() }
// Copyright (C) 2015 Scaleway. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE.md file. package commands import ( "fmt" "sort" "github.com/dustin/go-humanize" "github.com/scaleway/scaleway-cli/pkg/api" ) // ProductsArgs are flags for the `R...
package main import "fmt" func main() { fmt.Println("Welcome Gophers :)") }
package main import "time" var version = "v1.0.2" var uptime = time.Now()
package config const ( CookieMaxAge = 60 * 60 * 24 * 3 // 3天 CookieIdName = "bk_token" )
package Config import ( "github.com/gorilla/mux" controller "ExampleRESTApi/Controllers" "net/http" ) func InitializeRoutes(router *mux.Router) { //Configuring Controller's Routes router.HandleFunc("/people", controller.GetPeopleEndpoint).Methods("GET") router.HandleFunc("/people/{id}", controller.GetPersonEndp...
package fbmessenger_test import ( . "github.com/ekyoung/fbmessenger" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "encoding/json" "fmt" "io/ioutil" "strings" ) var _ = Describe("Callback Models", func() { Describe("Message Model", func() { It("should unmarshal a callback with a text message", fun...
package protobuf type Buf interface { //GetProtocolNum will return the protocol number. GetProtocolNum() int }
package warp import ( "crypto/sha256" "golang.org/x/crypto/pbkdf2" "golang.org/x/crypto/scrypt" ) type result struct { seed []byte err error } type seedGenerator func() ([]byte, error) func scryptSeed(passphrase, salt string) seedGenerator { return func() ([]byte, error) { return scrypt.Key([]byte(passphr...
package common_test import ( "encoding/json" "fmt" "github.com/APTrust/exchange/constants" "github.com/APTrust/exchange/network" "github.com/APTrust/exchange/partner_apps/common" "github.com/APTrust/exchange/util/fileutil" "github.com/aws/aws-sdk-go/service/s3" "github.com/aws/aws-sdk-go/service/s3/s3manager" ...
package leetcode /*Design a HashSet without using any built-in hash table libraries. To be specific, your design should include these functions: add(value): Insert a value into the HashSet. contains(value) : Return whether the value exists in the HashSet or not. remove(value): Remove a value in the HashSet. If the v...
package main import ( "fmt" "github.com/feng/future/design/adapter/adapter" ) func main() { //adapter.AdapterTest() // var b adapter.NonA // nty := adapter.AdapterNonToYes{b} // f(nty) b := adapter.Fowards{} b.Player("巴蒂尔") f2(&b) m := adapter.Guards{} m.Player("麦克格雷迪") f2(&m) ym := adapter.Translat...
package utils import ( "bufio" "os" "strings" ) func ArrayContains(array []string, check string) bool { for _, ele := range array { if ele == check { return true } } return false } func ArrayContainsNoCase(array []string, check string) bool { for _, ele := range array { if strings.ToLower(ele) == str...
package main import ( "fmt" "net" "strings" "time" ) // 定义结构体 type Client struct { // 传递信息的管道 C chan string // 名称 Name string // 地址 Addr string } // 定义全局map,用于存储已经连接的客户端信息 var onlineClient map[string]Client // 定义全局广播信息的管道 var message chan string // 向每个客户端广播信息 func BroadcastInfo() { for { msg := <-mess...
package main import ( "github.com/StatCan/namespace-controller/cmd" ) func main() { cmd.Execute() }
package main import ( "flag" "log" "net/http" "github.com/gorilla/websocket" "github.com/mastercactapus/yaspjs/server" ) var ( addr = flag.String("addr", ":8989", "HTTP listen address.") ) func main() { log.SetFlags(log.Lshortfile) flag.Parse() srv := server.NewServer() // TODO: origin var upgrader web...
package v1 import ( "errors" "io" "math/rand" "os" "path/filepath" "sync" "testing" ) // Data 代表数据的类型 type Data []byte // DataFile 代表数据文件的接口类型 type DataFile interface { Read() (rsn int64, d Data, err error) // Read 读取一个数据块 Write(d Data) (wsn int64, err error) // Write 写入一个数据块 RSN() int6...
package main import "fmt" var ( a int b float64 ) const ( i int = 10 s string = "nihao" ) func main() { a, b = 19, 3.14 fmt.Println("a = ", a) fmt.Println("b = ", b) fmt.Println("i =", i) fmt.Println("s =", s) }
package middlewares import ( "errors" "github.com/valyala/fasthttp" ) var ( headerXAutheliaURL = []byte("X-Authelia-URL") headerAccept = []byte(fasthttp.HeaderAccept) headerContentLength = []byte(fasthttp.HeaderContentLength) headerLocation = []byte(fasthttp.HeaderLocation) headerXForwardedProto...
package db import ( "context" "fmt" "github.com/go-chi/render" "github.com/go-redis/redis/v8" "net/http" ) type redisClientContextKeyType string const redisClientContextKey redisClientContextKeyType = "redis_client" func SessionCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.Response...
package main import ( "context" "encoding/json" "flag" "log" "net/http" "github.com/go-chi/chi" "github.com/pkg/errors" "github.com/pressly/saml" ) var ( flagInitiatedBy = flag.String("initiated-by", "", "Either idp or sp") flagListenAddr = flag.String("listen-addr", "127.0.0.1:1113", "Bind to address") ...
/* Create a program that will read in a quiz provided via a CSV file (more details below) and will then give the quiz to a user keeping track of how many questions they get right and how many they get incorrect. Regardless of whether the answer is correct or wrong the next question should be asked immediately a...
package leetcode /*Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates).  For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three times in the final an...
package sstable import ( "errors" ) var ( ErrTooManyRecords = errors.New("go-sstable: too many records") ErrTooMuchData = errors.New("go-sstable: too much data (max file size 4 GiB)") ErrKeyTooLong = errors.New("go-sstable: key too long (max key length 255 bytes)") ErrValueTooLong = errors.New("go-sstab...
package apis import ( "errors" "fmt" "project/app/admin/models" "strconv" "project/app/admin/models/bo" "project/app/admin/models/dto" "project/app/admin/service" "project/common/api" "project/utils" "project/utils/app" "github.com/gin-gonic/gin" "github.com/go-playground/validator/v10" "go.uber.org/zap...
package main import ( "flag" "os" "runtime/pprof" "github.com/golang/glog" "github.com/kho/easy" "github.com/kho/fslm" ) type CanWriteBinary interface { WriteBinary(string) error } func main() { var args struct { Out string `name:"out" usage:"output path"` } cpuprofile := flag.String("cpuprofile", "", "...
package facebook import ( "context" "net/http" "net/url" "strings" "time" "github.com/otamoe/oauth-client" ) type ( Client struct { oauth.OAuth2 } ) var Endpoint = oauth.Endpoint{ Name: "fackbook", AuthorizeURL: "https://www.facebook.com/dialog/oauth", AccessTokenURL: "https://graph.face...
package model import "github.com/Yangshuting/golang_model/config" var DBNAME_KuaiMaoUser = "" func InitModel() { DBNAME_KuaiMaoUser = config.RawEnv("KETH_DB") }
package creds import ( "bytes" "encoding/xml" "io/ioutil" "net/http" "testing" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil" "github.com/aws/aws-sdk-go/service/sts" ) var dummy...
package port import ( "fmt" "net" "os" ) // FreeAddr asks the kernel for a free open port that is ready to use. func FreeAddr() string { if v := os.Getenv("ADDR"); v != "" { return v } l, err := net.Listen("tcp", ":0") if err != nil { return ":10020" } _ = l.Close() return fmt.Sprintf(":%d", l.Addr()...
package nougat import "testing" func TestMethodSetters(t *testing.T) { cases := []struct { Nougat *Nougat expectedMethod string }{ {New().Path("http://a.io"), "GET"}, {New().Head("http://a.io"), "HEAD"}, {New().Get("http://a.io"), "GET"}, {New().Post("http://a.io"), "POST"}, {New().Put("http:/...
package main import ( "net/url" "fmt" "github.com/kavenegar/kavenegar-go" ) func main() { api := kavenegar.New(" your apikey here ") //Message.SendArray sender := []string{"",""} //Sender Line Numbers(optional) receptor := []string{"", ""} //Recipient numbers message := []string{"Hello Go!", "Hello Go!"} ...
package gorsa import ( "bytes" "crypto/rsa" "errors" "io/ioutil" ) var RSA = &RSASecurity{} type RSASecurity struct { pubStr string //公钥字符串 priStr string //私钥字符串 pubkey *rsa.PublicKey //公钥 prikey *rsa.PrivateKey //私钥 } // 设置公钥 func (rsas *RSASecurity) SetPublicKey(pubStr string) (err erro...
package dcp import ( "encoding/binary" "net" "github.com/zemirco/dcp/block" ) // EthernetII header. type EthernetII struct { Destination net.HardwareAddr Source net.HardwareAddr EtherType uint16 } // NewEthernetII returns pointer to ethernet II struct. func NewEthernetII(dst, src net.HardwareAddr) *Eth...
/** * Given a sorted linked list, delete all duplicates such that each element appear only once. * For example, * Given 1->1->2, return 1->2. * Given 1->1->2->3->3, return 1->2->3. * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func deleteDuplicates(he...
package server import ( "encoding/json" "fmt" "reflect" "strings" "github.com/yekhlakov/gojsonrpc/common" ) // Extract methods from the handler using the method name prefix func ExtractMethods(handler Handler, methodNamePrefix string) (r []JsonRpcMethod) { t := reflect.TypeOf(handler) for i := 0; i < t.NumMe...
package models type Dept struct { ID uint `gorm:"primary_key" json:"id" uri:"id"` Name string `json:"name"` Users []User `gorm:"foreignkey:DeptID" json:"users"` }
/* Description We all love recursion! Don't we? Consider a three-parameter recursive function w(a, b, c): if a <= 0 or b <= 0 or c <= 0, then w(a, b, c) returns: 1 if a > 20 or b > 20 or c > 20, then w(a, b, c) returns: w(20, 20, 20) if a < b and b < c, then w(a, b, c) returns: w(a, b, c-1) + w(a, b-1, c-1) - w(a...
// Copyright 2020 Frederik Zipp. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "image" "image/color" "math" "github.com/fzipp/canvas" ) type ball struct { pos vec2 radius float64 v vec2 color color....
// Uniq removes adjacent duplicates from []string package main import ( "fmt" "os" "github.com/vlad-belogrudov/gopl/pkg/uniq" ) func main() { fmt.Println(uniq.Uniq(os.Args[1:])) }
package main import ( "fmt" "html/template" "log" "net/http" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { temp, err := template.New("test").Parse(` <ul> {{range $name, $val := .}} <li>{{$name}} - {{$val}}</li> {{end}} </ul> `) if err != nil { fmt.Fprintf(w,...