text
stringlengths
11
4.05M
package models import ( "fmt" u "github.com/mtjhartley/concerts-api/internal/pkg/utils" "github.com/jinzhu/gorm" ) type Concert struct { gorm.Model Name string `json:"name"` Date string `json:"date"` FacebookLink string `json:"facebook_link"` TicketLink string `json:"ticket_link"` UserId ...
package wguser import ( "net" "testing" "time" "github.com/google/go-cmp/cmp" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) // Example string source (with some slight modifications to use all fields): // https://www.wireguard.com/xplatform/#example-dialog. const okGet = `private_key=e84b5a6d2717c1003a13b4315703...
package main import("fmt") func main(){ n := make([]string,3) fmt.Println("\nn with 0 element : ", n,"Capacity : ",cap(n),"Length : ",len(n)) number := make([]int,3,5) fmt.Println("\nnumber with 0 element : ", number,"Capacity : ",cap(number)) number[0] = 0 number[1] = 1 number[2] = 2 fmt.Println("\nnumber...
//Package scrabble it's a package to calculate the score of a word package scrabble import "unicode" var letters = map[rune]int{ // A, E, I, O, U, L, N, R, S, T -> 1 'A': 1, 'E': 1, 'I': 1, 'O': 1, 'U': 1, 'L': 1, 'N': 1, 'R': 1, 'S': 1, 'T': 1, // D, G -> 2 'D': 2, 'G': 2, // B, C, M, P -> 3 'B': 3...
package main import ( "awesomeProject/micro_nats_streming_dome/wp/debug" "context" "fmt" "strings" "time" nats "github.com/nats-io/go-nats" gonats "github.com/nats-io/nats.go" "github.com/astaxie/beego/logs" micro "github.com/micro/go-micro" stanBroker "github.com/micro/go-plugins/broker/stan" natsRegistr...
// All material is licensed under the Apache License Version 2.0, January 2004 // http://www.apache.org/licenses/LICENSE-2.0 // This sample program demonstrates the basic channel mechanics // for goroutine signaling. package main import ( "fmt" "math/rand" "time" ) func init() { rand.Seed(time.Now().UnixNano()) ...
package power import ( "context" "github.com/superchalupa/sailfish/src/log" "github.com/superchalupa/sailfish/src/ocp/view" domain "github.com/superchalupa/sailfish/src/redfishresource" eh "github.com/looplab/eventhorizon" ) // TODO: current odatalite stack has this as part of output, but that seems completely...
package templates import ( "os" "testing" "text/template" ) func TestLearnTemplates(t *testing.T) { // Examples are mostly from https://golang.org/pkg/text/template/ documentation. t.Run("Trivial", func(t *testing.T) { type Inventory struct { Material string Count uint } sweaters := Inventory{"wo...
package messages import ( "time" "github.com/joernweissenborn/aursir4go/appkey" "github.com/joernweissenborn/aursir4go/util" "errors" ) //AurSirMessage represents a generic message type AurSirMessage interface { } const ( DOCK = iota DOCKED LEAVE REQUEST RESULT ADD_EXPORT UPDATE_EXPORT EXPORT_...
package main import( "fmt" "net/http" "github.com/julienschmidt/httprouter" "hash/fnv" "bytes" ) type jsonobject struct{ Key string Value string } var data [10]jsonobject var i int var k [10]string var v [10]string var server [3]string var CHashServer map[string]uint32 var CHashClient map[string]uint32 var cServe...
package buildInfo // BuildInfo contains build information type BuildInfo struct { Name string `json:"Name,omitempty"` Version string `json:"Version,omitempty"` Date string `json:"BuildDate,omitempty"` Branch string `json:"BuildBranch,omitempty"` Build string `json:"BuildNumber,omitempty"` }
package dynatrace import ( "encoding/json" "errors" log "github.com/sirupsen/logrus" ) const metricsPath = "/api/v2/metrics" // MetricDefinition defines the output of /metrics/<metricID> type MetricDefinition struct { MetricID string `json:"metricId"` DisplayName string `json:"displayName"...
package main import ( "fmt" "strconv" ) func main() { fmt.Println("请输入数字长度") var num int fmt.Scan(&num) arr := make([]string, num) for i := 0; i < len(arr); i++ { fmt.Scan(&arr[i]) } fmt.Println("数组输入完成") fmt.Printf("%T %v\n", arr, arr) fmt.Println(evalRPN(arr)) } func evalRPN(tokens []string) int { sta...
package factogo import ( "fmt" "reflect" ) /* Creates a new product struct from an anonymous factory design */ func Produce(product interface{}) error { fi := &factoryInstance{object: product, isAnonymous: true} fi.values = make(map[string]*factoryValue) return fi.Produce(product) } /* Produce invokes a designe...
package main import ( "testing" ) func TestCode(t *testing.T) { var tests = []struct { seconds int grid []string output []string }{ { seconds: 3, grid: []string{ ".......", "...O...", "....O..", ".......", "OO.....", "OO.....", }, output: []string{ "OOO.OOO", ...
package main import ( "io/ioutil" "log" "os" ) var ( Info *log.Logger Warning *log.Logger Error *log.Logger ) func initLog() { info := ioutil.Discard warn := ioutil.Discard err := ioutil.Discard if debug { info = os.Stdout warn = os.Stdout err = os.Stderr } Info = log.New(info, "INFO: ", ...
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build !windows // +build !windows package winutil const RegBase = `` // GetRegString looks up a registry path in our local machine path, or ...
package _1_Factory_Pattern import ( "reflect" "testing" ) //步骤 4 //使用该工厂,通过传递类型信息来获取实体类的对象。 func TestFactoryPattern(t *testing.T) { tests := []struct { name string args string want string }{ {name: "Rectangle", args: "Rectangle", want: "Rectangle"}, {name: "Square", args: "Square", want: "Square"}, {n...
package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "net/http" "os" "path/filepath" "strings" "time" "github.com/pkg/browser" "github.com/pkg/errors" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/rs/zerolog/pkgerrors" "github.com/spf13/pflag" "github.com/spf13/viper" "git...
package mesos_cli import ( "encoding/json" "fmt" "net/http" "strings" ) const ( masterURL string = "/master/state.json" slavesURL string = "/master/slaves" ) type MesosCli interface { Slaves() ([]Slave, error) } type Client struct { Scheme string Address string Client *http.Client } func (c *Client) ge...
/* * Copyright (c) zrcoder 2019-2020. All rights reserved. */ package campus_bikes import "container/heap" type item struct { workerId int bikeId int dist int } type Heap []*item func (h Heap) Len() int { return len(h) } func (h Heap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } func (h Heap) Less(i, ...
package controller import ( "testing" "github.com/jerolan/slack-poll/test" "github.com/jerolan/slack-poll/usecase" "github.com/stretchr/testify/assert" ) func TestPollController(t *testing.T) { db := test.InitializeTestDatabase() uuid := test.NewTestUUIDPort() pollService := test.NewTestPollService(db) useC...
package main import ( "encoding/csv" "log" "math/rand" "os" "strconv" ) func (s *schedule) init() { s.sort(0, len(s.jobs)-1) s.calCompletionTimes() } func (s *schedule) getCompletionTime() int { return s.completionTimes[len(s.completionTimes)-1] } func (s *schedule) calCompletionTimes() { sumLength := 0 s...
// Package main ... package main import ( "github.com/go-rod/rod/lib/utils" ) func main() { utils.Exec("npx -ys -- cspell@6.31.1 --no-progress **") utils.Exec("npx -ys -- eslint@8.41.0 --ext=.js,.html --fix --ignore-path=.gitignore .") utils.Exec("npx -ys -- prettier@2.8.8 --loglevel=error --write --ignore-path...
package conf import ( "io/ioutil" "encoding/json" "os" ) type Settings struct { BotURL string `json"BotURL` DBHost string `json"DBHost` DBName string `json"DBName` DBPassword string `json"DBPassword` DBUser string `json"DBUser` ServerAddr string `json:"ServerAddr"` ServerPort string `json...
package scheduler import ( "github.com/waybeams/waybeams/pkg/clock" "github.com/waybeams/waybeams/pkg/events" "github.com/waybeams/waybeams/pkg/layout" "github.com/waybeams/waybeams/pkg/spec" ) const shouldPollEvents = true // Scheduler manages Specification lifecycle and rendering interactions with // the host ...
// 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 activity import ( "context" // "encoding/hex" // hexadecimal encoding of BSON obj "github.com/go-kit/kit/endpoint" "fmt" "go.mongodb.org/mongo-driver/bson/primitive" // for BSON ObjectID ) type Endpoints struct { CreateActivity endpoint.Endpoint GetActivity endpoint.Endpoint DeleteActivity endpoi...
package models // Dreadlocks is an artwork model of gogo.tattoo. it represents Dreadlocks type Dreadlocks struct { Artwork } // NewDreadlocks returns a new model, requires id, the unique title of the new work // link, also unique and final image ipfs hash func NewDreadlocks(id, title, link, hash string) (h Dreadlock...
// Copyright © 2019 NAME HERE <EMAIL ADDRESS> // // 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 ...
// Copyright (C) 2019-2020 Zilliz. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable l...
package db import ( "database/sql" hd "diaria/handlers" "log" ) var db *sql.DB func Initialize() { db = hd.Db createSeq() createTables() createPKey() createFKey() createUniqueKey() createFeatures() createSystemRoles() createRoleFeatures() createAdmin() InitMealTypes() InitMeasures() InitFoods() } fu...
package algorithms import ( "bytes" "golang.org/x/text/unicode/norm" "math" "regexp" "strings" "sync" ) type Similarity struct { stopWords map[string]string tfIdf *TFIDF } var ( instance *Similarity once sync.Once ) func Get() *Similarity { once.Do(func() { instance = &Similarity{} instance.t...
package transport import "encoding/json" // NotifyEvent - type NotifyEvent struct { // Send - which node send event Send string `json:"send"` // Receives - Receives []string `json:"receives"` // Session - Session string `json:"session"` // Message - Message Message `json:"message"` } // Message - type Mes...
package db import "context" type PlayerInfo struct { ID string `bson:"_id"` DateOfBirth string `bson:"date_of_birth"` FirstName string `bson:"first_name"` LastName string `bson:"last_name"` Nationality string `bson:"nationality"` } var ColPlayers string = "players" func (c *MongoDBClient) InsertP...
package handler import ( "github.com/gin-gonic/gin" "golang.org/x/net/websocket" "log" ) func GinWebsocketHandler(wsConnHandle websocket.Handler) gin.HandlerFunc { return func(c *gin.Context) { log.Println("终端接入", "ip:", c.Request.RemoteAddr) if c.IsWebsocket() { wsConnHandle.ServeHTTP(c.Writer, c.Request)...
package RedisLock import ( "gopkg.in/redis.v4" "time" ) type RedisLock struct { client *redis.Client expiration *time.Duration } func NewRedisLock(addr *string,password *string,db *int,expiration *time.Duration) *RedisLock { client := redis.NewClient(&redis.Options{ Addr: *addr, Password: *password, // ...
package main import ( "fmt" "os" "github.com/codegangsta/cli" "github.com/mgutz/ansi" ) var errorDecorator = ansi.ColorFunc("white:red") // Create New Cli App func createNewApp() *cli.App { app := cli.NewApp() app.Name = "Jira & Git Worflow" app.Usage = "Simple tool for automating branch management using ji...
package account import ( "errors" "finance/models" "finance/models/finance" "finance/plugins/redis" ) type EditPasswordForm struct { Phone string `validate:"required" json:"phone" form:"phone" error_message:"手机号~required:为必填项"` Password string `validate:"required,min=1,max=24" json:"password" for...
package dist import ( "errors" "math" ) type WeibullDistribution struct { DistributionType string } // Generate random numbers that fit the // weibull distribution // Paramaters : a = Scale parameter a > 0 // b = Shape parameter b > 0 func (d WeibullDistribution) RandVar(a float64, b float64) (float64, error)...
package gnr import ( "math" ) type Camera interface { // GetRayForPixel creates a ray in 3D space that corresponds to the pixel on // the 2D canvas of the image. This should be the only function where these // 2 spaces meet. GetRayForPixel(x, y uint64) *Ray Normalize() } type SphericalCamera struct { Position...
package genericerror import ( "fmt" ) // GenericError contains information regarding a certain error type GenericError struct { Message string } // GenericError returns an error message string func (e *GenericError) Error() string { return fmt.Sprintf(e.Message) }
package characters type Class struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` ArmorType ArmorType `json:"armorType"` CombatType CombatType `json:"combatType"` //Spells Spells[] } //ArmorType type type ArmorType string const ( Arm...
package main import ( "bytes" "crypto/hmac" "crypto/sha1" "crypto/subtle" "encoding/hex" "encoding/json" "flag" "io/ioutil" "log" "net/http" "os" ) var ( addrFlag = flag.String("addr", ":80", "address to listen on") secretFlag = flag.String("secret", "./secret", "path to secret file") masterHo...
/* *@author 菠菜君 *@Version 0.1 *@time 2013-10-30 *@go语言实现模拟登陆微信公众平台,突破微信群发每日一条限制 *@青岛程序员 微信订阅号 qdprogrammer *@Golang 微信订阅号 gostock *@关于青岛程序员的技术,创业,生活 分享。 *@开源 https://github.com/philsong/ */ package main import ( "crypto/md5" "encoding/hex" "encoding/json" "fmt" "io" "io/ioutil" "log" "net/http" "net/...
package dns import ( "testing" "github.com/shuLhan/share/lib/test" ) func TestHostsLoad(t *testing.T) { msgs, err := HostsLoad("testdata/hosts") if err != nil { t.Fatal(err) } test.Assert(t, "Length", 10, len(msgs), true) } func TestHostsLoad2(t *testing.T) { _, err := HostsLoad("testdata/hosts.block") i...
package conjson_test import ( "bytes" "encoding/json" "fmt" "os" "time" "github.com/Rican7/conjson" "github.com/Rican7/conjson/transform" ) type exampleModel struct { Title string Description string ImageURL string ReferredByURL string IsActive bool CreatedAt time.Time UpdatedAt...
package main import "fmt" //给定一个 n × n 的二维矩阵 matrix 表示一个图像。请你将图像顺时针旋转 90 度。 // //你必须在 原地 旋转图像,这意味着你需要直接修改输入的二维矩阵。请不要 使用另一个矩阵来旋转图像。 //输入:matrix = [[5,1,9,11],[2,4,8,10],[13,3,6,7],[15,14,12,16]] //输出:[[15,13,2,5],[14,3,4,1],[12,6,8,9],[16,7,10,11]] /////////////////暴力算法/////////////////////// func rotate(matrix [][]...
// Unless explicitly stated otherwise all files in this repository are licensed // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. package datadog import "fmt" // Event contains the rquired information ...
package _121_best_time_to_buy_and_sell_stock import "math" // 1次遍历,记录最低的值,同时利用最低的值找到最大的差值,就是最大的利润 // 时间复杂度:O(n),只需要遍历一次。 // 空间复杂度:O(1),只使用了常数个变量。 func maxProfit(prices []int) int { minValue := math.MaxInt64 maxValue := 0 for i := 0; i < len(prices); i++ { if prices[i] < minValue { minValue = prices[i] } els...
/* Copyright 2021 The Skaffold Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, sof...
package models type XMetadata struct { Replicas int `yaml:"replicas,omitempty" json:"replicas,omitempty" validate:"required,min=1"` Name string `yaml:"name,omitempty" json:"name,omitempty" validate:"required,min=4"` Labels map[string]interface{} `yaml:"labels,omitempty" json...
package Image import ( "container/list" "image" ) func Delaunay(point list.List, w int, l int) list.List{ triangle_list := list.New() x := w y := l d := 40 triangle_list.PushBack(NewTriangle(0 - d, 0 - d, x + d, 0 - d, x/2, y/2)) triangle_list.PushBack(NewTriangle(x + d, y + d, x + d, 0 - d, x/2, y/2)) tri...
package shutdown import ( "go.uber.org/dig" "github.com/iotaledger/hive.go/app" "github.com/iotaledger/hive.go/app/shutdown" ) func init() { Component = &app.Component{ Name: "Shutdown", Provide: provide, Params: params, } } var ( Component *app.Component ) func provide(c *dig.Container) error { /...
package main import ( "fmt" "App/calc" ) func main() { fmt.Println(basic.Mult(6, 3)) }
package main import ( "fmt" "huffman_hamming/huffman" ) func main() { fmt.Println("Empiezo ejecucion") // hamming.Hamming() huffman.Huffman() fmt.Println("Fin de la ejecucion") }
// exporter.go tries to download videos from yandes.disk // // usage: // > go get github.com/Grishberg/yandex-disk-restapi-go // > go run exporter.go -token=access_token // // You can find an access_token for your app at https://oauth.yandex.ru package main import ( "flag" "fmt" "github.com/Grishberg/yandex-d...
package web import ( "github.com/kataras/iris" ) func CorsHandler(ctx iris.Context) { ctx.Header("Access-Control-Allow-Origin", "*") //允许访问所有域 ctx.Header("Access-Control-Allow-Headers", "Content-Type") //header的类型 ctx.Header("content-type", "application/json") //返回数据格式是json ctx.Next() //...
package models import ( "encoding/json" "fmt" "reflect" "strconv" "github.com/GUAIK-ORG/go-snowflake/snowflake" "github.com/astaxie/beego" ) // 生成唯一id // (s *Snowflake) NextVal() int64 // 返回1 (int64): 唯一ID func SnowflakeId() uint64 { s, err := snowflake.NewSnowflake(int64(0), int64(0)) if err != nil { beeg...
package health import ( "net/http" "github.com/gin-gonic/gin" ) func HealthHandler() gin.HandlerFunc { return func(ctx *gin.Context) { ctx.String(http.StatusOK, "{\"data\":\"¡Alive!\"}") } }
package set1 import ( "bytes" "testing" ) func TestChallenge5(t *testing.T) { key := []byte("ICE") plaintext := []byte("Burning 'em, if you ain't quick and nimble I go crazy when I hear a cymbal") output, err := HexDecodeString("0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272a282b2f20...
package repository //go:generate go run github.com/golang/mock/mockgen -source=$GOFILE -destination=mock/${GOFILE} -package=mock import ( "context" "github.com/traPtitech/trap-collection-server/src/domain" "github.com/traPtitech/trap-collection-server/src/domain/values" ) type LauncherVersion interface { Create...
package kube import ( "github.com/bmsandoval/kubester/bash" "github.com/bmsandoval/kubester/services/kube_svc" "github.com/bmsandoval/kubester/utils" "github.com/spf13/cobra" ) var ContextCmd = &cobra.Command{ Use: "context", Aliases: []string{"ctx"}, Short: "kubectl config use-context", Long: ``, R...
package main import ( "fmt" "rand" "time" ) type heap struct { s []int size int } func max(a int, b int) int { if a > b { return a } return b } func (h *heap) parent(i int) int { return max((i-1)/2, 0) } func (h *heap) left(i int) int { return 2*(i+1)-1 } func (h *heap) right(i int) int { return 2*(i...
package application import ( "github.com/stretchr/testify/assert" "testing" ) func Test_loadFromEnvPairs(t *testing.T) { type args struct { prefix string pairs []string } tests := []struct { name string args args want HookMap }{ { name: "simple", args: args{ prefix: "test", pairs: []s...
package fynegui import ( "fmt" "fyne.io/fyne" "fyne.io/fyne/layout" "fyne.io/fyne/widget" "github.com/smaTc/RemotePlayDetached/executor" ) var apps *[]executor.App var appList *widget.Form //var appList widget.NewVBox var appListContainer *fyne.Container func importApp() { importWindow := rpd.NewWindow("Imp...
package biz import ( "context" pb "edu/api/sys/v1" "edu/service/sys/internal/model" "google.golang.org/protobuf/types/known/timestamppb" ) func (uc *AdminUsecase) GetDictDataPage(ctx context.Context, req *pb.GetDictDataListRequest) (list []*pb.DictData, total int64, err error) { var pageSize = int(req.PageSize...
package metrics import ( "bufio" "os/exec" "regexp" "strconv" "strings" ) var procUsageRegex = regexp.MustCompile("\\s+") func GetProcessResourceUsages(names []string) ([]*ProcessResourceUsage, error) { usages := make([]*ProcessResourceUsage, 0, len(names)) for _, name := range names { usages = append(usage...
package constant_test import ( "testing" ) const WEEK = 7 const ( Mon = 0 + iota Tue Wed Thu Fri Sat Sun ) const ( READ = 1 << iota WRITE EXECUTE ) func TestConstantWeek(t *testing.T) { t.Log(Mon,Tue,Sat,Sun) } func TestConstantStatus(t *testing.T) { t.Log(READ,WRITE,EXECUTE) var a int = 7 //0x0111 t...
// 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 bittrex_test import ( "testing" "time" "github.com/carterjones/bittrex" ) func TestOrder_Market(t *testing.T) { cases := map[string]struct { in bittrex.Order exp string }{ "correct": {in: bittrex.Order{Exchange: "abc123"}, exp: "abc123"}, } for id, tc := range cases { act := tc.in.Market() ...
package main import ( "net/http" "github.com/fomiller/go-mongodb-tutorial/API" "github.com/fomiller/go-mongodb-tutorial/config" ) func main() { // Route Handlers http.HandleFunc("/", IndexHandler) http.HandleFunc("/api/create", API.CreateHandler) http.HandleFunc("/api/createmany", API.CreateManyHandler) http...
// Package stack implements the Stack data structure package stack type Stack struct { Stack []interface{} } func (s *Stack) Push(value interface{}) { s.Stack = append(s.Stack, value) } func (s *Stack) Pop() interface{} { length := len(s.Stack) poppedValue := s.Stack[length-1] s.Stack = s.Stack[:length-1] r...
package storage_market import actor "github.com/filecoin-project/specs/systems/filecoin_vm/actor" import addr "github.com/filecoin-project/specs/systems/filecoin_vm/actor/address" import block "github.com/filecoin-project/specs/systems/filecoin_blockchain/struct/block" import deal "github.com/filecoin-project/specs/sy...
package code const ( BlockTypeSpecial = 0x8000000000000000 BlockTypeMask = 0x80000000ffffffff StackHeightMask = 0x7fffffff00000000 BlockTypeEmpty = 0x40 | BlockTypeSpecial BlockTypeI32 = 0x7f | BlockTypeSpecial BlockTypeI64 = 0x7e | BlockTypeSpecial BlockTypeF32 = 0x7d | BlockTypeSpecial BlockTypeF6...
package main import( "fmt" "bufio" "os" ) func main() { var arr [10]string fmt.Println("Give string input:") // way one using bufio.NewReader() it uses to split on particular charecter /* reader := bufio.NewReader(os.Stdin) for i:=0;i<5;i++{ arr[i],_=reader.ReadString(' ') }*/ // way 2 using bufio.NewS...
// SPDX-License-Identifier: MIT package lang import ( "bytes" "unicode" ) // 接口定义了解析代码块的所有操作 type blocker interface { // 确定 l 的当前位置是否匹配 Blocker 的起始位置。 beginFunc(l *parser) bool // 确定 l 的当前位置是否匹配 Blocker 的结束位置 // // data 表示匹配的内容,如果不使用返回的内容,可以返回空值。 // 比如字符串,只需要返回 true,以确保找到了结束位置,但是 data 可以直接返回 nil。 // // 如果...
// This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT License was not distributed with this // file, you can obtain one at https://opensource.org/licenses/MIT. // // Copyright (c) DUSK NETWORK. All rights reserved. package chain import ( "bytes" "context" "testing" "time" ...
package main import "fmt" type Person struct { Name string } // Map elements are not addressable func main() { people := map[string]Person{ "mike": {"Michael"}, } fmt.Println(people["mike"]) mike := people["mike"] mike.Name = "Mikey" people["mike"] = mike fmt.Println(people["mike"]) }
package main import "fmt" type Point struct { X int Y int } func main() { str := "\x99\x42\x32" fmt.Println(str) fmt.Printf("%x\n",str) fmt.Printf("len:%d\n",len(str)) fmt.Printf("%q\n",str) fmt.Printf("%+q\n",str) fmt.Printf("% x\n",str) fmt.Printf("%s\n",str) fmt.Printf("%b\n",7) fmt.Printf("%c\n",37)...
package identity import ( "context" "fmt" "os" "strings" "testing" "github.com/databrickslabs/terraform-provider-databricks/common" "github.com/databrickslabs/terraform-provider-databricks/qa" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/stretchr/testify/assert" "github.com/str...
// Copyright 2019 - 2022 The Samply Community // // 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 ...
package requests import ( "kubeitcli/httpd" ) func InitS3(filename string, multi bool, c *httpd.RequestClient) (passkey string, err error) { data2 := httpd.S3InitResponse{} s3struct := httpd.S3InitRequest{ Filename: filename, Multi: multi, } err, _ = c.SendRequest("POST", "/s3/init", s3struct, &data2) ...
package quoteplugin import ( "io/ioutil" "math/rand" "strconv" "strings" "sync" "fmt" "os" "encoding/json" "github.com/Krognol/dgofw" "github.com/google/go-github/github" ) type Server struct { ID string `json:"id"` Quotes []string `json:"quotes"` } type Quotes struct { sync.RWMutex Servers [...
package models import ( "fmt" "github.com/astaxie/beego" "github.com/astaxie/beego/orm" "strconv" "time" ) type Orders struct { Id uint64 `orm:"column(id);pk" description:"id"` Type string `orm:"column(type)" description:"类型"` ParentId string `orm:"column(parent_id)" description:"父I...
package main import ( "context" "fmt" "log" "os" "path/filepath" "strings" "time" "github.com/spf13/pflag" "mvdan.cc/sh/v3/syntax" "github.com/go-task/task/v3" "github.com/go-task/task/v3/args" "github.com/go-task/task/v3/errors" "github.com/go-task/task/v3/internal/experiments" "github.com/go-task/tas...
package main import "fmt" func nextGreaterElements(nums []int) []int { ret := make([]int,len(nums)) for i:=0;i<len(ret);i++ {ret[i]=-1} stack := make([]int,0) for i:=2*len(nums)-1;i>=0;i-- { cur := nums[i%len(nums)] for len(stack) > 0 && cur >= stack[len...
package main import ( "context" "flag" "fmt" "net/http" "os" "strconv" "time" "github.com/nhudson/longbox/internal/api" "github.com/oklog/run" "github.com/sirupsen/logrus" ) const ( defaultHTTPPort = 7575 defaultURL = "https://getcomics.info" ) var ( httpPort = flag.Int("http-port", getEnvOrFallb...
package daemon import ( "github.com/hyperhq/hyper/engine" "github.com/hyperhq/runv/lib/glog" ) func (daemon *Daemon) CmdCommit(job *engine.Job) error { containerId := job.Args[0] repo := job.Args[1] author := job.Args[2] change := job.Args[3] message := job.Args[4] pause := job.Args[5] cli := daemon.DockerC...
package k8s import ( "fmt" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "github.com/tilt-dev/tilt/internal/k8s/testyaml" ) type workload struct { name string kind string namespace ...
package meter import ( "bufio" "errors" "fmt" "io" "net" "os" "strconv" "strings" "sync" "time" "github.com/basvdlei/gotsmart/crc16" "github.com/basvdlei/gotsmart/dsmr" "github.com/cenkalti/backoff/v4" "github.com/evcc-io/evcc/api" "github.com/evcc-io/evcc/util" "github.com/evcc-io/evcc/util/request" ...
// Package dst is the destination package to be updated. package dst type ExData struct { j uint }
package ftp import ( "Gaia/plugin" "Gaia/util" "sync" "github.com/jlaffaye/ftp" ) var pluginName = "ftp" // BurstPlugin ftp burst plugin type BurstPlugin struct { } // Flag turn on? func (BurstPlugin) Flag() bool { return plugin.SwitchIsOn(pluginName) } // Start start a burst func (BurstPlugin) Start(wgMain ...
package downloads import ( "github.com/gin-gonic/gin" "github.com/rs/xid" "github.com/sunil-bansiwal/file_download_manager/model/downloads" "github.com/sunil-bansiwal/file_download_manager/services" "github.com/sunil-bansiwal/file_download_manager/utils/errors" "net/http" ) func CheckDownloadStatus(c *gin.Conte...
package tree type QueueUnit []*Unit func (q *QueueUnit) Push(n *Unit) { *q = append(*q, n) } func (q *QueueUnit) Pop() (n *Unit) { if len := q.Len(); len > 0 { n = (*q)[0] *q = append(QueueUnit(nil), (*q)[1:]...) } return n } func (q *QueueUnit) Len() int { return len(*q) }
package odoo import ( "fmt" ) // IrQwebFieldText represents ir.qweb.field.text model. type IrQwebFieldText struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` DisplayName *String `xmlrpc:"display_name,omptempty"` Id *Int `xmlrpc:"id,omptempty"` } // IrQwebFieldTexts represents array of ir...
// Copyright 2019 Istio 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 i...
package xmppsid import ( "encoding/xml" "testing" "github.com/stretchr/testify/assert" "github.com/rez-go/xmpplib/xmppcore" ) func TestMarshalEmptyStanzaID(t *testing.T) { var stanzaID StanzaID assert.Panics(t, func() { xml.Marshal(&stanzaID) }) } func TestMarshalBasicStanzaID(t *testing.T) { stanzaID := St...
package host import ( "context" "time" "go.uber.org/fx" // libp2p "github.com/libp2p/go-libp2p" dht "github.com/libp2p/go-libp2p-kad-dht" "github.com/libp2p/go-libp2p-kad-dht/dual" "github.com/libp2p/go-libp2p/config" // libp2p core interfaces "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/g...
package auth import ( "context" "crypto/rsa" "encoding/base64" "encoding/json" "io/ioutil" "math/big" "net/http" "regexp" "strconv" "sync" "time" "github.com/pkg/errors" ) // PublicKeySource is to be used by servers who need to acquire public key sets for // verifying inbound request's JWTs. type PublicK...