text
stringlengths
11
4.05M
package context import ( "time" ) // Context is the struct to store application contexts for pages with different languages. // And returns only the requested language as Value. // datastore: ",noindex" causes json naming problems !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // Key's "StringID" is a fraction of the contex...
package main import ( "context" "fmt" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "log" "time" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) type MachineStatus struct { ID primitive.ObjectID `bson:"_id,omitempty"` Machine ...
/* * Copyright 2018, CS Systemes d'Information, http://www.c-s.fr * * 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 requir...
package main import ( "flag" "fmt" "io/ioutil" "log" "sort" "strconv" "strings" ) func main() { flag.Parse() if len(flag.Args()) != 1 { return } fileContents := MustOpenTextFile(flag.Args()[0]) lines := strings.Split(fileContents, "\n") n, _ := strconv.Atoi(lines[0]) sort.Sort(ByLength(lines[1:])) ...
package engine import ( "encoding/hex" "math/rand" ) // StoreState is the all-encompassing state of the cluster. The operations are // performed to this after being cast to a finite state machine, and otherwise // won't be able to make any changes. // // Important to note is that the state is not aware of its distr...
package main import "fmt" //Taiyaki is type(struct) type Taiyaki struct{} //Atama is function func (t Taiyaki) Atama() { fmt.Println("たい焼きの頭の方にはあんこがいっぱい入っている") } //Shippo is function func (t Taiyaki) Shippo() { fmt.Println("たい焼きの尻尾にはあんこがほとんど入っていない") fmt.Println("しかしカリカリしていて美味しい") } func main() { va...
package groupAnagrams func groupAnagrams(strs []string) [][]string { m := map[string][]string{} for i := 0; i < len(strs); i++ { base := convertToBase(strs[i]) if v, ok := m[base]; ok { m[base] = append(v, strs[i]) } else { m[base] = []string{strs[i]} } } ret := [][]string{} for _, v := range m { ...
package main import ( "encoding/json" "fmt" ) // 嵌套结构体 到 Json的互相转换 // 定义一个Student结构体 type Student3 struct { Id int Gender string Name string } // 定义一个班级结构体 type Class struct { Title string Students []Student3 } func main() { var class = Class{ Title: "1班", Students: make([]Student3, 0), } for i := 0;...
package domain // Article is an interface of an article type Article struct { ID string `json:"id"` PublishedAt string `json:"published"` Link string `json:"link"` Title string `json:"title"` Description string `json:"description"` Content string `json:"content"` } // Articles is a col...
package main import ( "fmt" "github.com/gorilla/websocket" "github.com/nsqio/go-nsq" "log" "net/http" ) var upgrader = websocket.Upgrader{ ReadBufferSize: 1024, WriteBufferSize: 1024, } type Client struct { conn *websocket.Conn addr string incoming chan []byte } func wsHandler(producer *nsq.Produ...
package main import ( f "fmt" "sort" ) func main() { strs := []string{"c", "a", "b"} sort.Strings(strs) f.Println("Strings : ", strs) ints := []int{4, 7, 1} sort.Ints(ints) f.Println("Ints : ", ints) s := sort.IntsAreSorted(ints) f.Println("Sorted : ", s) }
package cmd import ( "io/ioutil" "gopkg.in/yaml.v2" "github.com/ContinuousSecurityTooling/clairctl/clair" "github.com/coreos/clair/api/v1" "strings" ) func NewWhiteList(path string) *WhiteList { w := &WhiteList{path: path} w.whitelisted = vulnerabilitiesWhitelist{} whitelistBytes, err := ioutil.ReadFile(w.pa...
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package ir type insertPointType int const ( insertUndefined insertPointType = iota insertAfterInstr insertBeforeInstr insertBlockEnd ) type Builder struct { insertType insertPointType insertInstr *Instr insertBlock *Block } func NewBuilder() *Builder { return &Builder{} } func (v *Builder) insert(i *Instr...
package services import ( "strings" "github.com/swjang1214/bookstore_oauth-api/src/models/access_token" "github.com/swjang1214/bookstore_oauth-api/src/utils/errors" ) // type IRepository interface { // GetById(string) (*AccessToken, *errors.RestError) // Create(*AccessToken) *errors.RestError // UpdateExpirati...
package main import "fmt" /** 定义一个人结构体 */ type Person struct { name string age int sex string } func main() { // 实例化结构体 var person Person person.name = "张三" person.age = 20 person.sex = "男" fmt.Printf("%#v", person) // 第二种方式实例化 var person2 = new(Person) person2.name = "李四" person2.age = 30 person2....
// Copyright 2015 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 applicabl...
package main import "fmt" func demo(recoverHighestPanicAtFirst bool) { fmt.Println("====================") defer func() { if !recoverHighestPanicAtFirst{ // recover panic 1 defer fmt.Println("panic", recover(), "is recovered") } defer func() { // recover panic 2 fmt.Println("panic", recover(), "is...
package module import ( "encoding/base64" "fmt" "io/ioutil" "net/http" "strings" "github.com/Qihoo360/poseidon/service/meta/store" "github.com/golang/glog" "github.com/gorilla/mux" ) func getBackendStoreName(metaType, businessName string) string { return metaType + "/" + businessName } func (m *Meta) Get(w...
package httpStreamWriter import ( "net/http" ) func HijackAndForceClose(w http.ResponseWriter) { hj, ok := w.(http.Hijacker) if !ok { logger.Println("Error hijacking connection") http.Error(w, "webserver doesn't support hijacking", http.StatusInternalServerError) return } conn, _, err := hj.Hijack() if e...
package content_test import ( "github.com/concourse/bosh-io-stemcell-resource/content" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("BuildRange", func() { Context("when an even content length is provided", func() { var cr content.Ranger BeforeEach(func() { cr = content.NewRang...
package entities // Player defines a player for our application type Player struct { Code int `json:"code"` Name string `json:"name"` QuestKey string `json:"questkey"` QuestState string `json:"queststate"` QuestStatus string `json:"queststatus"` Achievements []string `json:"ac...
package merkle // Tree is the information on the structure of a set of nodes // // TODO more docs here type Tree struct { Nodes []*Node `json:"pieces"` BlockLength int `json:"piece length"` } // Pieces returns the concatenation of hash values of all blocks // // TODO integrate with hash size func (t *Tree...
package main import ( "fmt" "net/url" "time" "github.com/pocke/paizaio" ) const code = ` package main import "fmt" func main() { fmt.Println("Hello World!") } ` func main() { paiza := paizaio.NewAPI() v := url.Values{} v.Add("language", "go") v.Add("source_code", code) r, err := paiza.RunnerCreate(v) ...
package logger type Interface interface { Info(err error) InfoStr(err string) Trace(err error) TraceStr(err string) Debug(err error) DebugStr(err string) Warning(err error) WarningStr(err string) Panic(err error) PanicStr(err string) Error(err error) ErrorStr(err string) }
package main import "fmt" func main() { //var cat int = 1 //var str string = "banana" // //fmt.Printf("%p, %p", &cat, &str) //var house = "Malibu Point 10880, 90264" //ptr := &house //fmt.Printf("ptr type: %T\n", ptr) // ptr 的类型 //// ptr 指针的地址 //fmt.Printf("address: %p \n", ptr) //value := *ptr //fmt.Print...
package main const ( _ = iota KB int64 = 1 << (10 * iota) )
package util import ( "net" ) // NewStdinListener creates a new stdin listener func NewStdinListener() *StdinListener { return &StdinListener{ connChan: make(chan net.Conn), } } // StdinListener implements the listener interface type StdinListener struct { connChan chan net.Conn } // Ready implements interfac...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2020-08-18 09:57 # @File : lt_3_Longest_Substring_Without_Repeating_Characters.go # @Description : 不重复最长子串 # @Attention : */ package slide_window import ( "fmt" "testing" ) func Test_lengthOfLongestSubstring(t *testing.T) { fmt.Println(lengthOfLongestSubstring...
package device import ( "errors" "github.com/tiagorlampert/CHAOS/entities" "github.com/tiagorlampert/CHAOS/repositories" "gorm.io/gorm" "time" ) type deviceRepository struct { dbClient *gorm.DB } func NewRepository(dbClient *gorm.DB) Repository { return &deviceRepository{dbClient: dbClient} } func (r deviceR...
package main import ( "encoding/json" "net/http" log "github.com/Sirupsen/logrus" ) func loadMetrics(config rabbitExporterConfig, endpoint string, build func(d *json.Decoder)) { client := &http.Client{} req, err := http.NewRequest("GET", config.RabbitURL+"/api/"+endpoint, nil) req.SetBasicAuth(config.RabbitUse...
package rigis import ( "errors" "net/http" "net/url" "github.com/rocinax/rigis/pkg/rule" "github.com/sirupsen/logrus" ) // Rigis Rocinax Rigis type Rigis interface { ServeHTTP(res http.ResponseWriter, req *http.Request) } type rigis struct { filter filter nodes []node } // NewRigis : func NewRigis(config ...
package controller import ( "encoding/json" "errors" "fmt" "log" "net/http" "net/http/httptest" "net/url" "strings" "testing" "github.com/ksw95/GoIndustrialProject/API/models" "github.com/DATA-DOG/go-sqlmock" _ "github.com/go-sql-driver/mysql" // go mod init api_server.go "github.com/labstack/echo" "gi...
package main /* @Time : 2020/10/8 23:00 @Author : DELL ricemarch@foxmail.com @tips: */ func reverseString(s []byte) { for left, right := 0, len(s)-1; left < right; left++ { s[left], s[right] = s[right], s[left] right-- } }
package moss /* Copyright 2018 Bruno Moura <brunotm@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by ...
package main import "fmt" func main() { for i := 32; i <= 122; i++ { fmt.Printf("%d\t%b\t%#X\t%#U\n", i, i, i, i) } }
// Copyright (C) 2019 Cisco Systems 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 agr...
package main import ( "fmt" "strings" "github.com/lflxp/systemed" ) func test() { systemed := systemed.NewSystemed("systemctl") systemed.SetArgs("list-unit-files").SetArgs("--type service").SetArgs("--plain").SetArgs("|grep -vE 'STATE|listed'|tr -s '\n'|awk '{print $1\" \" $2}'") rs, err := systemed.Exec() if...
package atomix // CacheLine of the CPU. // See aligned_cachelineXXX.go files const CacheLine = cacheLineBytes type atomicType struct { _ incomparable } type incomparable [0]func()
package types import ( "errors" . "grm-service/util" ) var ( ErrDataSetIdNULL = errors.New(TR("id of new dataset is null")) ErrScanDataDirInvalid = errors.New(TR("scan data dir is empty or not exists")) ErrInvalidDataType = errors.New(TR("invalid data type")) ErrInvalidDataSet = errors.New(TR("inva...
package main func hIndex2(citations []int) int { l := 0 n := len(citations) r := n for l < r { mid := l + (r-l)/2 if citations[mid] >= n-mid { r = mid } else { l = mid + 1 } } return n - l }
package rabbit import ( "fmt" "log" "github.com/streadway/amqp" ) type Rabbit struct { hostname string connection *amqp.Connection channel *amqp.Channel queue *amqp.Queue exchange_name string exchange_type string queue_name string } func failOnError(err error, msg string) { if err != nil { log.Fatalf("%...
package web import ( "context" "encoding/json" "net/http" ) // RespondJSON marshals the object provided and writes to the response func RespondJSON(ctx context.Context, w http.ResponseWriter, object interface{}, headers map[string]string) { // Marshal object to JSON jsonBytes, err := json.Marshal(object) if err...
package main import "fmt" func PrintError(err error) { fmt.Println("Error(s) happened during processing, Please verify your input. More info:", err) } func PrintOutput(copies int) { fmt.Println(copies, "copies are needed.") }
package floc import "sync/atomic" const ( controlEnabled = 1 // Call to Complete or Cancel is permitted controlDisabled = 0 // Call to Complete or Cancel is prohibited ) type disablableFlowControl struct { parent Flow state int32 } // DisableFunc when invoked disables calls to Complete and Cancel. type Disabl...
package model type Todo struct { ID string `json:"id"` Text string `json:"text"` UserID string `json:"user"` }
package interruption import ( "encoding/json" "net/http" "time" ) const url = "https://www.mvg.de/.rest/betriebsaenderungen/api/interruptions" // Client is a client for the MVG interruptions API type Client interface { // Interruptions fetches and returns all interruptions available Interruptions() ([]Interrupt...
package labels import ( "reflect" "strings" "sync" "testing" "time" . "github.com/anthonybishopric/gotcha" "github.com/hashicorp/consul/api" "github.com/rcrowley/go-metrics" "k8s.io/kubernetes/pkg/labels" "github.com/square/p2/pkg/logging" ) type fakeLabelStore struct { data map[string][]byte dataMu s...
package mapsutil_test import ( "fmt" "github.com/AdguardTeam/golibs/mapsutil" ) func ExampleOrderedRange() { m := map[string]int{ "b": 200, "a": 100, "c": 300, "d": 400, } mapsutil.OrderedRange(m, func(k string, v int) (cont bool) { fmt.Printf("value for %q is %d\n", k, v) // Do not print any valu...
package main import ( "bufio" "fmt" "os" "strings" ) type name struct { fname string lname string } var names []name func check(err error) { if err != nil { panic(err) } } func main() { scanner := bufio.NewScanner(os.Stdin) fmt.Print("Please enter a filename: ") scanner.Scan() filename := scanner.T...
package mongo import ( "context" "fmt" "log" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" ) //var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second) var ctx = context.Background() //defer cancel() type Student struct {...
package httpclient import ( "bytes" "context" "encoding/json" "fmt" "io" "net/http" "net/url" "strings" "github.com/pkg/errors" ) type HostGetter func() string type Client struct { host HostGetter *http.Client } func NewClient() *Client { c := &Client{ Client: DefaultHttpClient, } return c } func...
package csidriveroperator import ( "context" "fmt" "strconv" "strings" "time" operatorapi "github.com/openshift/api/operator/v1" "github.com/openshift/cluster-storage-operator/pkg/csoclients" "github.com/openshift/cluster-storage-operator/pkg/generated" "github.com/openshift/cluster-storage-operator/pkg/oper...
package ibmcloud import ( "net/http" "reflect" "strings" "github.com/IBM/vpc-go-sdk/vpcv1" "github.com/pkg/errors" ) const ( securityGroupTypeName = "security group" securityGroupRuleTypeName = "security group rule" ) // listSecurityGroups lists security groups in the vpc func (o *ClusterUninstaller) lis...
package paxos import ( "coms4113/hw5/pkg/base" ) const ( Propose = "propose" Accept = "accept" Decide = "decide" ) type Proposer struct { N int Phase string N_a_max int V interface{} SuccessCount int ResponseCount int // To indicate if response from peer is receive...
package request import ( "net/http" ) type Option func(r *Request) // option factory type options struct{} var Options options func (options) Method(method string) Option { return func(r *Request) { r.method = method } } func (options) CheckResponseBeforeUnmarshal(f CheckResponseBeforeUnmarshalFunc) Option ...
package store import ( "context" "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "strings" "github.com/projecteru2/phistage/common" ) // KhoriumManager manages khorium steps. // Currently it can download (git clone) // repo identified by khorium step name from // GitLab and GitHub. type KhoriumManager struc...
package print import ( "fmt" "strings" ) const ( head = "HEAD" ) // Printable represents a repository which status can be printed type Printable interface { Path() string Current() string Branches() []string BranchStatus(string) string WorkTreeStatus() string Remote() string Errors() []string } // Errors ...
// Package syscallx provides wrappers that make syscalls on various // platforms more interoperable. // // The API intentionally omits the OS X-specific position and option // arguments for extended attribute calls. // // Not having position means it might not be useful for accessing the // resource fork. If that's nee...
package websocket_route import ( "github.com/changx123/websocket-sync" "net/http" ) var upgrader = websocket.Upgrader{ ReadBufferSize: 1024, WriteBufferSize: 1024, CheckOrigin: SetWebSocketOrigin, } func SetWebSocketOrigin(_ *http.Request) bool { return true } func NewConn(w http.ResponseWriter,r *http.R...
package cmd import ( "fmt" "os/user" "path" "github.com/cinus-ue/securekit/common/pathutil" "github.com/cinus-ue/securekit/internal/simplessh" "github.com/cinus-ue/securekit/internal/webapps/webssh" "github.com/cinus-ue/securekit/termui" "github.com/cinus-ue/securekit/termui/prompt" "github.com/urfave/cli/v2...
package token import ( "camp/week2/api" "github.com/globalsign/mgo/bson" ) func (t *TokenModel) Get(token string) (tokenObj *api.Token, err error) { tokenObj = &api.Token{} c := t.GetC() defer c.Database.Session.Close() err = c.Find(bson.M{"token": token}).One(&tokenObj) return }
package controllers import ( "SocialWebsite/config" "SocialWebsite/models" "bytes" "context" "encoding/base64" "go.mongodb.org/mongo-driver/bson" "log" "net/http" "sort" "time" ) //Serves the upload post page func YourPosts(w http.ResponseWriter, r *http.Request) { //If not logged in //Then redirect to lo...
package mat import ( "github.com/stretchr/testify/assert" "testing" ) func TestSplitPerfectCube(t *testing.T) { box := NewBoundingBoxF(-1, -4, -5, 9, 6, 5) left, right := SplitBounds(box) assert.Equal(t, NewPoint(-1, -4, -5), left.Min) assert.Equal(t, NewPoint(4, 6, 5), left.Max) assert.Equal(t, NewPoint(4, -...
package util import ( "encoding/binary" "math" ) type PacketWriter struct { data []byte pos int } func NewPacketWriter(size int) *PacketWriter { pw := &PacketWriter{make([]byte, 2 + size), 0} pw.AppendUInt16(uint16(size)) return pw } //packet without len prepended func NewPacketWriterNoLen(size int) *...
package main // Gateway : 网关服务器 type Gateway struct { } // NewGateway : 构造函数 func NewGateway() *Gateway { return &Gateway{} } // Start : 启动 func (gateway *Gateway) Start() bool { Ctx.ServerForClient.RegisterSessType(User{}) return true } // Close : 关闭 func (gateway *Gateway) Close() { }
//File : main.go //Author: 燕人Lee&骚气又迷人的反派 //Date : 2019-07-29 package main import ( mainXXX "Object/FenBuShi/All/functional/adder" "bufio" "fmt" "os" ) func main() { fmt.Println("start") try() writeFile("fib.txt") } func try() { defer fmt.Println(1) defer fmt.Println(2) fmt.Println(3) //panic("error oc...
package client import ( "encoding/json" "fmt" "github.com/wish/ctl/cmd/util/config" "github.com/wish/ctl/pkg/client/types" ) // FindAdhocJob loops through all valid contexts and returns the first active job found func (c *Client) FindAdhocJob(appName string, options ListOptions) (*types.JobDiscovery, error) { /...
//+build !windows package rlimit import ( "github.com/juju/errors" "golang.org/x/sys/unix" ) func Set() (err error) { rLimit := unix.Rlimit{} err = unix.Getrlimit(unix.RLIMIT_NOFILE, &rLimit) if err != nil { err = errors.Annotate(err, "Cannot get rlimit") return } rLimit.Cur = rLimit.Max err = unix.Setr...
package spawner import ( "github.com/dollarshaveclub/acyl/pkg/models" "golang.org/x/net/context" ) // EnvironmentSpawner describes an object capable of managing environments type EnvironmentSpawner interface { Create(context.Context, models.RepoRevisionData) (string, error) Update(context.Context, models.RepoRevi...
/* Copyright 2018 The HAWQ Team. */ package myresource import ( "log" "github.com/kubernetes-incubator/apiserver-builder/pkg/builders" "fmt" "time" "github.com/golang/glog" "github.com/hawq-cn/apiserver-example/pkg/apis/core/v1alpha1" listers "github.com/hawq-cn/apiserver-example/pkg/client/listers_gener...
package main import ( "encoding/json" "fmt" "github.com/sirupsen/logrus" "log" "os" "time" "github.com/bettercap/gatt" "github.com/bettercap/gatt/examples/option" "github.com/urfave/cli" "k3s_iot_demo" "k8s.io/klog" ) var ( Version = "v0.0.0-dev" GitCommit = "HEAD" ) func main() { app := cli.NewApp(...
package main import "fmt" func main() { name := "Todd" fmt.Println(name) // Todd changeMe(&name) fmt.Println(name) // Rocky } func changeMe(z *string) { *z = "Rocky" }
package functions import ( "encoding/json" "net/http" ) func FunctionIndex() (functions []string, err error) { r, err := http.Get("https://raw.githubusercontent.com/webmachinedev/functions/main/index.json") if err != nil { return nil, err } var functionids []string json.NewDecoder(r.Body).Decode(&functionid...
package easysql_test import ( "fmt" "os" "github.com/ironzhang/golang/easysql" ) type Account struct { Id int64 Name string Password string Status int8 } //INSERT INTO tb_account (name, password, status) VALUES("iron", "123456", 1); func ExampleInsertQuery1() { esql := easysql.InsertInto("tb_acc...
package azuretexttospeech // AudioOutput defines supported audio formats // Each incorporates a bitrate and encoding type. Azure Speech Service supports 24-KHz, 16-KHz, and 8-KHz audio outputs // See https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-apis#audio-outputs type AudioOutput strin...
package main import "fmt" func f1(a *int){ *a = 0 } func f2(a int){ a = 10 } func main(){ i := 5 f2(i) fmt.Println(i) f1(&i) fmt.Println(i) }
package shop type amazon struct { } type Inventory interface { }
package dictator import ( "io" "log" ) type Logger struct { Error *log.Logger Debug *log.Logger } func NewLogger(errWriter, debugWriter io.Writer) Logger { l := Logger{ Error: log.New(errWriter, "Error: ", log.LstdFlags|log.Lshortfile), Debug: log.New(debugWriter, "Debug: ", log.LstdFlags|log.Lshortfile), ...
package main import ( "fmt" "time" ) func Worker(chnl chan string) { time.Sleep(2500 * time.Millisecond) chnl <- "Worker done!" } func main() { chnl := make(chan string) go Worker(chnl) for { time.Sleep(500 * time.Millisecond) select { case val := <-chnl: fmt.Println("Get value:", val) return de...
package builtinfunctions import "github.com/kasworld/nonkey/interpreter/object" // The built-in functions / standard-library methods are stored here. var BuiltinFunctions = map[string]*object.Builtin{} // Register registers a built-in function. This is used to register // our "standard library" functions. func Regi...
package download import ( "archive/zip" "fmt" "io" "io/ioutil" "net/http" "net/url" "os" "path/filepath" "strings" "github.com/Sirupsen/logrus" "github.com/Stratoscale/logserver/source" "github.com/bluele/gcache" ) var log = logrus.WithField("pkg", "router") func New(root string, sources source.Sources,...
package image type Image struct { ID int `json:"id"` Path string `json:"path"` Type string `json:"type"` PathCode string `json:"pathCode"` } func New() Image { return Image{} }
package main import ( "github.com/nsf/termbox-go" "io/ioutil" "strconv" "strings" ) var ( MODE_DEFAULT = &defaultMode{} MODE_COMMAND = &commandMode{} MODE_CONFIRM = &confirmMode{} MODE_FILE_INPUT = &fileInputMode{} ) const ( MARKS_MODE_FAIL_LOCKED = "Can't enter mark mode on a cell that's l...
package main import ( "bufio" "fmt" "log" "os" "strconv" "sync" "github.com/fatih/color" skynet "github.com/autisticvegan/go-skynet" ) /* * This program does mass upload/download using sia skynet * Use it to test banning bad IPs, load balancing, rate-limiting, whatever * * Example usage * stress siasky...
package bgControllers import ( "github.com/astaxie/beego" "strconv" "fmt" "GiantTech/models" "github.com/ying32/alidayu" "GiantTech/controllers/tools" "encoding/json" ) type BgProjectOperationController struct { beego.Controller } func (this *BgProjectOperationController) Prepare() { s := this.StartSession(...
package leetcode import "testing" func TestSmallestRangeI(t *testing.T) { if smallestRangeI([]int{1}, 0) != 0 { t.Fatal() } if smallestRangeI([]int{0, 10}, 2) != 6 { t.Fatal() } if smallestRangeI([]int{1, 3, 6}, 3) != 0 { t.Fatal() } }
package prome import ( "math" "regexp" "strconv" "strings" "github.com/golang/protobuf/proto" log "github.com/sirupsen/logrus" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" pb "github.com/vwidjaya/barito-proto/producer" ) const ( ESClientFailedP...
/** * Definition for a Node. * type Node struct { * Val int * Children []*Node * } */ type Stack struct { Val *Node Next *Stack } func preorder(root *Node) []int { r := make([]int, 0, 10) if root == nil { return r } stack := &Stack{ Val : root, } for v...
package server import ( "time" "github.com/Sirupsen/logrus" "github.com/bryanl/dolb/dao" ) // LBState manages the states of a load balancer at creation time. type LBState struct { lbID string logger *logrus.Entry dbSession dao.Session } // Track tracks a load balancer. It sets the initial load balance...
package main import "fmt" import "time" func main() { now := time.Now() fmt.Println(now.Unix()) fmt.Println(now.UnixNano()) fmt.Println(now) fmt.Println(time.Unix(now.Unix(), 0)) fmt.Println(time.Unix(0, now.UnixNano())) }
/* Build with: go version go1.11.1 darwin/amd64 Created by Uğur "vigo" Özyılmazel on 2018-07-01. */ package main import ( "fmt" "os" "github.com/vigo/lsvirtualenvs/app" ) func main() { cmd := app.LsVirtualenvsApp() if err := cmd.Run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } }
package model import ( "culture/cloud/base/internal/support/db" "github.com/google/uuid" "gorm.io/gorm" "strings" "time" ) // 基础模型 // 所有数据模型都应该继承 PrimaryKeyID 或 DistributedPrimaryKeyID 与 Time 模型 // PrimaryKeyID 自增主键ID type PrimaryKeyID struct { ID uint64 `gorm:"primary_key;autoIncrement" json:"id"` } // Distr...
// Copyright 2016 NetApp, Inc. All Rights Reserved. package docker_driver import ( "fmt" "os" "path/filepath" "strings" "sync" "github.com/netapp/netappdvp/storage_drivers" log "github.com/Sirupsen/logrus" ) type ndvpDriver struct { m *sync.Mutex root string config storage_drivers.CommonStorageDri...
package main import ( "net" "time" "github.com/ubinte/livego/app" "github.com/ubinte/livego/av" "github.com/ubinte/livego/container/flv" "github.com/ubinte/livego/protocol/hls" "github.com/ubinte/livego/protocol/httpflv" "github.com/ubinte/livego/protocol/rtmp" log "github.com/sirupsen/logrus" ...
package controller import ( "net/http" "posthis/utils" "strconv" "github.com/gorilla/context" "github.com/gorilla/mux" ) //Handlers func GetFollows() http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { followModel := FollowModel{Model: Model{Scheme: r.URL.Scheme, Host: r.U...
package main import ( "fmt" ) func main() { fmt.Println("Howdy Hackers") }
package actor_test import ( "fmt" "sync" "time" "github.com/AsynkronIT/protoactor-go/actor" ) type setReceiveTimeoutActor struct { sync.WaitGroup } // Receive is the default message handler when an actor is started func (f *setReceiveTimeoutActor) Receive(context actor.Context) { switch context.Message().(typ...
package helper import ( "log" "net/http" "net/url" "os" "strings" ) func ExtractRecordingUrl(r *http.Request) string { return r.FormValue("RecordingUrl") } func RecordingUrlExist(r *http.Request) bool { if ExtractRecordingUrl(r) == "" { return false } return true } func getEmergencyContacts() string { r...
/* Example of interfacing between Go and C programs. Copyright (C) 2017, Lefteris Zafiris <zaf@fastmail.com> This program is free software, distributed under the terms of the MIT License. See the LICENSE file at the top of the source tree. */ // Package should be called main and 'C' should always be imported pack...