text
stringlengths
11
4.05M
// Graphics project Graphics.go package Graphics import ( // "errors" "fmt" // gl "github.com/chsc/gogl/gl21" // "github.com/Jragonmiris/mathgl" "github.com/go-gl/gl/v3.2-core/gl" Image "image" "image/draw" _ "image/jpeg" _ "image/png" "os" ) type image struct { data *Image.Image height, width in...
package cf type UserContext struct { ApiUrl string Username string Password string Org string Space string LoginFlags string } func NewUserContext(apiUrl, username, password, org, space, loginFlags string) UserContext { return UserContext{ ApiUrl: apiUrl, Username: username, Password...
// 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 memory import ( "math/rand" "time" "github.com/elhamza90/lifelog/internal/domain" "github.com/elhamza90/lifelog/internal/store" ) func generateRandomTagID() domain.TagID { rand.Seed(time.Now().UnixNano()) res := rand.Intn(10000) return domain.TagID(res) } // FindTagByID searches for a tag with the gi...
package main import "fmt" func main() { dataSlice := []string{"var1", "var2"} fmt.Println(dataSlice) // Append a new value dataSlice = append(dataSlice, "new value") fmt.Println(dataSlice) // Check loops Dir to check how to iterate over Slice }
package filter import ( "S2Y/pkg/s2y/app/rest" "S2Y/pkg/s2y/app/rest/management" "github.com/emicklei/go-restful" "github.com/pkg/errors" "regexp" ) var ( ErrUnauthorizedRequest = errors.New("access token required") ) var authHeaderFormat = regexp.MustCompile("Bearer (.+)") type AuthorizationHeaderFilter stru...
/* Copyright 2021 The KodeRover 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, s...
package evaluator import ( "os" "path/filepath" "../object" ) var logFolder = "." var stdLog = object.Record{ Stoned: true, Values: map[string]object.Object{ "info": object.BuiltinFunction(func(args ...object.Object) object.Object { if err := checkArgLength("log.info", args, 1); err != nil { return er...
package handlers import ( "encoding/json" "net/http" "net/http/httptest" "reflect" "testing" ) func TestGet(t *testing.T) { w := httptest.NewRecorder() r := httptest.NewRequest(http.MethodGet, "/", nil) Get(w, r) if w.Code != http.StatusOK { t.Errorf("Expected %d, got %d", http.StatusOK, w.Code) } //...
// Package pubsub contains utilities for handling Google Cloud Pub/Sub events. package pubsub import ( "fmt" "regexp" "time" "cloud.google.com/go/functions/metadata" "cloud.google.com/go/pubsub" "github.com/GoogleCloudPlatform/functions-framework-go/internal/fftypes" ) const ( pubsubEventType = "google.pubs...
package main import ( "fmt" "unicode" ) func main() { s := "a ac d s" fmt.Println(remove(s)) } func remove(a string) string { s := []byte(a) l := len(s) if l <= 1 { return a } for i := 0; i < l-1; i++ { if unicode.IsSpace(rune(s[i])) && unicode.IsSpace(rune(s[i+1])) { copy(s[i:], s[i+1:]) l-- ...
package camo import ( "context" "hash/adler32" "io" "sync" ) // DefaultMTU TODO const DefaultMTU = 1400 const ( headerClientID = "camo-client-id" headerNoise = "camo-noise" ) const noisePadding = "BYLtpGfhBnrxe2rC7rbZ5QMHMMIjcMeThMI309QI5Zewv9OD1UNhie2ZPmIEuJDeKeQboeo5ClAwLusaKasWVLIGHkJmY3l0YP2dsoT1MyPSLq...
package libguestfs import ( log "github.com/sirupsen/logrus" "os" "os/exec" ) func SparsifyImage(image string) error { args := []string{"--in-place", "-v", "-x", image} c := exec.Command("virt-sparsify", args...) os.Setenv("LIBGUESTFS_BACKEND", "direct") o, err := c.CombinedOutput() if err != nil { log.Erro...
package models type Click struct { Link string `json:"processed"` Timestamp string `json:"timestamp"` }
package main import ( "bytes" "fmt" "log" "net/http" "regexp" "gophr.pm/gocql/gocql@3ac1aabebaf2705c6f695d4ef2c25ab6239e88b3" "gophr.pm/skeswa/gophr@035e5f373426d6fe40f9cd89a615fffedca067fe/common" "gophr.pm/skeswa/gophr@035e5f373426d6fe40f9cd89a615fffedca067fe/common/config" "gophr.pm/skeswa/gophr@035e5f373...
package middlewares import ( "github.com/julienschmidt/httprouter" ) type Middleware func(handler httprouter.Handle) httprouter.Handle func Wrap(middlewares []Middleware, handler httprouter.Handle) httprouter.Handle { for i := len(middlewares) - 1; i >= 0; i-- { handler = middlewares[i](handler) } return handl...
package encryption import ( "github.com/stretchr/testify/assert" "testing" ) var aes = NewAESEncryptionService([]byte("1111111111111111")) var plainJSON = []byte(`{"type":"login","user_name":"test","ping_interval":45000,"ppks":[{"ppk_num":0,"pwd":"0","license_key":[0,0,0,0,0,0]}]}`) func TestAesEncryptionService_E...
package log import ( "testing" ) func TestSetLevel(t *testing.T) { t.Run("infoLevel", func(t *testing.T) { SetLevel(InfoLevel) Info("this is a info") Error("this is a error") }) t.Run("errorLevel", func(t *testing.T) { SetLevel(ErrorLevel) Info("this is a info") Error("this is a error") }) t.Run("di...
//go:build tools // +build tools package tools import ( // Code generators built at runtime. _ "k8s.io/kube-openapi/cmd/openapi-gen" )
package main import ( "day1/app/http2" ) func main() { http2.Start() }
package _4_Chain_of_Responsibility_Pattern import ( "testing" ) //步骤 3 //创建不同类型的记录器。赋予它们不同的错误级别,并在每个记录器中设置下一个记录器。每个记录器中的下一个记录器代表的是链的一部分。 func TestChainOfResponsibilityPattern(t *testing.T) { errorLogger := ErrorLogger{level: ERROR} fileLogger := FileLogger{level: DEBUG} consoleLogger := ConsoleLogger{level: INFO}...
package middlewares import ( "encoding/json" "fmt" "net/http" "time" "github.com/dgrijalva/jwt-go" "github.com/gin-gonic/gin" "github.com/ramailh/backend/fetch/props" ) const ( tokenExp = 1 * time.Hour ) type claims struct { Name string `json:"name"` Phone string `json:"phone"` Role string ...
package api import ( "log" "golang.org/x/net/context" ) //server represents the gRPC type Server struct { } func (s *Server) SayHello(ctx context.Context, in *PingMessage) (*PingMessage, error) { log.Printf("Menerima pesan %s", in.Greeting) return &PingMessage{Greeting: "bar"}, nil }
package fetcher import ( "github.com/stretchr/testify/assert" "testing" ) func TestNewFetcher(t *testing.T) { const n = 2 //given a fetcher with capacity of n NewFetcher(n) fetcher := singleton //count of elements in the full fetcher must be n fillTheChan() assert.Len(t, singleton.sem, n) //call the cons...
// SPDX-License-Identifier: GPL-2.0 package main import ( "flag" "fmt" "log" "net/http" ) var addr = flag.String("addr", ":8080", "listening address") func main() { flag.Parse() db := database{ "shoes": 12.5, "socks": 8.99, } log.Fatal(http.ListenAndServe(*addr, db)) } type dollar float32 func (d dolla...
package score import "github.com/go-pg/pg/v9" type ( // Repository represents the repository for score. Repository interface { CreateScore(score *Score) error FindAllScores() (Scores, error) } // RepositoryImpl represents the repository implementation for score. RepositoryImpl struct { db *pg.DB } ) // N...
package handler_test import ( "encoding/json" "errors" "net/http" "time" "github.com/Lunchr/luncher-api/db" "github.com/Lunchr/luncher-api/db/model" . "github.com/Lunchr/luncher-api/handler" "github.com/Lunchr/luncher-api/handler/mocks" "github.com/Lunchr/luncher-api/router" "github.com/Lunchr/luncher-api/s...
/* Copyright 2021 The KodeRover 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, s...
// Copyright (C) 2018 Google 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 agreed t...
package database // Client represents all the method available for the database type Client interface { Query(string) string } type database struct{} func (db *database) Query(string) string { return "Mock response from DB" } // New returns a new instance of connection to the database func New() Client { return ...
package errutil // Func delays error string generation until the error string actually get displayed. It does this by implementing the go Error() interface for parameterless functions. // For example: funError:= errutil.Func(func() string { return "fun" }) type Func func() string // Error implements go's Error() inte...
package gui import ( "github.com/magicmonkey/go-streamdeck" "github.com/magicmonkey/go-streamdeck/buttons" ) type StopAppAction struct { StopFunc func() } func (action *StopAppAction) Pressed(btn streamdeck.Button) { mybtn := btn.(*buttons.TextButton) mybtn.SetText("BYE") action.StopFunc() }
package _091_Decode_Ways import ( "testing" "github.com/stretchr/testify/assert" ) func TestDecodeWays(t *testing.T) { ast := assert.New(t) ast.Equal(0, numDecodings("0")) ast.Equal(0, numDecodings("01")) ast.Equal(2, numDecodings("11")) ast.Equal(1, numDecodings("101")) ast.Equal(0, numDecodings("100")) a...
package main import ( . "../shared" "sync" ) func main() { Say(`All goroutines will wakeup and print "Finish waiting"`) var wg1 sync.WaitGroup var wg2 sync.WaitGroup wg1.Add(1) for i := 0; i < 3; i++ { wg2.Add(1) go func() { wg1.Wait() Say("Finish waiting") wg2.Done() }() } wg1.Done() wg2....
package cluster import ( "errors" "fmt" "sync" "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "github.com/tilt-dev/tilt/internal/controllers/apis/cluster" "github.com/tilt-dev/tilt/internal/docker" "github.com/tilt-dev/tilt/internal/k8s" "github.com/tilt-dev/tilt/pkg/a...
package bolt import ( "github.com/asdine/storm" "github.com/asdine/storm/q" fm "github.com/rjchee/dcac_filemanager" ) // ShareStore is a shareable links store. type ShareStore struct { DB *storm.DB } // Get gets a Share Link from an hash. func (s ShareStore) Get(hash string) (*fm.ShareLink, error) { var v fm.Sh...
package main import "github.com/oceanho/gw/contrib/cmder/generator" func main() { generator.Run() }
package main import ( "fmt" "html/template" "log" "os" ) var ( path = os.Getenv("NGINX_BASE") available = os.Getenv("NGINX_AVAILABLE") enabled = os.Getenv("NGINX_ENABLED") fullPath string aFile string eFile string output string ) // Nginx - Host structure type Nginx struct { HostName ...
// Package pubsub provides a library that implements the Publish and Subscribe // model. Subscriptions can subscribe to complex data patterns and data // will be published to all subscribers that fit the criteria. // // Each Subscription when subscribing will walk the underlying subscription // tree to find its place i...
package main import ( "flag" "fmt" "log" "net/http" "os" "book/ch03/mandelbrot" ) var ( addr = flag.String("address", "", "listening address") port = flag.Int("port", 8002, "listening port") ) func main() { flag.Parse() if *addr == "" { mandelbrot.Draw(os.Stdout) return } http.HandleFunc("/", func(w...
package models import ( "bytes" "errors" "fmt" "github.com/msutter/go-pulp/pulp" "net/url" "strings" ) type Node struct { Fqdn string ApiUser string ApiPasswd string Tags []string Parent *Node Children []*Node Repositories []Repository SyncPath ...
package model import ( "mall/lib/address" xtime "mall/lib/time" "gopkg.in/mgo.v2/bson" ) type EweiShopGroupsActivity struct { ID bson.ObjectId `bson:"_id,omitempty" gorm:"-" json:"-"` Id string `bson:"id,omitempty" json:"id"` Uniacid int...
package data import ( meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/kiali/kiali/kubernetes" ) func CreateEmptyMeshPolicy(name string, peers []interface{}) kubernetes.IstioObject { return (&kubernetes.GenericIstioObject{ ObjectMeta: meta_v1.ObjectMeta{ Name: name, ClusterName: "svc.clus...
package edocuments type DocumentFetchQuery struct { Type string `json:"type"` Series string `json:"series"` Number string `json:"number"` } type Document struct { Type string `json:"type"` // FT ; FR ; FS ; DI ; Serie string `json:"serie"` Number string `json:"number"` U...
package node import ( "archive/tar" "context" "fmt" "io" "io/ioutil" "path" "strconv" "strings" "time" "github.com/tinyzimmer/k3p/pkg/log" "github.com/tinyzimmer/k3p/pkg/types" dockertypes "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/...
/* B1 Yönetim Sistemleri Yazılım ve Danışmanlık Ltd. Şti. User : ICI Name : Ibrahim ÇOBANİ Date : 25.07.2019 15:57 Notes : */ package models type ApiKeyUsages struct { ApiKey string Usage uint64 }
package vaulttransit import ( "crypto/rand" "encoding/base64" "encoding/json" "fmt" "path" "strings" "sync" "github.com/hashicorp/vault/api" "github.com/libopenstorage/secrets" "github.com/libopenstorage/secrets/pkg/store" "github.com/libopenstorage/secrets/vault/utils" "github.com/libopenstorage/secrets/...
package Reverse_Words_in_a_String import ( "strings" ) func reverseWords1(s string) string { words := strings.Fields(s) left, right := 0, len(words)-1 for left < right { words[left], words[right] = words[right], words[left] left++ right-- } return strings.Join(words, " ") }
package main import ( "fmt" "log" "strings" ) func (c element) Generate() { fmt.Printf("%s %s\r\n", c.GetName(), c.GetType()) if y := c.GetRelated(); y != nil { y.Generate() for _, e := range y.GetElements() { e.Generate() } } } func (e element) Setter(typeName string) { if strings.HasSuffix(typeName...
package main import ( "os" "fmt" "github.com/webview/webview" ) func main() { debug := true w := webview.New(debug) defer w.Destroy() w.SetTitle("Minimal webview example") w.SetSize(800, 600, webview.HintNone) // Get working directory path, err := os.Getwd() if err != nil { panic(err) } fmt.Println...
// Copyright (C) 2019 Google 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 agreed t...
package main import ( "flag" "fmt" "net/http" "os" "strings" "time" "github.com/shirou/gopsutil/cpu" "github.com/shirou/gopsutil/mem" ) var ( interval int token string ) const ( api = "http://localhost:3000/servers" web = "http://localhost/api/users" version = "1.0.0" ) // TODO: spearating ...
package client import ( "errors" "net/http" "testing" "github.com/moyen-blog/client-go/client/mocks" ) func init() { DefaultHTTPClient = &mocks.MockHTTPClient // Ensure no real HTTP calls are made } func TestRequestSuccess(t *testing.T) { token := "testtoken" mocks.MockHTTPClient.SetResponse("", 200, nil) s...
package ines import ( "fmt" "io/ioutil" "github.com/funsun/peridot/cartridge" "github.com/funsun/peridot/common" ) func ReadFile(filename string) common.Cartridge { data, _ := ioutil.ReadFile(filename) return Read([]uint8(data)) } func Read(data []uint8) common.Cartridge { header := data[0:16] mapper := get...
// Copyright 2019 Yunion // // 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 writi...
package do func serviceCallOne() (string, error) { return "a", nil } func serviceCallTwo() (int, error) { return 1, nil } func serviceCalls() (string, int, error) { return deriveDo(serviceCallOne, serviceCallTwo) }
package main import ( "container/list" "fmt" ) type lru struct { capacity int // list of keys queue *list.List data map[string]*node } type node struct { Data interface{} KeyPtr *list.Element } func (n *node) String() string { if key, ok := n.KeyPtr.Value.(string); ok { return fmt.Sprintf("%s - %v", k...
package models type Vote struct { userId string `json:"userId"` voteId string `json:"voteId"` }
package main import ( "flag" "fmt" ) var name string func init() { //接收命令行参数 //参数1:&name表示接收参数变量的地址,&符号取地址的意思 //参数2:name表示接收参数的名字 //参数3:默认值 //参数4:参数描述 flag.StringVar(&name, "name", "default name", "请输入名称:") } func main() { //开始真正开始解析命令行参数,将内容赋值给响应的name变量 flag.Parse() fmt.Println("Hello " + name) } /** ...
/* Copyright 2021 The KodeRover 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, s...
package main //1744. 你能在你最喜欢的那天吃到你最喜欢的糖果吗? //给你一个下标从 0 开始的正整数数组candiesCount,其中candiesCount[i]表示你拥有的第i类糖果的数目。同时给你一个二维数组queries,其中queries[i] = [favoriteTypei, favoriteDayi, dailyCapi]。 // //你按照如下规则进行一场游戏: // //你从第0天开始吃糖果。 //你在吃完 所有第 i - 1类糖果之前,不能吃任何一颗第 i类糖果。 //在吃完所有糖果之前,你必须每天 至少吃 一颗糖果。 //请你构建一个布尔型数组answer,满足answer.lengt...
// 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 kernel import ( "bufio" "context" "os" "regexp" "strconv" "chromiumos/tast/testing" ) func init() { testing.AddTest(&testing.Test{ Func: HighResTimers, ...
package handlers type getResponse struct { Rating float64 `json:"rating"` } type reviewResponse struct { Author string `json:"author"` Rating int `json:"rating"` Commentary string `json:"commentary"` } type reportResponse struct { ReportedBy string `json:"reportedBy"` ReportedUser string `json:"reportedUser"` ...
/* Spiral Matrix Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] You should return [1,2,3,6,9,8,7,4,5]. */ package main // 模拟螺旋的方式 func spiralOrder(matrix [][]int) []int { i...
package main import "fmt" func main() { var list LinkedList list.print() // appends list.append(Node{data: 1}) list.append(Node{data: 2}) list.append(Node{data: 3}) list.print() fmt.Println("size is", list.size()) // prepends list.prepend(Node{data: 4}) list.prepend(Node{data: 5}) list.prepend(Node{data...
package metaltest import ( "fmt" "github.com/ionous/sashimi/compiler/model/modeltest" "github.com/ionous/sashimi/metal" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "testing" ) func VerifyPostConditions(t *testing.T, v metal.ObjectValue) { VerifyPostValues(t, v) VerifyPostLists(t...
package usermodel import ( "time" "github.com/naaltunian/wyn-search-go/utils/errors" "go.mongodb.org/mongo-driver/bson/primitive" ) // User is the user model type User struct { ID primitive.ObjectID `json:"_id,omitempty" bson:"_id, omitempty"` Name string `json:"name,omitempty"...
// Copyright 2019 Prometheus Team // 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 wri...
package goisgod import ( "image" "os" "github.com/disintegration/imaging" "log" ) type GopherImageDrawer struct { gopher *image.Image dao *GigDao stoppedCh chan struct{} } // NewGopherImageDrawer is used to draw gopher via image input channel func NewGopherImageDrawer(dao *GigDao, stoppingCh <-chan ...
package lib import ( "github.com/chidakiyo/benkyo/go-memleak-check/log" "github.com/gin-gonic/gin" "math/rand" "net/http" "strconv" ) func RandStream(g *gin.Context) { c := g.Request.Context() bit := uint64(0) bitSt := g.Query("b") if bitSt == "" { bit = 8 } else { bit, _ = strconv.ParseUint(bitSt, 10,...
package main func f(n... int) { }
package api import ( "encoding/base64" uuid "github.com/satori/go.uuid" "github.com/sirupsen/logrus" "net/http" "strings" "text-converter/internal/cfg" ) func requestIdMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { config := cfg.GetConfig()...
package git import ( "container/heap" "fmt" ) type NodeFlag uint32 const ( NodeColorRed NodeFlag = (1 << iota) NodeColorGreen NodeColorBlue NodeColorYellow = NodeColorRed | NodeColorGreen NodeColorWhite = NodeColorRed | NodeColorGreen | NodeColorBlue NodeFlagSeen = 1 << 4 ) type CommitNode struct { comm...
package main import ( "fmt" "math" ) func find132pattern(nums []int) bool { n:=len(nums) stack:=make([]int,0) second:=math.MinInt64 for i:=n-1;i>=0;i--{ if nums[i]<second{ return true } for len(stack)>0&&stack[len(stack)-1]<nums[i]{ second=stack[len(stack)-1] stack=stack[:len(stack)-1] } st...
// Copyright 2019 Yunion // // 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 writi...
package sentiment import "strings" import "regexp" var whitespace = regexp.MustCompile("[\\r\\n\\t ]+") // SanitizerFunc will operate on an entire document and return // the result. Note that the length of the processed array // need not be the same as the input. type SanitizerFunc func(words []string) (result []str...
package main import "fmt" import "strings" import "unicode/utf8" func isLetter(c rune) bool { return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') } func Fast_Encode_Upper(a, b rune) rune { return (((a - 'A') + (b - 'A')) % 26) + 'A' } func Fast_Decode_Upper(a, b rune) rune { return (((((a - 'A') - (b - 'A'))...
package session import "github.com/gin-contrib/sessions" type Session interface { Store() sessions.Store }
package main // /root page -- welcome, show link to go to /mastermind // /mastermind -- welcome, mastermind home page, instruction // /mastermind/play -- start playing, sessionId, secret code generated, board init // /mastermind/play/{sessionId}?guess={guess} -- send guess to the server to crack the code // /mastermin...
package transfer import ( "net" "golang.org/x/net/context" "github.com/juntaki/transparent" pb "github.com/juntaki/transparent/transfer/pb" "google.golang.org/grpc" ) type receiver struct { serverAddr string grpcServer *grpc.Server transferServer *server } func NewSimpleLayerReceiver(serverAddr st...
// 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 webrtc import ( "context" "time" "chromiumos/tast/common/media/caps" "chromiumos/tast/local/bundles/cros/webrtc/mediarecorder" "chromiumos/tast/local/chrome" ...
package lbricks import "github.com/ungerik/go3d/vec2" type Typable interface { Type() } type Poolable interface { Reset() } type Disposable interface { Dispose() } type Renderable interface { Render(Batch) } type Positionable interface { Position() *vec2.T } type Scalable interface { Scale() *vec2.T } t...
/* Package resolv is a simple collision detection and resolution library. Its goal is to be lightweight, fast, simple, and easy-to-use for game development. Its goal is to also to not become a physics engine or physics library itself, but to always leave the actual physics implementation and "game feel" to the develope...
package servicediscovery import ( "bytes" "encoding/json" "fmt" "io/ioutil" "os" "path" "strconv" "strings" "github.com/hyperhq/hyper/utils" "github.com/hyperhq/runv/hypervisor" "github.com/hyperhq/runv/hypervisor/pod" "github.com/hyperhq/runv/lib/glog" ) var ( ServiceVolume string = "/usr/local/etc/hap...
package api import ( commonapi "github.com/cidverse/cid/pkg/common/api" "github.com/cidverse/cid/pkg/core/catalog" "github.com/cidverse/cid/pkg/core/state" ) // ActionExecutor is the interface that needs to be implemented by all action executors type ActionExecutor interface { // GetName returns the name of the e...
package pubsub import ( "fmt" "log" "testing" "time" ) type intlDummyChanColl map[uint]Channel func (coll intlDummyChanColl) LoadOrOpen(id uint) Channel { if _, ok := coll[id]; !ok { coll[id] = newDummyChannel() } return coll[id] } func (coll intlDummyChanColl) Close(id uint) { } type intlDummyChannel st...
package cmd import ( "os" "github.com/spf13/cobra" ) var newPublisherAlias string // trustPublisherCmd represents the add-identity command var trustPublisherCmd = &cobra.Command{ Use: "trust-publisher ID_OR_ALIAS", Short: "records trust in publisher", Long: `TODO`, Run: func(cmd *cobra.Command, args []stri...
package main import "fmt" func main() { //string.Split分割函数 len //var s1 string = "hello" // s2 := "how are you" // s3 := strings.Split(s2, " ") // fmt.Println(s3[1]) // s := "hello 你好" // for i := 0; i < len(s); i++ { //按字节计算 // fmt.Printf("%c\n", s[i]) // } // for i, v := range s { //按单个字符输出 // fmt.Pr...
package gmtls // #cgo CFLAGS: -I${SRCDIR}/../../3rd_party/gmssl/include // #cgo CFLAGS: -I${SRCDIR}/../../3rd_party/addon/include // #cgo LDFLAGS: -L${SRCDIR}/../../3rd_party/gmssl/lib -lcrypto -lssl // #cgo LDFLAGS: -L${SRCDIR}/../../3rd_party/addon/lib -laddon // #cgo LDFLAGS: -Wl,-rpath=${SRCDIR}/../../3rd_party/gm...
package plot import ( "time" "github.com/nictuku/latency" ) // ExamplePlot creates a histogram with 10 buckets and records an event that took 16ms (16000us), // then plots a (very uninteresting) graph for it. func ExamplePlot() { h := &latency.Histogram{ Buckets: make([]int, 10), Resolution: time.Milliseco...
package store import ( "fmt" "math" ) type MuxingWriter []Writer // This builds a writer that writes each record it recieves to one of the // provided writers according to the record's DatabaseIndex. For example, the // writer NewMuxedStoreWriter(db0, db1) will write records with DatabaseIndex = // 0 to db0 and re...
package build import ( "fmt" "regexp" "strings" "time" digest "github.com/opencontainers/go-digest" "github.com/tonistiigi/units" "github.com/tilt-dev/tilt/pkg/apis" "github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1" "github.com/tilt-dev/tilt/pkg/logger" ) type buildkitPrinter struct { logger logger.Logger...
package split import ( "encoding/hex" "fmt" "testing" ) func TestEncode(t *testing.T) { s := Secret{} f := "e424cc3ef5c62accff7ebe9c3d797927af59976677501b2c4cd9a2f046218952" p := "d41ca9b3ff93b24da439c32ab28c24fd03220fbee13d3c4650f20125172ae72d" bf, _ := hex.DecodeString(f) bp, _ := hex.DecodeString(p) fmt.P...
package datasource import ( "encoding/json" "github.com/aws/aws-sdk-go/service/ec2" "net/http" "github.com/grafana/grafana-plugin-sdk-go/backend/log" "github.com/grafana/grafana-plugin-sdk-go/backend/resource/httpadapter" ) func (ds *Datasource) getRegions(rw http.ResponseWriter, req *http.Request) { if ...
package main import ( "encoding/json" "fmt" "html/template" "net/url" "os" "strings" "time" "github.com/apex/go-apex" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" ) func getEnvmap() map[string]string { envmap := make(map[string]string) fo...
package main //724. 寻找数组的中心索引 //给定一个整数类型的数组nums,请编写一个能够返回数组 “中心索引” 的方法。 // //我们是这样定义数组 中心索引 的:数组中心索引的左侧所有元素相加的和等于右侧所有元素相加的和。 // //如果数组不存在中心索引,那么我们应该返回 -1。如果数组有多个中心索引,那么我们应该返回最靠近左边的那一个。 // // // //示例 1: // //输入: //nums = [1, 7, 3, 6, 5, 6] //输出:3 //解释: //索引 3 (nums[3] = 6) 的左侧数之和 (1 + 7 + 3 = 11),与右侧数之和 (5 + 6 = 11) 相等...
// Package echo shows a simple RPC service that can be served with rpcz. package echo import ( "context" "errors" "time" ) const ( defaultTimeout = 60 * time.Second ) var ( errInvalidMsg = errors.New("echo: invalid message") ) // Echo service replies back with the message it receives. type Echo struct{} // Ne...
package exec import ( "encoding/binary" "fmt" "io" "math" "reflect" "github.com/pgavlin/warp/wasm" "github.com/pgavlin/warp/wasm/code" "github.com/pgavlin/warp/wasm/leb128" ) type InvalidGlobalIndexError uint32 func (e InvalidGlobalIndexError) Error() string { return fmt.Sprintf("wasm: Invalid index to glo...
package state import ( "time" "github.com/guregu/null" ) type PostgresReplication struct { InRecovery bool // Data available on primary CurrentXlogLocation null.String Standbys []PostgresReplicationStandby // Data available on standby IsStreaming null.Bool ReceiveLocation null.String ...
// 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 wilco import ( "bytes" "context" "time" "chromiumos/tast/common/testexec" "chromiumos/tast/ctxutil" "chromiumos/tast/local/vm" "chromiumos/tast/local/wilco" ...