text
stringlengths
11
4.05M
package main import "fmt" func main() { matrix := [][]int{{0, 1, 2, 0}, {3, 4, 5, 2}, {1, 3, 1, 5}} setZeroes(matrix) fmt.Println(matrix) } func setZeroes(matrix [][]int) { row := len(matrix) col := len(matrix[0]) firstRow := false firstCol := false for i := 1; i < row; i++ { for j := 1; j < col; j++ { ...
package main import "fmt" func main() { switch 25 { case 1: fmt.Println("Yes") case 25: fmt.Println("No") } }
// Copyright 2020 The Cockroach Authors. // // Licensed as a CockroachDB Enterprise file under the Cockroach Community // License (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // https://github.com/cockroachdb/cockroach/blob/master/li...
package main import "fmt" //int float64 bool string; struct array slice map channel var s string var i int = 0 var j = 0 type Student struct { Name string `json:"name"` Age int `json:"age"` } func main() { fmt.Println(s, i, j) var I int = 0 fmt.Println(I) x := "this is string" x = `is string` fmt.Prin...
package session import ( "context" "reflect" "strings" "time" "gamesvr/manager" "shared/common" "shared/csv/static" "shared/statistic/logreason" "shared/utility/errors" "shared/utility/glog" "shared/utility/param" "shared/utility/servertime" ) func (s *Session) isGMCode(code string) bool { return string...
package main import "fmt" func main() { defer foo() //When main closes then all defers get run bar() } //END main func foo() { fmt.Println("foo") } func bar() { fmt.Println("bar") } //A "defer" statement invokes a function whose execution is deferred to the moment the surrounding function returns, either b...
package client import "github.com/go-redis/redis" var ( Cache *redis.Client )
package getsubcommands import ( snmpsimclient "github.com/inexio/snmpsim-restapi-go-client" "github.com/rs/zerolog/log" "github.com/spf13/cobra" "github.com/spf13/viper" "os" ) // GetEnginesCmd represents the getEngines command var GetEnginesCmd = &cobra.Command{ Use: "engines", Args: cobra.ExactArgs(0), S...
package migrations import ( "database/sql" "github.com/pressly/goose" ) func init() { goose.AddMigration(upInit, downInit) } var initDB = ` CREATE TABLE messages ( id uuid PRIMARY KEY, message text, from uuid NOT NULL, to uuid NOT NULL ); ` func upInit(tx *sql.Tx) error { _, err := tx.Exec(initDB) if err !...
// division and multiplication accuracy in floating point precesion // use of math.Abs package main import "fmt" func main() { // division first c1 := 21.0 fmt.Print((c1/5.0*9.0)+32, "* F\n") fmt.Print((9.0/5.0*c1)+32, "* f\n") // 69.80000000000001* F // 69.80000000000001* f // multiplication first F1 := (c...
package service import ( "context" "fmt" "github.com/imouto1994/yume/internal/infra/sqlite" "github.com/imouto1994/yume/internal/model" "github.com/imouto1994/yume/internal/repository" "go.uber.org/zap" ) type ServiceLibrary interface { CreateLibrary(context.Context, sqlite.DBOps, *model.Library) error GetLi...
package agollo import ( "github.com/go-apollo/agollo/test" "testing" ) func TestStart(t *testing.T) { go runMockConfigServer(onlyNormalConfigResponse) go runMockNotifyServer(onlyNormalResponse) defer closeMockConfigServer() Start() value := getValue("key1") test.Equal(t, "value1", value) }
package ooapi import ( "bytes" "context" "encoding/gob" "encoding/json" "io" "net/http" "strings" "text/template" ) type defaultRequestMaker struct{} func (*defaultRequestMaker) NewRequest( ctx context.Context, method, URL string, body io.Reader) (*http.Request, error) { return http.NewRequestWithContext(c...
package image import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestGetDestinationInfo(t *testing.T) { t.Run(`not nil`, func(t *testing.T) { testDir := "dir" context, reference, err := getDestinationInfo(testDir) require.NoError(t, err) require.NotNil(t,...
// // Weather update client. // Connects SUB socket to tcp://weather-server:5556 // Collects weather updates and finds avg temp in zipcode // package main import ( zmq "github.com/pebbe/zmq4" "fmt" "os" "strconv" "strings" ) func main() { // Socket to talk to server fmt.Println("Collecting updates from w...
// Copyright 2019 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 ( "encoding/json" "io/ioutil" "log" ) const ( config = ".loop.json" ) const ( red = "\033[31m" green = "\033[32m" reset = "\033[39;49m" ) func main() { loop := &Loop{} data, err := ioutil.ReadFile(config) if err != nil { log.Fatal(err) } err = json.Unmarshal(data, loop) if err !...
package main import ( "log" "os" "github.com/akamensky/argparse" ) func main() { parser := argparse.NewParser("Tv Series Renamer", "Organizes your tvseries") inputPath := parser.String("i", "inputPath", &argparse.Options{Required: true, Help: "path/to/folder/for/input"}) err := parser.Parse(os.Args) if err...
package option import ( "errors" "fmt" "os" "path/filepath" "runtime" "github.com/jacexh/multiconfig" ) type ( // LoggerOption 日志配置模块 LoggerOption struct { Level string `default:"info"` Name string Filename string MaxSize int `default:"100" yaml:"max_size,omitempty" json:"max_size,om...
package configmap import ( "context" "strconv" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ctrlclient "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1" ) func UpsertDisableConfigMap(ctx context.Context...
package model import ( "github.com/joostvdg/cmg/pkg/model" ) // MapLegend Legend for API uses, which allows use of codes (which can than be mapped via the Legend type MapLegend struct { Harbors []model.Harbor Landscapes []model.Landscape }
package flags import ( "fmt" "strings" "github.com/urfave/cli" ) // OldPasswordFile returns a flag for receiving an old password func OldPasswordFile(usage string) cli.Flag { if usage == "" { usage = "The path to the `FILE` containing the old encryption password" } return cli.StringFlag{ Name: "old-pass...
package main import ( "math" "sync" ) type Tree struct { cache Path size uint64 h Hasher sync.RWMutex } func (t Tree) Root() Pos { return Pos{0, uint64(math.Ceil(math.Log2(float64(t.size))))} } func (t Tree) Last() Pos { return Pos{t.size, 0} } func (t *Tree) Add(event []byte) (Digest, Visitor) { t.L...
package main import ( "fmt" "strings" ) // submission on leetcode // https://leetcode.com/submissions/detail/293528291/ func main() { testStr := "the sky is blue" fmt.Printf("'%s'", reverseWords(testStr)) testStr = " Hello! World! " fmt.Printf("'%s'", reverseWords(testStr)) testStr = " Hello! World! " f...
package day12 import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // TestSomething : test func TestParsing(t *testing.T) { colorReset := "\033[0m" colorGreen := "\033[32m" colorYellow := "\033[33m" testData := "input_test.txt" functionOutput := ParseInput(testData) validResult := []instructio...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package arcvpn interacts with the ARC-side fake VPN. package arcvpn import ( "context" "fmt" "regexp" "strings" "time" "chromiumos/tast/common/action" "chromiumos...
package main import ( "bufio" "bytes" "fmt" "io/ioutil" "log" "net" "os" "strconv" "strings" "sync" "time" ) /*Constants used throughout the program to identify commands, request, response, and error messages*/ const ( //request SET = "set" GET = "get" GETM = "getm" CAS = "cas" DELETE ...
package main import "fmt" func main() { fmt.Println("Hakuna " + "Matata") fmt.Println("Let's check whether 1+1 is 11 ", 1+1) fmt.Println("float check 7.0/3.0 =", 7.0/3.0) fmt.Println("bool check ", true && false) fmt.Println("Life is awesome: ", true || false) fmt.Println("go is difficult",...
// envsubst command line tool package main import ( "bufio" "flag" "fmt" "io" "os" ) var ( input = flag.String("i", "", "") output = flag.String("o", "", "") noUnset = flag.Bool("no-unset", false, "") noEmpty = flag.Bool("no-empty", false, "") ) var usage = `Usage: envsubst [options...] <input> Options:...
package svrtest import ( bnd "github.com/devwarrior777/atomicswap/libs/protobind" ) /* TEST DATA FOR THE LTC WALLET RPC COMMANDS You will need your own testdata that reflects your coins configurations: - Testnet or not - RPC Info to connect to your LTC RPC wallet node(s) */ var ltcPingWalletRPCRequest = bnd.Ping...
package bot import "github.com/SevereCloud/vksdk/v2/object" func getPersonalAreaKeyboard() *object.MessagesKeyboard { k := object.NewMessagesKeyboardInline() k.AddRow() k.AddTextButton(`Изменить кабинет`, ``, `primary`) k.AddRow() k.AddTextButton(`История заказов`, ``, `secondary`) k.AddRow() k.AddTextButto...
package resolver import ( "context" "github.com/plexmediamanager/micro-torrent/proto" ) func (service TorrentService) ApplicationVersion (_ context.Context, properties *proto.TorrentEmpty, response *proto.TorrentResponse) error { result, err := service.Torrent.ApplicationVersion() return structureToBy...
package main import ( "ShortURL/internal/app/store" "ShortURL/pkg/api" "ShortURL/pkg/grpcserver" "log" "net" "os" "github.com/go-redis/redis" "github.com/joho/godotenv" "google.golang.org/grpc" ) func init() { // loads values from .env into the system if err := godotenv.Load(); err != nil { log.Print("N...
package userMemory const ( UserName = "user" UserPass = "user" ) var BasicUser User type User struct { Name string Pass string } func SetUserPassword() { BasicUser = User{ Name: UserName, Pass: UserPass, } } func UpdateUserPass(pass string) { BasicUser = User{ Name: UserName, Pass: pass, } }
package redshift import ( "context" "database/sql" "fmt" "io/ioutil" "log" "regexp" "strings" "time" kvlogger "gopkg.in/Clever/kayvee-go.v6/logger" yaml "gopkg.in/yaml.v2" "github.com/Clever/pathio" multierror "github.com/hashicorp/go-multierror" // Use our own version of the postgres library so we get...
package client import ( "context" "crypto/rsa" "crypto/x509" "encoding/json" "encoding/pem" "fmt" "net/http" "time" "golang.org/x/oauth2" oauth2JWT "golang.org/x/oauth2/jwt" "github.com/pkg/errors" jose "gopkg.in/square/go-jose.v2" fctx "formation.engineering/library/lib/telemetry/context" ) type Cred...
package engine import ( "github.com/Gregmus2/simple-engine/common" "github.com/Gregmus2/simple-engine/graphics" "github.com/go-gl/gl/v4.6-core/gl" "github.com/go-gl/glfw/v3.3/glfw" "github.com/sirupsen/logrus" "time" ) type App struct { Window *glfw.Window GL *graphics.OpenGL updateActions ...
package migration import ( "log" "github.com/Anondo/graphql-and-go/conn" "github.com/Anondo/graphql-and-go/database/migration" "github.com/spf13/cobra" ) var downCMD = &cobra.Command{ Use: "down", Short: "Drop tables from database", Long: `Drop tables from database`, RunE: downDatabase, } func downDatab...
package get import ( "github.com/spf13/cobra" ) var RootCMD = &cobra.Command{ Use: "get", Short: "Get Studio resources", Long: ``, } func init() { RootCMD.AddCommand(customersCMD) }
package config const ( // TmpDataFileDir - TmpDataFileDir = "/Users/duanyahong/tmp/data/" // TmpChunkFileDir - TmpChunkFileDir = "/Users/duanyahong/tmp/chunk/" )
package server import ( "github.com/Buhrietoe/brood/server/apiv1" "github.com/Buhrietoe/brood/server/middleware" "github.com/gin-gonic/gin" ) type Server struct { Address string Port string ListenString string // Complete string of address:port to listen on } // BuildServer configures the web ser...
package hmacsha256 import ( "crypto" "fmt" "testing" ) func TestHmacSha2562(t *testing.T) { fmt.Println(HmacSha256("hello","111")) } func TestHmacEncrypt(t *testing.T) { fmt.Println(HmacEncrypt([]byte("hello"),[]byte("111"),crypto.SHA256)) } func TestHmacEncryptToBase64(t *testing.T) { fmt.Println(HmacEncrypt...
package command import ( "net/url" "os" "path/filepath" "strings" "time" "github.com/cidverse/cid/pkg/core/util" "github.com/cidverse/cidverseutils/pkg/containerruntime" "github.com/cidverse/cidverseutils/pkg/filesystem" "github.com/rs/zerolog/log" ) func ApplyProxyConfiguration(containerExec *containerrunt...
// Copyright 2020 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package main import "fmt" func main() int { nums := [3]int{3,2,3} target := 6 for i := 0; i < len(nums); i++ { for j := i + 1; j < len(nums); j++ { var total int total = nums[i] + nums[j] if total == target { return[2]int{i, j} fmt.Println(successVar) r...
package nocgo import ( "errors" "reflect" "unsafe" ) func mustSpec(fn *byte, fun interface{}) { err := makeSpec(uintptr(unsafe.Pointer(fn)), fun) if err != nil { panic(err) } } // on 386 we need to do the dance of cgo_import_dynamic followed by two linknames, // definining a variable that gets the dynamic sy...
package model type Cell struct { Mine bool `json:"mine"` Revealed bool `json:"revealed"` Flagged bool `json:"flagged"` MinesAround int `json:"mines_around"` }
package main import "github.com/drakmaniso/glam" type Transform struct { TransformMat glam.Mat4 } func NewTransform(matrix glam.Mat4) *Transform { return &Transform{matrix} } func MakeTransform() *Transform { return NewTransform(*MatIdentity4) } func Translate(amount glam.Vec3) *Transform { return NewTransform...
// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php package blkgenorV2 import ( "sort" "sync" "time" "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/m...
/* * Created on Thu Mar 21 2019 22:51:36 * Author: WuLC * EMail: liangchaowu5@gmail.com */ func shipWithinDays(weights []int, D int) int { left, right := 0, 0 for _, w := range weights { left = max(left, w) right += w } mid, tmp, days := 0, 0, 0 for left < right { mid, tmp, days = left + ((right - left...
package models type SysConfig struct { Id string `json:"id" xorm:"pk 'id'"` Key string `json:"key" xorm:"'key'"` Value string `json:"value" xorm:"'value'"` Comments string `json:"comments" xorm:"'comments'"` } func (SysConfig) TableName() string { return "sys_config" } var DefaultSysConfig = make(...
package main func main() { server := newSever(":1935") server.run() }
package main /* enum chess { Queen, King, Knight, Pawn, }; */ import "C" import "fmt" func main() { var queen C.enum_chess = C.Queen var king C.enum_chess = C.gKing var pawn C.enum_chess = C.Pawn var knight C.enum_chess = C.Knight fmt.Println(queen) fmt.Println(king) fmt.Println(pawn) fmt.Println(knight) ...
// This abstracts common-use functions from the database // All functions here will return client-safe messages. // That is, nothing internal will be exposed in these messages. package main import ( "crypto/rand" "encoding/base64" "fmt" "time" ) const ( tokenLength = 32 saltLength = 10 ) /***************** * ...
package global import ( "context" "testing" "github.com/go-redis/redis/v8" ) func TestGreetings(t *testing.T) { GreetingsGlobal := NewGreetings(redis.NewClient(&redis.Options{ Username: "root", Password: "", Addr: ":6379", })) ctx := context.Background() err := GreetingsGlobal.SetUserGreetingCoun...
package testdata import ( "path/filepath" "runtime" ) func NginxIngressChartPath() string { return filepath.Join(staticPath(), "nginx-ingress-0.31.0.tgz") } func staticPath() string { _, file, _, ok := runtime.Caller(0) if !ok { panic("Could not locate path to tiltfile/testdata") } return filepath.Dir(file...
package main import "fmt" // Go doesn't support any pointer arithmatic like C func main() { var num int = 10 increment(&num) fmt.Println(num) fmt.Println(increment(&num)) } func increment(x *int) int { *x++; return *x; }
package main import "fmt" type Student struct { id int name string age int sex string score int addr string } //结构体变量作为函数参数 func test(stu Student) { stu.name = "野猪佩奇" fmt.Println(stu) } func main0201() { stu := Student{101, "喜羊羊", 6, "男", 100, "羊村"} //值传递 test(stu) fmt.Println(stu) } func tes...
package domain type Tweet struct { User string Text string CreatedAt string }
package mpath import ( "bytes" "fmt" "net/http" "path" "strings" "unicode" "github.com/gorilla/muxy" //"github.com/gorilla/muxy/encoder" "golang.org/x/net/context" ) func NotFoundHandler(h muxy.Handler) func(*matcher) { return func(m *matcher) { m.notFoundHandler = h } } func New(options ...func(*match...
package config import "github.com/kelseyhightower/envconfig" type MySQLConfig struct { Host string `default:"127.0.0.1"` Port string `default:"3306"` DBUser string `default:"root"` Password string `default:"mysql"` DataBase string `default:""` } func Init() (*MySQLConfig, error) { config := &MySQLC...
package analytics import ( "errors" "os" "time" "github.com/gobuffalo/uuid" "go.uber.org/zap" segment "gopkg.in/segmentio/analytics-go.v3" ) // Client ... type Client struct { client segment.Client logger *zap.Logger } // NewClient ... func NewClient(logger *zap.Logger) (Client, error) { writeKey, ok := o...
package solutions func cloneGraph(node *GraphNode) *GraphNode { if node == nil { return nil } queue := []*GraphNode{node} cloned := map[int]*GraphNode{ node.Val: { Val: node.Val, Neighbors: []*GraphNode{}, }, } for len(queue) > 0 { node,...
package stdmeta import ( "context" "errors" "reflect" "sync" "github.com/spf13/viper" "github.com/superchalupa/sailfish/src/dell-resources/attributes" "github.com/superchalupa/sailfish/src/log" "github.com/superchalupa/sailfish/src/ocp/model" "github.com/superchalupa/sailfish/src/ocp/testaggregate" "github....
package app import ( "context" "encoding/json" "log" "net/http" "github.com/jackc/pgx/v5/pgtype" ) func (c *App) SuspendUser() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { query := r.URL.Query() id := query.Get("id") log.Println("suspending user", id) user := c.LoggedInUs...
// Will combine NACS with NACS_table // Create a File. // Then Submit to FIRESTORE package main import ( "context" "encoding/json" "fmt" "io/ioutil" "log" "os" firebase "firebase.google.com/go" "google.golang.org/api/option" ) var TableMap = map[string]NACSTable{} func main() { var ComplexNACS []COMPLEX...
package tests_test import ( "sigs.k8s.io/kustomize/k8sdeps/kunstruct" "sigs.k8s.io/kustomize/k8sdeps/transformer" "sigs.k8s.io/kustomize/pkg/fs" "sigs.k8s.io/kustomize/pkg/loader" "sigs.k8s.io/kustomize/pkg/resmap" "sigs.k8s.io/kustomize/pkg/resource" "sigs.k8s.io/kustomize/pkg/target" "testing" ) func writeK...
package main import ( "fmt" "os" ) func checkErr(err error) { if err != nil { fmt.Fprintf(os.Stderr, "error: %v\n", err) os.Exit(1) } }
package strategy import ( "github.com/joshprzybyszewski/cribbage/model" ) // GiveCribHighestPotential gives the crib the highest potential pointed crib func GiveCribHighestPotential(_ int, hand []model.Card) ([]model.Card, error) { return getEvaluatedHand(hand, newTossEvaluator(false, highestIsBetter)) } // GiveCr...
// Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. 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 // ...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package utility import ( "strings" "github.com/mattermost/mattermost-cloud/internal/tools/aws" "github.com/mattermost/mattermost-cloud/model" "github.com/pkg/errors" log "github.com/sirupsen/logrus...
package model type PandoInfo struct { PeerID string Addresses APIAddresses } type APIAddresses struct { HttpAPI string GraphQLAPI string GraphSyncAPI string }
package array import "fmt" func removeDuplicatesLC80(nums []int) int { n := len(nums) if n < 2 { return n } slow := 2 for fast := 2; fast < n; fast++ { fmt.Println(slow) if nums[fast] != nums[slow-2] { nums[slow] = nums[fast] slow++ } } return slow }
/* A simple library to build queriable html structure. * * @author: FATESAIKOU * @date : 04/17/2018 */ package queriableHtml import ( "fmt" "bytes" "strings" "regexp" "golang.org/x/net/html" ) type DOMObj struct { Atom string Attrs map[string]string Contents []DOMObj TokenTyp...
package main import ( "github.com/gin-gonic/gin" "go-fcm-example/admin/src/define" "go-fcm-example/admin/src/service" "net" "net/http" "time" ) /** * @Author: caishi13202 * @Date: 2021/9/27 3:00 下午 */ // 初始化路由 func initRouter(router *gin.Engine) { loginUser := make(map[string]string, 16) httpClient := create...
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package router provides utilities for accessing or controlling different routers. package router
package access import ( "github.com/kataras/iris" "gopkg.in/mgo.v2" ) type Resp struct { Msg string `json:"msg"` Data interface{} `json:"data"` } var ( RespOK = Resp{Msg: "OK"} ) //Access interface type Access interface { Create(p interface{}) (interface{}, error) Read(p interface{}, id string) (interf...
package apiserver import ( "context" "crypto/tls" "crypto/x509" "fmt" "io/ioutil" "os" "path" "time" "k8s.io/api/admissionregistration/v1beta1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/util/cert" apiregv1 "k8s.io/kube-agg...
package main //1460. 通过翻转子数组使两个数组相等 //给你两个长度相同的整数数组target和arr。每一步中,你可以选择arr的任意 非空子数组并将它翻转。你可以执行此过程任意次。 // //如果你能让 arr变得与 target相同,返回 True;否则,返回 False 。 // // // //示例 1: // //输入:target = [1,2,3,4], arr = [2,4,1,3] //输出:true //解释:你可以按照如下步骤使 arr 变成 target: //1- 翻转子数组 [2,4,1] ,arr 变成 [1,4,2,3] //2- 翻转子数组 [4,2] ,arr 变成 [1,...
package mssql import ( "fmt" "gorm.io/gorm/schema" ) type MniNamer struct { TablePrefix string SingularTable bool } func (MniNamer) TableName(table string) string { return table } func (MniNamer) ColumnName(table, column string) string { return fmt.Sprintf("%v", column) } func (MniNamer) JoinTableName(joi...
package main type Sema struct { counter chan int8 } func newSema(n int) *Sema { return &Sema { counter: make(chan int8, n), } } func (s *Sema) acquire() { var one int8 s.counter <- one } func (s *Sema) release() { if s.isEmpty() { return } <- s.counter } func (s *Sema) count() int { return len(s.count...
package domain import "fmt" type Ads struct { Id int64 `pg:",notnull"` Title string `pg:",notnull"` Description string `pg:",notnull"` Price float64 `pg:",notnull"` UserId int64 `pg:",notnull,fk"` Picture string `pg:""` Sold bool `pg:",use_zero"` } func StringAds(a *Ads) strin...
package main import ( "bufio" "fmt" "log" "os" "strings" ) const k = ` !"#$%&'()*+,-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz` func gronsfeld(p, q string) string { r := make([]byte, len(q)) for i := 0; i < len(q); i++ { r[i] = k[(len(k)+strings.IndexRune(k, rune(q[i]))-int(p[i%l...
package thirdapi import ( "encoding/json" "io/ioutil" "log" "net/http" ) // AliIP 阿里ip归属地查询 type AliIP struct { Status string `json:"status,omitempty"` // Info string `json:"info,omitempty"` // Infocode string `json:"infocode,omitempty"` // Province string `json:"province,omitempty"` // C...
// 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 gflConst type RankC int const ( Navigator RankC = 300 + iota FlightEngineer SecondOfficer FirstOfficer Captain ) /* type RankC struct { elements map[string]int } func (l *RankC) Const(ref string) int { if ret, ok := l.elements[ref]; ok { return ret } else {...
// SPDX-License-Identifier: ISC // Copyright (c) 2014-2020 Bitmark Inc. // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package transactionrecord import ( "github.com/bitmark-inc/bitmarkd/account" "github.com/bitmark-inc/bitmarkd/currency" "github.com/bitmark-inc/...
package text // Import external packages import ( "github.com/veandco/go-sdl2/sdl" ) // subpackages import ( "flood_go/graphicsx" ) // ===================================================================== // Struct: TextObject // ===================================================================== type TextO...
package order type Product struct { Name string `json:"name" validate:"required"` Quantity float64 `json:"quantity"` Unit int `json:"unit"` Price float64 `json:"price"` Measure float64 `json:"measure"` }
package easyquery import ( "fmt" "gorm.io/gorm" ) func PageScope(paginater Paginater) func(db *gorm.DB) *gorm.DB { return func(db *gorm.DB) *gorm.DB { return db.Limit(paginater.GetSize()).Offset(paginater.GetOffset()) } } func PageOrderIdDescScope(paginater Paginater, table string) func(db *gorm.DB) *gorm.DB ...
package kubeconf import ( "io/ioutil" "github.com/ghodss/yaml" kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1" ) // GetKubeletConfigFromLocalFile returns KubeletConfiguration loaded from the node local config func GetKubeletConfigFromLocalFile(kubeletConfigPath string) (*kubeletconfigv1beta1.KubeletConfigur...
package models // Copyright 2016-2017 MediaMath // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable l...
/* * Copyright 2019, Offchain Labs, 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 ag...
package common import ( "github.com/pkg/errors" "log" "os" "strconv" ) const ( EnvCriticalFusePodEnabled = "CRITICAL_FUSE_POD" ) var criticalFusePodEnabled bool func init() { if strVal, exist := os.LookupEnv(EnvCriticalFusePodEnabled); exist { if boolVal, err := strconv.ParseBool(strVal); err != nil { pa...
package streaming_transmit import ( "encoding/binary" "fmt" "io" "sync" "time" "github.com/lithdew/bytesutil" "github.com/valyala/bytebufferpool" ) var DefaultReadBufferSize = 4096 var DefaultWriteBufferSize = 4096 var DefaultReadTimeout = 3 * time.Second var DefaultWriteTimeout = 3 * time.Second var Defaul...
package main /* This question was asked by BufferBox. Given a binary tree where all nodes are either 0 or 1, prune the tree so that subtrees containing all 0s are removed. For example, given the following tree: 0 / \ 1 0 / \ 1 0 / \ 0 0 should be pruned to: 0 / \ 1 0 / 1 We d...
package packet import ( "github.com/google/gopacket" layers "github.com/google/gopacket/layers" "github.com/taciomcosta/dnsbyo/dns" "net" ) type Packet struct { dnsPacket *layers.DNS clientAddr net.Addr } func New(buff []byte, addr net.Addr) Packet { packet := gopacket.NewPacket(buff, layers.LayerTypeDNS, go...
// Copyright 2016-2018, Pulumi Corporation. // // 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...
package telepathy import ( "net/url" "gitlab.com/kavenc/argo" "github.com/sirupsen/logrus" ) // Plugin defines the functions that need to be implemented for all plugins // Plugins may optionally implement other functions by implement intefaces below type Plugin interface { // Id returns the unique id for the pl...
package steps import ( "fmt" survey "github.com/AlecAivazis/survey/v2" "github.com/lib/pq" "github.com/pganalyze/collector/setup/query" s "github.com/pganalyze/collector/setup/state" ) var EnsureMonitoringUser = &s.Step{ ID: "ensure_monitoring_user", Description: "Ensure the monitoring user (db_user ...