text
stringlengths
11
4.05M
package deadcode import ( "testing" "github.com/stephens2424/php/ast" "github.com/stephens2424/php/parser" ) func TestDeadFunctions(t *testing.T) { src := `<?php $var1 = "a"; function simple() { $var2 = "b"; $var3 = "c"; } class fizz { const buzz = "fizzbuzz"; static function notsimple() { $var4...
// Copyright 2018 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 infrastructure import ( interfaces "github.com/dev-jpnobrega/api-rest/src/domain/contract/interface" factory "github.com/dev-jpnobrega/api-rest/src/infrastructure/factory" handler "github.com/dev-jpnobrega/api-rest/src/infrastructure/http" echo "github.com/labstack/echo/v4" ) func Adapter(command interfac...
package codes import ( "net/http" "net/http/httptest" "testing" "github.com/go-chi/chi/v5" "github.com/jrapoport/gothic/core/codes" "github.com/jrapoport/gothic/core/context" "github.com/jrapoport/gothic/hosts/rest" "github.com/jrapoport/gothic/models/code" "github.com/jrapoport/gothic/models/types" "github...
package apns import ( "fmt" ) type NotificationError struct { Command uint8 Status uint8 Identifier uint32 OtherError error } // Make a new NotificationError with error response p and error err. // If send in a 6-length p and non-nil err sametime, will ignore err and parse p. func NewNotificationError(p...
package cmd // resetFlags reset all flags back to the default values func resetFlags() { rootFlags.json = false rootFlags.quiet = false }
package main type XMainHook struct { } //程序启动后调用 func (p *XMainHook) OnStartup() (err error) { return } //加载配置文件之前调用 func (p *XMainHook) OnBeforeLoadConfig() (err error) { return } //加载配置文件之后,服务正式运行之前调用 func (p *XMainHook) OnAfterLoadConfig() (err error) { return } //热加载配置之前调用 func (p *XMainHook) OnBeforeReload...
package main import "fmt" /* !!! main article: http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html http://programm.ws/page.php?id=663 http://ru.bmstu.wiki/%D0%97%D0%B5%D1%80%D0%BA%D0%B0%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9_%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%87%D0%BD%D1%8B%D0%B9_%D0%B0%D0%BB%D0%B3%D0%BE%D1%80%...
// Copyright 2019 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package graphics import ( "context" "time" "chromiumos/tast/local/crostini" "chromiumos/tast/local/graphics/glbench" "chromiumos/tast/testing" ) // Tast framework req...
package main import ( "fmt" "os" "github.com/unixpickle/gocube" ) func main() { sc, err := gocube.InputStickerCube() if err != nil { fmt.Println("Failed to read stickers:", err) os.Exit(1) } cc, err := sc.CubieCube() if err != nil { fmt.Println("Invalid stickers:", err) os.Exit(1) } fmt.Println("S...
package main import ( "fmt" "math/rand" "time" ) func getLuckyNum(c chan<- int) { fmt.Println("...") // 占いにかかる時間はランダム rand.Seed(time.Now().Unix()) time.Sleep(time.Duration(rand.Intn(3000)) * time.Millisecond) num := rand.Intn(10) c <- num } func main() { fmt.Println("what is today's lucky number?") c :...
package main import ( "bytes" "fmt" "net/http" "os" "os/exec" "strconv" "strings" "github.com/PuerkitoBio/goquery" "github.com/bchadwic/gh-graph/pkg/color" "github.com/bchadwic/gh-graph/pkg/stats" lg "github.com/charmbracelet/lipgloss" "github.com/cli/cli/git" "github.com/spf13/cobra" ) func main() { g...
package service import ( "github.com/bitschain/panicgo/model" "github.com/manveru/faker" "github.com/stretchr/testify/assert" "testing" ) func TestPanicService_CreateNewUser(t *testing.T) { s := GetTestService() fakeUser, _ := faker.New("en") data := model.UserRegister{Name: fakeUser.Name(), Email: fakeUser.E...
package models import ( "context" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" ) // 配送方式数据格式 type Delivery struct { DeliveryId int64 `json:"delivery_id" bson:"delivery_id"` //配送方式id 这个id由前端生成 ComId int64 `json:"com_id" bson:"comid"` //公司id Delive...
// Copyright 2017 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package chrome import ( "context" "chromiumos/tast/errors" "chromiumos/tast/local/chrome/internal/extension" ) // ComputeExtensionID computes the 32-character ID that C...
package events // Alert simple alert struct type Alert struct { ResourceID string `json:"resourceId"` AlertRuleName string `json:"alertRuleName"` AccountName string `json:"accountName"` ResourceRegionID string `json:"resourceRegionId"` CloudType string `json:"cloudType"` AlertID str...
package main import ( "fmt" "sort" ) func main() { m := map[int]string{} m[1] = "ok" m[2] = "no" fmt.Println(m) fmt.Println(m[1]) delete(m, 2) fmt.Println(m[2]) mm := map[int]map[int]string{} mm[1] = map[int]string{} a, ok := mm[2][1] //map一定要做检查和MAKE 否则会发生运行时错误 if !ok { mm[2] = map[int]string{} } ...
package opsgenie import ( "flag" "testing" "github.com/codegangsta/cli" ) func TestMandatoryFlagsNotProvided(t *testing.T) { flagsTestHelper(t, mandatoryFlags, createCli("", "", "")) } func TestMandatoryFlagsNameNotProvided(t *testing.T) { flagsTestHelper(t, mandatoryFlags, createCli("key", "", "")) } func Te...
package vault_test import ( "bytes" "context" "fmt" "io/ioutil" "net/http" "testing" "github.com/ecadlabs/signatory/pkg/config" "github.com/ecadlabs/signatory/pkg/vault" ) type HandleFunc func(req *http.Request) (*http.Response, error) type MockClient struct { DoFunc HandleFunc } func (m *MockClient) Do(r...
package main //1822. 数组元素积的符号 //已知函数signFunc(x) 将会根据 x 的正负返回特定值: // //如果 x 是正数,返回 1 。 //如果 x 是负数,返回 -1 。 //如果 x 是等于 0 ,返回 0 。 //给你一个整数数组 nums 。令 product 为数组 nums 中所有元素值的乘积。 // //返回 signFunc(product) 。 // // // //示例 1: // //输入:nums = [-1,-2,-3,-4,3,2,1] //输出:1 //解释:数组中所有值的乘积是 144 ,且 signFunc(144) = 1 //示例 2: // //输入:nu...
package tracer import "github.com/nkbai/tgo/log" type tracingPoints struct { startAddressList []uint64 endAddressList []uint64 goRoutinesInside []int64 } // IsStartAddress returns true if the addr is same as the start address. func (p *tracingPoints) IsStartAddress(addr uint64) bool { for _, startAddr := range...
// 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" "io/ioutil" "os" ) func main() { raw, err := ioutil.ReadFile(os.Args[1]) if err != nil { fmt.Println(err) os.Exit(1) } var floor = 0 var position = 0 var entered = false for _, r := range string(raw) { if !entered { position += 1 } switch r { case '(': floor +...
package gosi import ( "encoding/json" "fmt" "net" "time" "github.com/shirou/gopsutil/v3/host" psnet "github.com/shirou/gopsutil/v3/net" ) //const timeformat = "2006/01/02 15:04:05" const timeformat = "2006/01/02 15:04:05.000000000" type IpAddr struct { Name string `json:"name"` IpAddr string `json:"ipaddr...
package model import ( "go_crud/database" entity "go_crud/entities" "html" "strings" ) type User entity.User func (user *User) FindAll() (*[]User, error) { var users []User err := database.Connector.Joins("JOIN roles ON roles.id=users.role_id").Preload("roles").Find(&users).Error if err != nil {...
package api import ( "github.com/mickaelmagniez/elastic-alert/api/router" ) func Run() { router.Load() }
package main import ( "fmt" "log" "sync" "time" "zk" ) var ( TESTIP = []string{ //"172.19.32.16", "192.168.56.101", } ) func main() { log.Println("testing") conn := zk.New() err := conn.Connect(TESTIP) if err != nil { log.Println(err) } t1 := time.Now() wg := sync.WaitGro...
package datagrid import ( "fmt" // used for outputting to the terminal //"time" // used for pausing, measuring duration, etc //"math/rand" // random number generator //"math" //"sync" ) // Import internal packages import ( cfg "flood_go/config" ) // Import external packages import ( "github.com/...
// 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 lacros import ( "context" "time" lacroscommon "chromiumos/tast/common/cros/lacros" "chromiumos/tast/ctxutil" "chromiumos/tast/remote/bundles/cros/lacros/provis...
// Copyright 2019 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 tree import ( "github.com/jagandecapri/vision/utils" ) type Grid struct{ Store map[Range]*Unit ClusterContainer point_unit_map map[int]Range minDensePoints int minClusterPoints int cluster_id_counter int listDenseUnits map[Range]*Unit tmpUnitToCluster map[Range]*Unit } f...
package ksql import ( "fmt" "log" "testing" "github.com/Mongey/terraform-provider-kafka/kafka" r "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) func TestBasicStream(t *testing.T) { err := createTopic("vault") if err != nil { log.Printf("[DEBUG] Could not creat...
package wsServer import ( "log" "net/http" "sync" ) const ( sendChanBufferSize = 64 ) var ( globPeers sync.Map = sync.Map{} ) func Upgrade(w http.ResponseWriter, r *http.Request) { peer, err := CreatePeer(w, r) if err != nil { log.Printf("[ERROR] upgrade: %v\n", err) return } go peer.readPump() peer....
// Copyright 2021 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 domain import ( "context" "fmt" "sync" categoryDomain "flamingo.me/flamingo-commerce/v3/category/domain" product "flamingo.me/flamingo-commerce/v3/product/domain" "flamingo.me/flamingo/v3/framework/flamingo" "flamingo.me/flamingo/v3/framework/opencensus" "go.opencensus.io/stats" "go.opencensus.io/sta...
package rsscombine import "fmt" import "github.com/mmcdole/gofeed" import "github.com/gorilla/feeds" import "sort" import "time" import "net/http" import "log" import "github.com/spf13/viper" import "io/ioutil" import "mvdan.cc/xurls" import "strings" func getUrlsFromFeedsUrl(feeds_url string) []string { log.Printf...
package wechat import ( "crypto/md5" "crypto/sha1" "encoding/hex" "math/rand" "sort" "strconv" "strings" "text/template" "time" ) // 设置时间戳 func StampString() string { ts64 := time.Now().Unix() return strconv.FormatInt(ts64, 10) } // 随机字符串 func CreateNonceStr(length int) string { str := "0123456789abcdefg...
package node type Resp struct { Key Key Label ID Value []byte } func (r *Resp) equals(o *Resp) bool { return r.Key.Key == o.Key.Key && r.Label.eq(o.Label) && string(r.Value) == string(o.Value) }
package repository import ( "database/sql" "ehsan_esmaeili/model" "fmt" ) type TransactionRepository interface { Insert(user *model.Transaction) (use *model.GetaUser, err error ) } type TransactionRepositorySqlServer struct { db *sql.DB //64b table string //4b //68 } func NewTransactionRepositorySqlServ...
package svrcfg import ( "fmt" "os" "github.com/go-ini/ini" ) const ( configFile = "config.ini" ) type config struct { AppMode string // [server] PidFile string UseTLS bool CertPath string CertKeyPath string ServerAddr string ServerPort int HostOverride string } // Config is the exp...
package gitlabClient import ( "fmt" "github.com/xanzy/go-gitlab" ) func (git *GitLab) GetMilestoneByGroupName(pid gitlab.Group, milestoune string) (*gitlab.GroupMilestone, error) { opt := gitlab.ListGroupMilestonesOptions{ Search: milestoune, ListOptions: gitlab.ListOptions{ PerPage: 100, Page: 1, }...
package log import ( "io" "os" "sync" ) type Handler interface { Handle(lr LogRecord) SetLogLevel(l LogLevel) LogLevel() LogLevel Formatter() LogFormatter SetFormatter(lf LogFormatter) io.Closer } type BaseHandler struct { minLevel LogLevel fmt LogFormatter } func (h *BaseHandler) LogLevel() LogLeve...
package online import ( "bufio" "hash/fnv" "os" "strconv" "strings" ) func Hash(s string, dim int) int { h := fnv.New32a() h.Write([]byte(s)) return int(h.Sum32()) % dim } func FileToHash(in string, out string, length int, ads int, ignore []int, dim int) error { fpIn, err := os.Open(in) if err != nil { r...
package connect import ( "context" "fmt" "io/ioutil" "os" "github.com/fatih/color" "github.com/porter-dev/porter/cli/cmd/api" "github.com/porter-dev/porter/cli/cmd/utils" ) // GCR creates a GCR integration func GCR( client *api.Client, projectID uint, ) (uint, error) { // if project ID is 0, ask the user t...
package notify import ( pb "github.com/LILILIhuahuahua/ustc_tencent_game/api/proto" "github.com/LILILIhuahuahua/ustc_tencent_game/framework" "github.com/LILILIhuahuahua/ustc_tencent_game/framework/event" "github.com/LILILIhuahuahua/ustc_tencent_game/internal/event/info" ) type EnterGameNotify struct { framework....
package controllers import ( "testing" "todo-app/models/connection" ) func TestCretaeTask(t *testing.T) { connection.InitConnection() defer connection.DB.Close() } func TestGetTasks(t *testing.T) { connection.InitConnection() defer connection.DB.Close() }
package main import ( "fmt" "math/rand" "time" ) func main() { var a [10]int var b [10]int rand.Seed(time.Now().UnixNano()) for i := 0; i < len(a); i++ { a[i] = rand.Intn(100) } fmt.Println(a) //倒序显示 for i := 0; i < len(a); i++ { b[i] = a[len(a)-i-1] } fmt.Println(b) //平均值 sum := 0.0 for _, v :=...
package main import ( "fmt" "strings" ) type Company map[string][]string func addPersonToDepartment(company map[string][]string, department string, person string) { company[department] = append(company[department], person) } func showPeopleInDeparment(company map[string][]string, department string) { peopleInDe...
package main import ( "errors" "fmt" "reflect" ) // 填充不同struct的相同字段 type Person struct { Name string `json:name` Age int `json:age` } type Student struct { Name string Age int Class string } // 填充函数,入参是接口类型和对应struct值的map func fill(x interface{}, setting map[string]interface{}) error { // 先判断传进来的x是...
package sqlite import ( "context" "database/sql" "embed" "log" "path" "path/filepath" "sync" "time" "github.com/twcclan/goback/backup" "github.com/twcclan/goback/proto" "contrib.go.opencensus.io/integrations/ocsql" _ "github.com/mattn/go-sqlite3" ) var tracedSQLiteDriver = "" func init() { var err err...
package store import "sync" // threadSafeStore is a wrapper around golang native // hashmap // this wrapper helps adding mutex to the map type threadSafeStore struct { store map[string]map[string]interface{} sync.RWMutex } // newThreadSafeStore creates a new threadSafeStore // and a returns a pointer to it func ne...
package objectstorage import ( "sync" ) type PartitionsManager struct { childPartitions map[string]*PartitionsManager retainCounter int mutex sync.RWMutex } func NewPartitionsManager() *PartitionsManager { return &PartitionsManager{ childPartitions: make(map[string]*PartitionsManager), } } func ...
package schemastore import ( parser "github.com/daischio/daischeme/codemodel/schemaparser" //"fmt" "github.com/daischio/daischeme/codemodel/util" ) type SchemaStore struct { ModelName string schema *parser.Scheme } // General named schema type NamedSchema struct { Name string // schema name *parser.S...
// 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 memio import ( "io" "unicode/utf8" ) // Buffer grants a byte slice very straightforward IO methods. type Buffer []byte // Read satisfies the io.Reader interface func (s *Buffer) Read(p []byte) (int, error) { if len(p) == 0 { return 0, nil } if len(*s) == 0 { return 0, io.EOF } n := copy(p, *s) *s...
// Copyright (C) 2018 Satoshi Konno. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package echonet import ( "bytes" "fmt" "github.com/cybergarage/uecho-go/net/echonet/encoding" "github.com/cybergarage/uecho-go/net/echonet/protocol" ) ...
package models // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command import ( "bytes" "encoding/json" strfmt "github.com/go-openapi/strfmt" "github.com/go-openapi/errors" ) /*Type1 type1 swagger:model Type1 */ type Type1 struct { ...
package models import ( "github.com/labstack/echo" "gopkg.in/mgo.v2/bson" "exons/utils" ) type exonsunity struct { ID bson.ObjectId `json:"_id" bson:"_id,omitempty"` Title string `json:"title"` Description string `json:"description"` } func (c *exonsunity) BindWithContext(ctx echo.Context) { err := ctx.Bind(...
package xhtml5_test import ( . "github.com/bytesparadise/libasciidoc/testsupport" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("quoted strings", func() { Context("quoted strings", func() { It("bold content alone", func() { source := "*bold content*" expected := `<div clas...
// Copyright 2020 cloudeng llc. All rights reserved. // Use of this source code is governed by the Apache-2.0 // license that can be found in the LICENSE file. // Package filewalk provides support for concurrent traversal of file system // directories and files. It can traverse any filesytem that implements // the Fil...
/** * * By So http://sooo.site * ----- * Don't panic. * ----- * */ package e // GetMsg 获取错误信息 func GetMsg(code int) string { if msg, ok := Msg[code]; ok { return msg } return Msg[Fail] }
package main import ( "fmt" "log" "os" "runtime" "sort" "text/tabwriter" "time" "github.com/azmodb/exp/azmo" "github.com/azmodb/exp/azmo/build" "golang.org/x/net/context" ) type command struct { Run func(ctx context.Context, d *dialer, args []string) error Args string Help string Short string } ty...
package main /* sync/atomic 实现原理 大致是向CPU发送对某一个块内存的LOCK信号,然后就将此内存块加锁,从而保证了内存块操作的原子性 1. 可以在并发的场景下对变量进行非侵入式的操作,保证并发安全 2. 解决的典型问题就是 i++和CAS(Compare-and-Swap)的线程安全问题 */ import ( "fmt" "sync" "sync/atomic" "time" ) func main() { test1() //test2() } //count++ 并发不安全 func test1() { var wg sync.WaitGroup c...
package main import ( "crypto/md5" "encoding/base64" "fmt" "io" "os" fp "path/filepath" "strings" "time" "github.com/codegangsta/cli" ) var vpnOps []cli.Command func init() { vpnIdFlag := cli.StringFlag{ Name: "id, i", Usage: "ID of the VPN.", } vpnOps = []cli.Command{ { Name: "vpn", ...
package ravendb import ( "net/http" "strconv" ) var _ IMaintenanceOperation = &GetIndexesOperation{} type GetIndexesOperation struct { _start int _pageSize int Command *GetIndexesCommand } func NewGetIndexesOperation(_start int, _pageSize int) *GetIndexesOperation { return &GetIndexesOperation{ _start: ...
package main import ( "encoding/json" "fmt" ) /* 1.channel为nil,读写都会阻塞 2.结构体访问控制,结构体中的属性大写,外部才能访问 */ func main() { chanIssue() jsonToStruct() } func chanIssue() { //未分配内存,ch为nil var ch chan int select { case v, ok := <-ch: println(v, ok) default: println("default") } } type People struct { Name str...
package problem0205 func isIsomorphic(s string, t string) bool { m1 := make(map[byte]byte, len(s)) m2 := make(map[byte]byte, len(t)) for i := 0; i < len(s); i++ { if _, ok := m1[s[i]]; ok { if m1[s[i]] != t[i] { return false } } m1[s[i]] = t[i] if _, ok := m2[t[i]]; ok { if m2[t[i]] != s[i] {...
package main import "testing" func TestTranslateString(t *testing.T) { check := map[string]string{ "a4bc2d5e": "aaaabccddddde", "abcd": "abcd", "qwe\\5": "qwe\\\\\\\\\\", } for testString, correctResult := range check { letTest, err := translateString(testString) if err != nil { t.Fatalf("Error...
package main import "fmt" // the interface bot defines that the implementor must have a function // getGreeting type bot interface { getGreeting(string) string getBotVersion() string } type englishBot struct { version string } type spanishBot struct { version string } func main() { eb := englishBot{version: "1...
package main import ( "fmt" "github.com/jacobsa/go-serial/serial" "github.com/marcinbor85/gohex" "io" "net" "os" "strconv" "strings" "time" ) var ( debugSpeed uint = 57600 // console serial speed ) // *** Debug Interfaces *** // These connect to the debug interface of the target system // A servicer is ru...
package types import ( "io" comm "github.com/zhaohaijun/matrixchain/common" "github.com/zhaohaijun/matrixchain/p2pserver/common" ) type BlocksReq struct { HeaderHashCount uint8 HashStart comm.Uint256 HashStop comm.Uint256 } //Serialize message payload func (this *BlocksReq) Serialization(sink *co...
package traefik import ( "github.com/layer5io/meshery-adapter-library/adapter" "github.com/layer5io/meshery-adapter-library/status" mesherykube "github.com/layer5io/meshkit/utils/kubernetes" ) func (mesh *Mesh) installSampleApp(namespace string, del bool, templates []adapter.Template) (string, error) { st := sta...
package dynatrace import ( "encoding/json" "fmt" "strconv" ) const entitiesPath = "/api/v2/entities" // EntitiesResponse represents the response from Dynatrace entities endpoints type EntitiesResponse struct { TotalCount int `json:"totalCount"` PageSize int `json:"pageSize"` NextPageKey string ...
package handler import ( "log" "net/http" "github.com/sparcs-home-go/internal/app/configure" "github.com/sparcs-home-go/internal/app/service" ) // SSOLogin : login thr sso func SSOLogin(w http.ResponseWriter, r *http.Request) { session := configure.GetSession(r) if auth, ok := session.Values["authenticated"].(...
package api import ( "k8s.io/kubernetes/pkg/api/meta" "k8s.io/kubernetes/pkg/api/unversioned" "k8s.io/kubernetes/pkg/labels" "k8s.io/kubernetes/pkg/runtime" ) var accessor = meta.NewAccessor() func GetMatcher(selector ClusterResourceQuotaSelector) (func(obj runtime.Object) (bool, error), error) { var labelSelec...
package lantern_cache import ( "encoding/binary" ) /* ┌───────────────────┐ │ entry marshal │ ├─────┬─────┬─────┬─┴───┬─────┐ │ 8 │ 2 │ 2 │ n │ m │ │ │ │ │ │ │ ├─────┼─────┼─────┼─────┼─────┤ │ ts │ key │ val │ key │ val │ │ │size │size │ │ │ └─────┴─────┴─────┴─────┴──...
package api import "time" type Project struct { Name string `json:"name"` TotalTime time.Duration `json:"totalTime"` } type ProjectsGetResponse struct { Projects []Project `json:"projects"` }
package jvmstack import "jean/rtda/heap" func NewShimFrame(thread *Thread, ops *OperandStack) *Frame { return &Frame{ thread: thread, method: heap.ShimReturnMethod(), operandStack: ops, } }
package main import fmt "fmt" // reverse reverses the contents of s in place func reverse(s []int) { for i := 0; i < len(s)/2; i++ { s[i], s[len(s)-1-i] = s[len(s)-1-i], s[i] } } func main() { s0 := []int{1, 2, 3} s1 := []int{1, 2, 3, 4, 5} s2 := []int{99, 55, 33, 00, 11, 4, 5, 6, 7} fmt.Println(s0, s1, s2) ...
package draw import ( "fmt" "hello-again-go/config" "image" "github.com/fogleman/gg" ) // Drawer interface type Drawer interface { DrawText(text string) (image.Image, error) } // GGDrawer implements Drawer interface type GGDrawer struct { imgWidth int imgHeight int } var _ Drawer = (*GGDrawer)(nil) // New...
package Nth_Digit import "strconv" func findNthDigit(n int) int { charSize, baseNum, period := 1, 9, 1 for n > charSize*baseNum*period { n -= charSize * baseNum * period charSize++ period *= 10 } return int(strconv.Itoa(period + (n-1)/charSize)[(n-1)%charSize] - '0') }
package app import ( "fmt" ) const ( errRunnerExist = "runner exist. Received: %s" ) type Config struct { Name string } type App struct { runners []*Runner Name string } //New create new app instance func New(c Config) *App { return &App{ Name: c.Name, } } func (a *App) Service(runs ...Runner) error ...
package page import ( "database/sql" "github.com/Miniand/venditio/asset" "github.com/Miniand/venditio/core" "github.com/Miniand/venditio/persist" "github.com/Miniand/venditio/template" "github.com/Miniand/venditio/web" "github.com/gorilla/mux" "net/http" ) func Register(v *core.Venditio) { registerSchema(v) ...
package canary import ( "fmt" "github.com/Shopify/sarama" "github.com/mailgun/oxy/utils" "github.com/mailgun/vulcand/Godeps/_workspace/src/github.com/codegangsta/cli" "github.com/mailgun/vulcand/plugin" "github.com/satori/go.uuid" "io" "log" "time" "encoding/json" "net/http" ) const Type = "canary" ...
package model import "github.com/dgrijalva/jwt-go" type User struct { ID int `json:"id" validate:"numeric,gte=0"` Username string `json:"username" validate:"required,min=3,max=32"` Password string `json:"password,omitempty"` //todo better password } type UserToken struct { UserID string `json:"id"` U...
package models // IstioConfigList istioConfigList // // This type is used for returning a response of IstioConfigList // // swagger:model IstioConfigList type IstioConfigList struct { // The namespace of istioConfiglist // // required: true Namespace Namespace `json:"namespace"` Gateways ...
package main import "sort" //1051. 高度检查器 //学校打算为全体学生拍一张年度纪念照。根据要求,学生需要按照 非递减 的高度顺序排成一行。 // //排序后的高度情况用整数数组 expected 表示,其中 expected[i] 是预计排在这一行中第 i 位的学生的高度(下标从 0 开始)。 // //给你一个整数数组 heights ,表示 当前学生站位 的高度情况。heights[i] 是这一行中第 i 位学生的高度(下标从 0 开始)。 // //返回满足 heights[i] != expected[i] 的 下标数量 。 // // // //示例: // //输入:heights...
package gostat import ( "fmt" "math" "math/rand" "testing" ) func TestDump(t *testing.T) { data := []int{2, 5, 4, 7, 1, 6, 1, 4, 4, 4, 2, -20, 40, -50, 100, -70} fmt.Println("Input is : ", data) s := NewStat(10) // fmt.Println(s) for _, i := range data { s.Add(i) // fmt.Println(s) } fmt.Println(s) } ...
//Package game is the core of the game. package game import ( "time" "github.com/go-gl/glfw/v3.1/glfw" ) type BaseEngine struct { run bool window *glfw.Window } //UpdateState is an interface that means that the object is updatable. This is //necesary for a Engine substruct implementation type UpdateState int...
package main import ( "fmt" ) func main() { fmt.Println("OK Let's GO!") //fmt.Printf("Hello, 世界\n") }
package configuration type Configurations struct { Configs []Configuration `json:"configurations"` } // GetFirst retrieves the first configuration from the Configurations object. // If the length Configurations object's Configs is less than 1 it returns an // uninitialized struct. func (cs Configurations) GetFirst()...
package db import ( "errors" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" "sort" "strings" "time" ) type MongoDB struct { session *mgo.Session } type mongoUser struct { GoogleId string `bson:"google_id"` UserName string `bson:"username"` } type mongoTopic struct { Id bson.ObjectId `bson:"_id"` Name ...
// Copyright (c) 2017 Kuguar <licenses@kuguar.io> Author: Adrian P.K. <apk@kuguar.io> // // MIT License // // 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 //...
package main import ( "fmt" "github.com/spf13/cobra" "os" ) var rootCmd = &cobra.Command{ Use: "decoration", Short: "Execute a program and add prefix suffix and color to its log output", RunE: func(cmd *cobra.Command, args []string) error { return runCommand() }, } var flags struct{ program string prefi...
package version import ( "encoding/hex" "fmt" "io/ioutil" "strings" "sync" "github.com/google/logger" "golang.org/x/crypto/blake2b" ) const rootDir = "./static" type FileSums map[string]string var StaticSums FileSums func init() { ch := make(chan File, 1) wg := &sync.WaitGroup{} wg.Add(1) go hashFiles...
package common const AzcopyVersion = "10.0.0-Preview" const UserAgent = "AzCopy/v" + AzcopyVersion
package ukpolice import ( "context" "time" ) // StopAndSearchService handles communication with the stop and search related // method of the data.police.uk API. type StopAndSearchService service // Search holds information relating to individual stop and searches. type Search struct { ID ...
package redis import ( "github.com/go-kratos/kratos/pkg/cache/redis" utilpaladin "way-jasy-cron/common/util/paladin" ) type Manager struct { Redis *redis.Pool } type Config struct { Redis *redis.Config } func (c *Config) Filename() string { return "redis.toml" } func New() *Manager{ c := &Config{} utilpalad...
/* Copyright 2019 The xridge kubestone contributors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to i...
package agent import ( "github.com/rancher/fleet/pkg/apis/fleet.cattle.io/v1alpha1" v1gen "github.com/rancher/fleet/pkg/generated/controllers/fleet.cattle.io/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // createBundle copies all targets from the GitRepo into TargetRestrictions. TargetRestrictions act...