text
stringlengths
11
4.05M
package main import _ "github.com/micro/go-plugins/transport/nats" import _ "github.com/micro/go-plugins/broker/nats" import _ "github.com/micro/go-plugins/registry/nats"
package solutions import ( "sort" ) func combinationSum(candidates []int, target int) [][]int { sort.Ints(candidates) result := make([][]int, 0) sumCandidates(candidates, target, []int{}, &result) return result } func sumCandidates(candidates []int, target int, current []int, result *[][]int) {...
/* Copyright 2018 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 law or agreed to in w...
package main import ( "flag" "fmt" "io/ioutil" "net/http" "os" "os/signal" "runtime" "runtime/pprof" "time" "github.com/gin-contrib/zap" "github.com/gin-gonic/gin" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/txn2/rxtx/rtq" "go.uber.org/zap" ) func main() { var port = flag.St...
package main func main() { a := make(map[int]int) for i := 0; i < 1000000; i++ { a[i] = i } for i := 0; i < 1000000; i++ { val := a[i] _ = val } }
package graph import ( "container/list" "errors" "fmt" ) //无向图 type Graph struct { GraphSize int adj []list.List found bool } func NewGraph(GraphSize int) *Graph { return &Graph{GraphSize: GraphSize, adj: make([]list.List, GraphSize), found: false} } func (this *Graph) AddEdage(s int, t int) (err e...
package Go // Time: O(n^2) // Space: O(n^2), can be reduced to O(1), by expanding around center approach func longestPalindrome(s string) string { if s == "" { return "" } mat := make([][]bool, len(s)) for i := 0; i < len(s); i++ { mat[i] = make([]bool, len(s)) mat[i][i] = true if i+1 < len(s) && s[i] == ...
// Copyright 2016 The Go 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 main const plotHTML = ` <!DOCTYPE html> <html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <...
package main import ( "bytes" "context" "crypto/rand" "encoding/base32" "encoding/json" "fmt" "io" "log" "os" "path" "path/filepath" "strings" "text/template" "time" exec "github.com/getsentry/sentry-sdk-benchmark/internal/std/execabs" ) var dockerComposeTemplate = template.Must(template.ParseFiles(fi...
package errorkit import ( "errors" "github.com/adamluzsi/frameless/internal/consttypes" ) func LookupUserError(err error) (UserError, bool) { var ue UserError return ue, errors.As(err, &ue) } type UserError struct { // ID is a constant string value that expresses the user's error scenario. // The caller who r...
package model import ( "context" "time" ) type ReferralCode struct { ID int64 `db:"id"` Msisdn string `db:"msisdn"` Code string `db:"code"` CreatedDate time.Time `db:"created_date"` Status int `db:"status"` } type ReferralCodeRepository interface { FindByMsisdn(ctx c...
package main import ( socks5 "github.com/getlantern/go-socks5" ) func Proxy() (server *socks5.Server) { creds := socks5.StaticCredentials{"Jorge": "82a07cc1b6cc1d05e594aeb3354da513438dc9695d3d15f6a70adf3697ba4fef"} auth := socks5.UserPassAuthenticator{Credentials: creds} conf := &socks5.Config{ AuthMethods: [...
package main import "fmt" func main() { s := make([]string, 3) fmt.Println("emp:", s) s[0] = "a" s[1] = "b" s[2] = "c" fmt.Println("set:", s) fmt.Println("get:", s[2]) fmt.Println("len:", len(s)) s = append(s, "d") s = append(s, "e", "f") fmt.Println("apd:", s) c := make([]string, len(s)) copy(c, s)...
package main import ( "bytes" "crypto/hmac" "crypto/sha512" "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "net/url" "strconv" "time" ) type ApiResponse map[string]interface{} type ApiParams map[string]string func api_query(method string, params ApiParams) (ApiRespo...
/* Copyright 2019 The Skaffold 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, sof...
package router import ( "github.com/gorilla/mux" middleware "server/system/middleware" ) // Router is exported and used in main.go func Router() *mux.Router { router := mux.NewRouter() router.HandleFunc("/ping", middleware.Ping).Methods("GET", "OPTIONS") router.HandleFunc("/read", middleware.ReadAll).Methods(...
package handler import ( "math/rand" "net/http" "time" "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" "github.com/talesmud/talesmud/pkg/entities/rooms" "github.com/talesmud/talesmud/pkg/repository" "github.com/talesmud/talesmud/pkg/service" ) //RoomsHandler ... type RoomsHandler struct { Servic...
package common import ( "fmt" "os" "path" "regexp" "strconv" "strings" ) // Regex to remove tabs and newlines. const ( replacementWhitespacePattern = `[\r\n\t]+` replacementWhitespace = " " ) var replaceWhitespaceRegex = regexp.MustCompile(replacementWhitespacePattern) //SyslogHeader gathers environ...
package identity import ( "context" "fmt" "github.com/databrickslabs/terraform-provider-databricks/common" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) // ResourceGroupMember bind group with member func ResourceGroupMember() *schema.Resource { return common.NewPairID("group_id", "member_id")....
package anilist var queryUserAnimeList = ` query UserList ($userID: Int, $scoreFormat: ScoreFormat) { MediaListCollection (userId: $userID, type: ANIME) { lists { entries { id status score(format: $scoreFormat) progress repeat updatedAt media { id idMal title { ro...
package handler import ( "log" "net/http" "strconv" "github.com/gamberooni/go-cats/model" "github.com/gamberooni/go-cats/store" "github.com/labstack/echo/v4" ) // cat handler is a wrapper around the catstore type CatHandler struct { catStore store.CatStore } // create cat handler instance to handle requests ...
package main import ( "bufio" "fmt" "log" "math/rand" "os" "strconv" "strings" "time" ) func main() { seconds := time.Now().Unix() rand.Seed(seconds) //numero aleatorio a adivinar target := rand.Intn(100) + 1 // fmt.Println(target) fmt.Println("he elegido un número entre 1 y 100") fmt.Println("Podes ...
'Set GOBIN path to be able to build bin files with Golang'
// // January 2016, cisco // // Copyright (c) 2016 by cisco Systems, Inc. // All rights reserved. // // // Handle TCP transports package main import ( "encoding/hex" "encoding/json" log "github.com/sirupsen/logrus" "io" "net" "sync" "time" ) const ( // // Time to wait before attempting to accept connection....
package candishared import "github.com/dgrijalva/jwt-go" // TokenClaim for token claim data type TokenClaim struct { jwt.StandardClaims Additional map[string]interface{} }
package main func test2() (int, int) { return 1, 2 } func add(x, y int) int { return x + y } func sum(n ...int) int { var x int for _, i := range n { x += i } return x } func add1(x, y int) (z int) { z = x + y return } func add2(x, y int) (z int) { defer func() { z += 100 }() z = x + y return } f...
package main import ( "context" "fmt" "io/ioutil" "log" "math" "math/rand" "os" "strconv" "strings" //"time" "./propu" "./uploader" "google.golang.org/grpc" ) //funcion que manda los libros al datanode distribuidor func subirLibro(conn *grpc.ClientConn, tipo string) { //buscamos libro, se selecciona y ...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package main import "github.com/spf13/cobra" type installationDNSAddFlags struct { clusterFlags installationID string dnsName string } func (flags *installationDNSAddFlags) addFlags(command *...
package slack import ( "github.com/balerter/balerter/internal/alert/message" "go.uber.org/zap" ) func (m *Slack) Send(message *message.Message) error { opts := createSlackMessageOptions(message.Text, message.Image, message.Fields...) _channel, _timestamp, _text, err := m.api.SendMessage(m.channel, opts...) m....
package main //351. 安卓系统手势解锁 // 中等 //我们都知道安卓有个手势解锁的界面,是一个3 x 3 的点所绘制出来的网格。 // //给你两个整数,分别为​​m 和 n,其中 1≤ m≤ n≤ 9,那么请你统计一下有多少种解锁手势,是至少需要经过m个点,但是最多经过不超过n 个点的。 //先来了解下什么是一个有效的安卓解锁手势: // //每一个解锁手势必须至少经过m 个点、最多经过n个点。 //解锁手势里不能设置经过重复的点。 //假如手势中有两个点是顺序经过的,那么这两个点的手势轨迹之间是绝对不能跨过任何未被经过的点。 //经过点的顺序不同则表示为不同的解锁手势。 // //解释: // //| 1 ...
package mapreduce import ( "fmt" "strconv" "time" "appengine" ds "appengine/datastore" queue "appengine/taskqueue" ) const ( dsWorkerKind = "MapreduceDsWorker" ) func NewDsWorkerQuery() *ds.Query { return ds.NewQuery(dsWorkerKind) } func NewDsWorkerKey(c appengine.Context, id int64) *ds.Key { return ds.Ne...
package kv import ( "time" "github.com/cerana/cerana/acomm" ) func (s *KVS) get(key string) string { v, err := s.KV.kv.Get(key) s.Require().NoError(err) return string(v.Data) } func (s *KVS) TestEKeyKnownBad() { tests := []struct { name string key string value string ttl time.Duration err str...
package amp //var map_resource chan *map[string]string = make(chan *map[string]string, 100) var callbox_resource chan *CallBox = make(chan *CallBox, 100) var askbox_resource chan *AskBox = make(chan *AskBox, 100) //func resourceMap() *map[string]string { //var m *map[string]string //select { //cas...
package main import ( "bufio" "fmt" "log" "os" "regexp" "strings" ) func seqTrans(p, q string) bool { p = "^" + strings.Replace(strings.Replace(p, "0", "A+", -1), "1", "((A+)|(B+))", -1) + "$" seqRegex := regexp.MustCompile(p) return seqRegex.MatchString(q) } func main() { data, err := os.Open(os.Args[1]) ...
package main // Leetcode 740. (medium) func deleteAndEarn(nums []int) int { maxVal := 0 for _, num := range nums { maxVal = max(maxVal, num) } arr := make([]int, maxVal+1) for _, num := range nums { arr[num]++ } pre, cur := 0, 0 for i, num := range arr { pre, cur = cur, max(pre+i*num, cur) } return c...
package main import "fmt" import "os" func main() { var SID, SKY string SID = os.Getenv("SID") fmt.Println(SID) SKY = os.Getenv("SKY") fmt.Println(SKY) }
package bootstrap import ( "context" "github.com/gin-gonic/gin" "github.com/go-redis/redis" "github.com/yangxinwei/gin-demo-api/config" "github.com/yangxinwei/gin-demo-api/controllers" "github.com/yangxinwei/gin-demo-api/utils" "log" "net/http" "os" "os/signal" "syscall" "time" ) type APP struct { Router...
package main import ( "github.com/gin-gonic/gin" "database/sql" "github.com/coopernurse/gorp" _ "github.com/mattn/go-sqlite3" "log" "time" "strconv" ) var dbmap = initDb() func main(){ defer dbmap.Db.Close() router := gin.Default() router.GET("/users", usersList) router....
package mapqueryparam_test import ( "net/url" "reflect" "testing" "time" "github.com/h-celel/mapqueryparam" ) func TestDecode(t *testing.T) { type EmbeddedStruct struct { A string } type EmbeddedStruct2 struct { EmbeddedStruct } type args struct { query map[string][]string v interface{} } te...
package liferay import ( "testing" internal "github.com/mdelapenya/lpn/internal" "github.com/stretchr/testify/assert" ) func init() { internal.CheckWorkspace() } func TestDeployFolderCE(t *testing.T) { ce := CE{} assert := assert.New(t) assert.Equal(ce.GetLiferayHome()+"/deploy", ce.GetDeployFolder()) } f...
package migrate // 注意: // 以前のマイグレーションとの互換性を保つために、 // 他のバージョンとは違いテーブル名にV1のようなバージョンをつけない import ( "database/sql" "fmt" "time" "github.com/go-gormigrate/gormigrate/v2" "github.com/google/uuid" "gorm.io/gorm" ) // v1 // アプリケーションのv1時のマイグレーション func v1() *gormigrate.Migration { tables := []any{ &gameTable{}, &g...
package main import ( "math/big" "strconv" "strings" ) type Integer string type Real string type Text string type Bool string type Error string type Variable interface { WhatIsMyType() string MyString() string toString() string } type Var struct { Value Variable } func toVar(value string) (Var, bool) { val...
package main import ( "database/sql" "encoding/json" "io/ioutil" "log" "net/http" "net/http/cookiejar" "net/url" "os" "strings" "time" _ "github.com/mattn/go-sqlite3" ) /* COOKIE JAR */ var jar, err = cookiejar.New(nil) var client = http.Client{ Jar: jar, } /* SKU DETAILS ...
package main import "fmt" func main() { // Println takes a variadic number of arguments // Returns the number in bytes and any errors with printing // To catch return values, assign the values to a variable num1, err := fmt.Println("Hello World", 42, true) fmt.Println(num1) fmt.Println(err) // Use underscores...
package middlewares import ( "github.com/dgrijalva/jwt-go" "github.com/gofiber/fiber/v2" ) func ParseJwt(cookie string) (string, error) { token, err := jwt.ParseWithClaims(cookie, &jwt.StandardClaims{}, func(t *jwt.Token) (interface{}, error) { return []byte("hi"), nil }) if err != nil || !token.Valid { re...
// Package steamid provides types and functions to represent and manipulate a SteamID. // // https://developer.valvesoftware.com/wiki/SteamID package steamid import ( "fmt" "regexp" "strconv" "github.com/13k/go-steam-resources/steamlang" ) var ( // STEAM_X:Y:Z steam2RE = regexp.MustCompile(`^STEAM_(?P<universe...
package pcsutil import ( "bytes" "sort" "strings" ) // TiebaClientSignature 根据给定贴吧客户端的 post (post数据指针) 进行签名, 以通过百度服务器验证。返回值为: sign 签名字符串 func TiebaClientSignature(post map[string]string) { if post == nil { return } // 预设 post["_client_type"] = "2" post["_client_version"] = "6.9.2.1" post["_phone_imei"] = "...
package http import ( "context" "fmt" "github.com/tahmooress/motor-shop/internal/port/dto/dtocustomers" "github.com/tahmooress/motor-shop/internal/entities/interfaces" "github.com/tahmooress/motor-shop/internal/pkg/server" ) func getCustomersHandler(_ context.Context, iUseCases interfaces.IUseCases) server.Midd...
package auth type Config struct { Realm string Key string TokenHeadName string TokenLookup string }
package postgres import ( "github.com/toundaherve/sad-api/user" ) type PostgresDB struct{} func NewPostgresDB() *PostgresDB { return &PostgresDB{} } func (p *PostgresDB) CreateUser(u *user.User) error { // if err != nil { // return errors.Wrap(err, "Something happened while creating the user") // } return nil...
package screen import "github.com/go-gl/gl/v4.5-compatibility/gl" type Program struct { handle uint32 shaders []*Shader } func (prog *Program) Delete() { for _, shader := range prog.shaders { shader.Delete() } gl.DeleteProgram(prog.handle) } func (prog *Program) Attach(shaders ...*Shader) { for _, shader :...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package crash import ( "context" "os" "time" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "chromiumos/tast/local/crash" "chromiumos/tast/te...
package _4_seatsInTheater func seatsInTheater(nCols int, nRows int, col int, row int) int { return (nCols-col+1)*(nRows-row) }
package ess import ( "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests" esssdk "github.com/aliyun/alibaba-cloud-sdk-go/services/ess" ) // Alarm struct to map to the tfvars template type Alarm struct { AlarmName string AlarmID string ScalingGroupID string Enable bool Alarm...
package BinarySearch //BinarySearch returns the smallest index of a number appearing in a sorted list func BinarySearch(object []int, target int) int { if len(object) == 0 { return -1 } left := 0 right := len(object) - 1 for left <= right { median := left + (right-left)/2 if target < object[median] { rig...
// Copyright 2018 The gVisor 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 agree...
package main import ( "fmt" ) /* Input: ["h","e","l","l","o"] Output: ["o","l","l","e","h"] */ func reverseString(s []byte) { // 첫 h를 끝으로, 끝의 o를 처음으로 reverseStringHelper(s, 0, len(s)-1) } func reverseStringHelper(s []byte, startIdx, targetIdx int) { // 현재 문자의 인덱스가 문자의 인덱스보다 크거나 같은 경우, 즉 역전하려는 경우 // 짝수/홀수를 나눌 필요...
package ravendb import ( "net/http" ) var ( _ RavenCommand = &SeedIdentityForCommand{} ) type SeedIdentityForCommand struct { RavenCommandBase id string value int64 forced bool Result int } func NewSeedIdentityForCommand(id string, value int64, forced bool) (*SeedIdentityForCommand, error) { if id ==...
/** Map 是一种无序的键值对的集合, Map最重要的一点是通过key来快速检索数据. key类似索引, 指向数据的值 Map 是一种集合 所以我们可以向迭代数组和切片那样迭代它. 不过 Map是无序的我们无法决定它返回的顺序 是因为Map是使用hash表来实现的 定义Map 可以通过內建函数make也可以使用map关键字来定义Map: // 申明变量 默认map是nil var map_variable map[key_data_type] value_data_type // 使用make函数 map_variable := make(map[key_data_type] value_data_type) 如果...
package transformer import ( "fmt" "github.com/sburnett/lexicographic-tuples" "github.com/sburnett/transformer/store" ) func makeRecord(values ...interface{}) *store.Record { return &store.Record{ Key: lex.EncodeOrDie(values...), } } func ExampleGrouper() { records := make(chan *store.Record, 10) records <...
package chapter1 import "strings" // URLify は、スペースを %20 に置き換える func URLify(target string) string { return strings.Replace(target, " ", "%20", -1) }
package alipay // BillDownloadURLQuery 查询对账单下载地址接口请求参数 https://docs.open.alipay.com/api_15/alipay.data.dataservice.bill.downloadurl.query type BillDownloadURLQuery struct { AppAuthToken string `json:"-"` // 可选 BillType string `json:"bill_type"` // 必选 账单类型,商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型:trade、signc...
package main import ( "log" "net/http" "os" "github.com/ivanovyordan/go-secrets-server/controller/secret" "github.com/ivanovyordan/go-secrets-server/tools/metrics" "github.com/gorilla/mux" ) func init() { metrics.Init() } func main() { router := mux.NewRouter() router.Use(metrics.Middleware) router.Hand...
package dynaml import ( "fmt" "math" "sort" "strconv" ) const endSymbol rune = 1114112 /* The rule types inferred from the grammar are below. */ type pegRule uint8 const ( ruleUnknown pegRule = iota ruleDynaml rulePrefer ruleMarkedExpression ruleSubsequentMarker ruleMarker ruleMarkerExpression ruleExpre...
package main import ( "context" "fmt" "os" "pp" ) // Вызываем процедуру заполнения DM по DDS за конкретный период func main() { ctx := context.Background() // Читаем аргументы коммандной строки // Если каталог задан в аргументах, читаем его args := os.Args if len(args) != 3 { ...
package main import ( "log" "golang.org/x/net/websocket" ) // Connection container type Connection struct { WS *websocket.Conn Send chan []byte Receive chan []byte } // NewConnection constructs Connection structures func NewConnection(wsConn *websocket.Conn) *Connection { connection := &Connection{ ...
package main import ( "context" "flag" corev1 "k8s.io/api/core/v1" "k8s.io/client-go/informers" kubeClient "k8s.io/client-go/kubernetes" cliFlag "k8s.io/component-base/cli/flag" "k8s.io/klog" mpaClientset "multidim-pod-autoscaler/pkg/client/clientset/versioned" "multidim-pod-autoscaler/pkg/target" "multidim-...
package main import "fmt" func main() { x := 3 y := 3 //simple if if x%2 == 0 { fmt.Println("x is even") } //if -else if x%2 == 0 { fmt.Println("x is even") } else { fmt.Println("x is odd") } //if else if else if x < y { fmt.Println("x is greater") } else if y < x { fmt.Println("x is odd") } el...
package transform import ( "bytes" "encoding/binary" snapshot "github.com/pganalyze/collector/output/pganalyze_collector" "github.com/pganalyze/collector/state" "github.com/pganalyze/collector/util" ) type statementKey struct { databaseOid state.Oid userOid state.Oid fingerprint uint64 } type statementV...
package recursion /* Given an array of non-consecutive numbers and a target value, find whether there exists a subset of those numbers that sums up to the target value*/ func SubsetSum(input []int, targetSum int) bool { return doSubSetSum(input, targetSum, 0, 0) } func doSubSetSum(input []int, targetSum int, index i...
package lexers import ( . "github.com/alecthomas/chroma/v2" // nolint ) // HTML lexer. var HTML = Register(MustNewLexer( &Config{ Name: "HTML", Aliases: []string{"html"}, Filenames: []string{"*.html", "*.htm", "*.xhtml", "*.xslt"}, MimeTypes: []string{"text/html", "application...
package main import ( "flag" "fmt" "log" "os" "path" "sort" "github.com/BurntSushi/xgb" "github.com/BurntSushi/xgb/randr" ) type commandInfo struct { f func(*config, heads) usage string } var ( command = "table" commands = map[string]commandInfo{ "set": {set, "set HEAD-NAME [ HEAD-NAME ... ...
package audit import ( "os" "github.com/jrapoport/gothic/models/auditlog" "github.com/jrapoport/gothic/models/types" "github.com/jrapoport/gothic/models/types/key" "github.com/jrapoport/gothic/models/user" "github.com/jrapoport/gothic/store" "github.com/jrapoport/gothic/utils" ) // LogStartup lof the service ...
package trading import ( "fmt" "log" "os" "path/filepath" "github.com/nzai/Tast/config" "github.com/nzai/Tast/stock" ) const ( dataFileName = "TradingSystem.txt" ) // 海龟交易系统参数 type TurtleTradingSystemParameter struct { Holding int N int Enter int Exit int Stop int } // 海龟交易系统 type TurtleT...
package main import ( "fmt" "sync" ) var waitgroup sync.WaitGroup func main() { waitgroup.Add(2) go foo() go bar() waitgroup.Wait() } func foo() { fmt.Println("hello") waitgroup.Done() } func bar() { fmt.Println("bye") waitgroup.Done() } //bye //hello
/* * Copyright (c) CERN 2016 * * 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 w...
package sg import ( "context" "fmt" "github.com/exoscale/egoscale" "github.com/janoszen/exoscale-account-wiper/plugin" "log" "sync" ) type Plugin struct { } func (p *Plugin) GetKey() string { return "sg" } func (p *Plugin) GetParameters() map[string]string { return make(map[string]string) } func (p *Plugin...
package main import ( _ "u3d_update/routers" "github.com/astaxie/beego" ) func main() { beego.SetStaticPath("/u3d_update", "./../") beego.BConfig.WebConfig.DirectoryIndex=true beego.Run() }
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package supervisor_test import ( "testing" "time" "github.com/mattermost/mattermost-cloud/internal/supervisor" "github.com/mattermost/mattermost-cloud/internal/testlib" "github.com/stretchr/testify...
package linksModel import ( "gopkg.in/mgo.v2/bson" ) type Links struct { ObjId bson.ObjectId `bson:"_id"` Id uint32 LinkName string //链接 Groupings bson.ObjectId //分组 }
package main import ( "github.com/thesephist/mira/pkg/mira" ) func main() { mira.Start() }
package main import ( "context" "github.com/bsromr/cloneTwitter/controller/auth" _ "github.com/bsromr/cloneTwitter/db" database "github.com/bsromr/cloneTwitter/db" "github.com/bsromr/cloneTwitter/db/types" "github.com/dgrijalva/jwt-go" "github.com/gofiber/fiber/v2" "log" "strconv" "time" ) func HomePage(c *...
/* Copyright 2022 The Tekton 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, software d...
package main import ( proto "github.com/caoyuewen/participle/npl-server/proto" "github.com/micro/go-micro" "context" "fmt" "runtime" "github.com/caoyuewen/participle/npl-server/thulac" ) type Server struct { } func (g *Server) GetParticiple(ctx context.Context, req *proto.SentenceRequest, rsp *proto.NplRespons...
package nebula /* import ( proto "google.golang.org/protobuf/proto" ) func HandleMetaProto(p []byte) { m := &NebulaMeta{} err := proto.Unmarshal(p, m) if err != nil { l.Debugf("problem unmarshaling meta message: %s", err) } //fmt.Println(m) } */
package base import "shared/utility/glog" type ConfigManager struct { AppListConfig *AppListConfig PatchListConfig *PatchListConfig } func (m *ConfigManager) Init() { m.AppListConfig = NewAppListConfig() m.PatchListConfig = NewPatchListConfig() } // set AppList interface func (m *ConfigManager) SetAppListConf...
package main import ( "fmt" "strconv" "strings" ) func parse(f string) map[string]*Map { lines := parseFileText1D(f) maps := map[string]*Map{} var m *Map t := "" x, y := 0, 0 lenY := -1 for _, l := range lines[1:] { if l == "" { continue } i := strings.Index(l, "Tile") if i != -1 { break } ...
package dbmigrate import ( "testing" "github.com/stretchr/testify/assert" ) func Test_defaultProvider_hasTableQuery(t *testing.T) { p := &defaultProvider{} assert.Contains(t, p.hasTableQuery(), "information_schema.tables") }
/* A tool to collect information of the system, similar to facter writen in ruby */ package main import ( "flag" "fmt" "github.com/fifthbeatles/gofacter/facter" "os" ) const ( VERSION = "0.1" ) // command-line flags var ( versionFlag = flag.Bool("v", false, "Print the version number.") ) func main() { flag.P...
package main import ( "regexp" "testing" ) func TestGlob(t *testing.T) { for _, c := range []struct { pattern string target string expect bool }{ {"", "", true}, {"", "a", false}, {"*", "a", true}, {"*a", "a", true}, {"*a", "aa", true}, {"*a", "ab", false}, {"a*", "a", true}, {"a*", "aa", ...
package main import "fmt" /* Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": great / \ gr eat / \ / \ g r e at / \ a t To scramble the string, we ...
package testtool import ( "log" "alauda.io/devops-apiserver/pkg/apis/devops/v1alpha1" devopsclient "alauda.io/devops-apiserver/pkg/client/clientset/versioned" "alauda.io/diablo/src/backend/api" "alauda.io/diablo/src/backend/errors" "alauda.io/diablo/src/backend/resource/common" "alauda.io/diablo/src/backend/re...
// By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. // // What is the 10 001st prime number? package main import ( "fmt" "math" ) func isPrime(n int) bool { for x := 2; x < int(math.Sqrt(float64(n))+1); x++ { if n % x == 0 { return f...
package export import ( "errors" "fmt" "net" "strings" "time" "github.com/tapvanvn/go-chain-wrapper/entity" "github.com/tapvanvn/gopubsubengine" ) type Exporter interface { Export(topic string, message interface{}) } func GetExport(name string) Exporter { if exp, ok := __exportmap[name]; ok { return exp ...
package gfg6310 import ( "math" "testing" ) func TestBadSize(t *testing.T) { result := LockerDistances(-1, -1, nil) if result != nil { t.Errorf("LockerDistances returns nil!") } } func TestResultPresent(t *testing.T) { result := LockerDistances(1, 1, nil) if result == nil { t.Errorf("LockerDistances retur...
package gago // Default configuration. var Default = Population{ NbDemes: 1, NbIndividuals: 30, Boundary: 100.0, SelMethod: Tournament, CrossMethod: Parenthood, CrossSize: 2, MutMethod: Normal, MutRate: 0.1, MutIntensity: 1, MigMethod: Shuffle, } // Medium configuration. ...
// Copyright 2022 The gVisor 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...
package main import "fmt" /* 考点: nil的赋值问题 nil只能赋值给指针, chan, map, slice, interface和func类型的变量 error是内置接口类型,也可以赋值nil */ var m interface{} = nil /* 考点: init()函数 一个包中可以有多个init 函数 不同包的init函数是根据导入的依赖关系来执行的,如A import B, B import C, 此时执行顺序为C, B, A 一个包被多次引用, init只会执行一次 */ /* 考点: 类型选择 类型选择语法 i.(type), i只能...
// Copyright (c) Mainflux // SPDX-License-Identifier: Apache-2.0 package redis type event interface { Encode() map[string]interface{} } var ( _ event = (*mqttEvent)(nil) ) type mqttEvent struct { clientID string timestamp string eventType string instance string } func (me mqttEvent) Encode() map[string]int...
package main import ( "fmt" "regexp" "sort" "strconv" "strings" "time" "github.com/gocolly/colly/v2" ) var citiesToAds = make(map[string]map[string]bool) func main() { SLEEP_TIME := 5000 listOfCities := [...]string{ "https://birmingham.rubratings.com", "https://mobile.rubratings.com", "https://montgom...