text
stringlengths
11
4.05M
package conf import ( "encoding/json" "io/ioutil" "os" "sync" "time" "github.com/snguovo/web/v2.0/dao" "github.com/snguovo/web/v2.0/log" "github.com/snguovo/web/v2.0/service" ) //Config 配置文件结构体 type Config struct { Applist []*dao.App `json:"applist"` WebEnable bool `json:"web_enable"`...
package main import "fmt" func getRow(rowIndex int) []int { ret := make([]int, rowIndex+1) for idx, _ := range ret { ret[idx] = 1 } for i := 0; i < rowIndex+1; i++ { for j := i - 1; j >= 1; j-- { ret[j] = ret[j] + ret[j-1] } } return ret } func main() { fmt.Println(getRow(0)) fmt.Println(getRow(...
package baz import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // Foo specifies an offered pizza with toppings. type Foo struct { metav1.TypeMeta metav1.ObjectMeta Spec FooSpec Status FooStatus } type FooSpec struct { // ...
package endpoint import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/stepan-s/jobro/pool/instant" "github.com/stepan-s/jobro/pool/scheduler" "net/http" ) const SubjectReload = 0 const ActionIncrement = 0 type StatsTransaction struct { ...
package jobs import ( "errors" "log" "github.com/GeorgeMac/pontoon/monitor" ) var NotEnoughWorkersError = errors.New("Not Enough Workers") type JobQueue struct { workers int jobs chan *Job stop chan struct{} } func NewJobQueue(workers int) (*JobQueue, error) { if workers <= 0 { return nil, NotEnough...
// Copyright 2018 NetApp, Inc. All Rights Reserved. package storageattribute import ( "fmt" "strings" ) func NewStringOffer(offers ...string) Offer { return &stringOffer{ Offers: offers, } } func (o *stringOffer) Matches(r Request) bool { sr, ok := r.(*stringRequest) if !ok { return false } for _, s := ...
package main // https://leetcode-cn.com/problems/bulb-switcher/ import "fmt" func bulbSwitch(n int) int { var count int for i := 1; i*i <= n; i++ { count++ } return count } func main() { var n int fmt.Scanf("%d", &n) if n < 1 { panic("input error") } fmt.Println(bulbSwitch(n)) }
package gmserver //平台类型 const ( PlatId_Ios = 0 PlatId_Android = 1 PlatId_Both = 2 ) //qq wx 类型 const ( ServerType_QQ uint32 = 1 ServerType_WX uint32 = 2 ) //公告类型 const ( Notice_Marquee = 0 Notice_Login = 1 Notice_Offline = 2 ) //错误 const ( err_code_ok = 0 //0:处理成功,需要解开包体获得详细信息 err_code_o...
package main import ( "encoding/json" "sync" "time" "github.com/uniqush/log" ) // APIPushResponseHandler records information about push notification attempts to generate a JSON response. type APIPushResponseHandler struct { response APIPushResponse logger log.Logger mutex sync.Mutex } var _ APIResponseH...
package indexer import "testing" func TestIndexer(t *testing.T) { err := Indexer() if err != nil { t.Error(err) return } t.Log("success") }
// Copyright 2018-present The Yumcoder Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // // Author: yumcoder (omid.jn@gmail.com) // package pattern import ( "fmt" "time" ) func Duration(invocation time.Time, name string) { elaps...
package backend import ( "errors" "sort" "sync" ) type IDSet struct { list IDs m sync.Mutex } func NewIDSet() *IDSet { return &IDSet{ list: make(IDs, 0), } } func (s *IDSet) find(id ID) (int, error) { pos := sort.Search(len(s.list), func(i int) bool { return id.Compare(s.list[i]) >= 0 }) if pos < ...
package handlers import ( "chitchat/models" _ "fmt" "net/http" ) // GET/login 登陆页面 func Login(writer http.ResponseWriter, request *http.Request){ generateHTML(writer,nil,"auth.layout","navbar","login") } // 注册页面 GET func Signup(writer http.ResponseWriter, request *http.Request){ generateHTML(writer, nil, "auth...
package migrations import ( "archive/zip" "errors" "io/ioutil" "regexp" "gopkg.in/yaml.v2" ) type ProductVersionFetcher interface { FetchProductVersion(productPath string) (string, error) } func NewProductVersionFetcher() ProductVersionFetcher { return &versionFetcher{} } type versionFetcher struct { } fun...
package binding /* #include <stdio.h> #include <stdarg.h> // The gateway function int debugCallback_cgo(int level, const char *fmt, va_list args, void *data) { void debugCallback(int, const char *, va_list, void *); debugCallback(level, fmt, args, data); } */ import "C"
// Copyright 2018 The gVisor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
package uploaders type Uploader interface { Upload(src string) (url string, err error) }
// Copyright (c) KwanJunWen // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. package estemplate // FielddataFrequencyFilter Datatype parameter to reduce the number of terms loaded into memory. // // See https://www.elastic.co/guide/en/elasti...
/* Copyright SecureKey Technologies Inc. All Rights Reserved. SPDX-License-Identifier: Apache-2.0 */ package did import ( "crypto/ed25519" "crypto/rand" "fmt" "net/http" "net/http/httptest" "testing" "github.com/hyperledger/aries-framework-go/pkg/doc/did" mocklegacykms "github.com/hyperledger/aries-framework...
package container import "container/list" type Lru struct { maxBytes int64 // 允许使用最大内存 nBytes int64 // 已使用内存 ll *list.List // 字典的定义是 map[string]*list.Element,键是字符串,值是双向链表中对应节点的指针。 cache map[string]*list.Element // 某条记录被移除时的回调函数,可以为 nil onEvicted func(key string, value Value) ...
package models import ( "fmt" "wblogApi/internal/db" "gorm.io/gorm" ) type Article struct { gorm.Model UserId uint ArticleTitle string `gorm:"not null" form:"article_title" json:"article_title" binding:"required"` ArticleContent string `gorm:"not null" form:"article_content" json:"article_content" b...
package handlers import ( "encoding/json" "fmt" "github.com/go-redis/redis/v8" log "github.com/sirupsen/logrus" "golang.org/x/crypto/bcrypt" "net/http" "parrot-software-center-backend/tokens" "parrot-software-center-backend/utils" ) // POST route to handle user login func Login(w http.ResponseWriter, r *http....
package main import ( "io" "kasir/controller" "net/http" "text/template" "github.com/labstack/echo" "github.com/labstack/echo/middleware" ) type M map[string]interface{} type TemplateRegistry struct { templates *template.Template } func (t *TemplateRegistry) Render(w io.Writer, name string, data interface{}...
package api import ( "fmt" "net/http" "rw/blockchain/blockchain" "time" ) const ( data_key = "data" wait_msg = "create new block, please wait a while." ) func init() { http.HandleFunc("/addblock", addBlock) } func addBlock(w http.ResponseWriter, r *http.Request) { r.ParseForm() data := r.FormValue(data_key...
package api_test import ( "fmt" "net/http" cniv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" . "github.com/onsi/ginkgo" "github.com/tidwall/gjson" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/harvester/harvester/pkg/builder" "github.com/harv...
package main import ( "github.com/jaypipes/ghw" "github.com/shirou/gopsutil/cpu" "github.com/shirou/gopsutil/mem" ) type HardwareInfo struct { Processor string `json:"processor"` Memory uint64 `json:"memory"` DiskSize uint64 `json:"disk_size"` } func NewHardwareInfo() (*HardwareInfo, error) { cpuinfo, err...
// Copyright 2020 Comcast Cable Communications Management, LLC // // 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 ...
package main import ( "flag" "io" "log" "os" "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" ) func main() { log.SetFlags(0) flag.Parse() args := strings.Split(flag.Arg(0), "/") if len(args) < 2 { log.Fatal("usage: AWS_REGION=us-...
// Copyright 2023 The gVisor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
package main import ( "context" "crypto/tls" "fmt" "io" "net" "net/http" "os" "time" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/crane" v1 "github.com/google/go-containerregistry/pkg/v1" "github.com/google/go-containerregistry/pkg/v1/mutate" ) func creat...
package main import ( "bytes" "flag" "fmt" "io/ioutil" "log" "net/http" ) var ( baseURL = flag.String("d", "http://127.0.0.1:8080/query", "Dgraph server address") ) var ( allMichaelBay = `{ director(func:allofterms(name, "michael bay")) { name@en director.film (orderdesc: initial_release_date) { ...
// Copyright © 2016 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 ...
package apiserver import ( "k8s.io/apimachinery/pkg/apimachinery/announced" "k8s.io/apimachinery/pkg/apimachinery/registered" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime/serializer" "k8s.io/apimachinery...
// 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 linux || windows || darwin // +build linux windows darwin package cli import ( "fmt" "path/filepath" "runtime" "strings" ps "gith...
package controller import ( "encoding/json" "github.com/gorilla/mux" "log" "net/http" "release-dashboard/app/model" "strconv" ) type ApiController struct { } func NewApiController() *ApiController { return new(ApiController) } func (apiController *ApiController) Register(router *mux.Router, path string) { l...
package piscine func Abort(a, b, c, d, e int) int { array := []int{a, b, c, d, e} len := 0 //min := 0 for i := range array { len = i + 1 } for k := 0; k < len-1; k++ { for j := 0; j < len-k-1; j++ { if array[j] < array[j+1] { array[j], array[j+1] = array[j+1], array[j] } } } return array...
package host import ( "testing" ) // TestSaveLoad tests that saving and loading a Host restores its data. func TestSaveLoad(t *testing.T) { ht := CreateHostTester("TestSaveLoad", t) ht.testAllocation() err := ht.host.save() if err != nil { ht.t.Fatal(err) } err = ht.host.load() if err != nil { ht.t.Fatal(...
package interview import "testing" //跳水板 func divingBoard(shorter int, longer int, k int) []int { var result []int if k == 0 { return result } if shorter == longer { result = append(result, k*shorter) return result } index := 0 for i := 0; i <= k; i++ { next := (k-i)*shorter + i*longer if index == 0 ...
package algorithm import "sort" func CombinationSum(candidates []int, target int) [][]int { var res [][]int length := len(candidates) if length == 0 { return res } sort.Ints(candidates) var row []int res = doSum(row, candidates, target, res) return res } func doSum(row []int, candidates []int, target ...
package sqlbuilder import ( "strconv" "sync/atomic" "github.com/valyala/bytebufferpool" ) // Dialect defines the method SQL statement is to be built. type Dialect uint32 const ( // DefaultDialect is a default statement builder mode. DefaultDialect Dialect = iota // PostgreSQL dialect is to be used to automati...
package main import ( "encoding/json" "github.com/go-chi/chi/v5" "github.com/sirupsen/logrus" "goWeb/models" "html/template" "log" "net/http" "time" ) func frontPageHander(writer http.ResponseWriter, request *http.Request) { renderTemplate(writer, "front") } func renderTemplate(w http.ResponseWriter, templa...
package repository import ( "errors" ) var ErrNotFound = errors.New("not found") type ID string
package utils import "fmt" type element struct { flag Flag error string } // ErrorAggregator allows to gather errors from different sources in one place type ErrorAggregator struct { flags Flag errors []element } func NewErrorAggregator() ErrorAggregator { return ErrorAggregator{flags: Flag{}, errors: make([...
package combatant import ( "fmt" "math/rand" "time" ) type Combatant struct { Name string MaxHp int CurrentHp int MaxDamage int } func (combatant *Combatant) Attack(opponent *Combatant) (int, bool) { rand.Seed(time.Now().Unix()) damage := rand.Intn(combatant.MaxDamage) + 1 opponent.CurrentHp -= ...
// 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 startstop import ( "context" "time" "github.com/shirou/gopsutil/v3/process" "chromiumos/tast/errors" "chromiumos/tast/testing" ) // TestMidis verifies midis ...
package ortb import ( "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/util/ptrutil" "github.com/prebid/prebid-server/util/sliceutil" ) func CloneApp(s *openrtb2.App) *openrtb2.App { if s == nil { return nil } // Shallow Copy (Value Fields) c := *s // Deep Copy (Pointers) c.Cat =...
package strategy type Operator interface{ Apply(int,int)int } type Operation struct{ Operator Operator } func (this *Operation)Operate(l,r int)int{ return this.Operator.Apply(l,r) } type Addition struct{} func (Addition) Apply(lval, rval int) int { return lval + rval }
/* * Quay Frontend * * This API allows you to perform many of the operations required to work with Quay repositories, users, and organizations. You can find out more at <a href=\"https://quay.io\">Quay</a>. * * API version: v1 * Contact: support@quay.io * Generated by: Swagger Codegen (https://github.com/swagger...
package main import ( "github.com/golang/protobuf/proto" "net/http" "fmt" "bytes" pb "github.com/dcmrlee/first-git-proj/go-lang/protobufExample/myproto" ) func main() { myClient := pb.Client{Id: 1234, Name: "Dcmrlee", Email: "lidachao@jd.com", Country: "China"} clientInbox :=...
//Merge-Interval Problem package main import ( "fmt" "sort" ) type Interval struct { Start, End int } func merge(intervals []Interval) []Interval { m := append([]Interval(nil), intervals...) if len(m) <= 1 { return m } sort.Slice(m, func(i, j int) bool { if m[i].Start < m[j].Start { return true ...
package modules import ( "fmt" "github.com/Aegon-n/sentinel-bot/handler/messages/en_messages" "github.com/dghubble/go-twitter/twitter" "github.com/dghubble/oauth1" "gopkg.in/telegram-bot-api.v4" "log" ) func Twitter_updates(bot *tgbotapi.BotAPI,update *tgbotapi.Update) { queryId := update.CallbackQuery.ID ...
package oomg import ( "github.com/sirupsen/logrus" "os" ) var log = logrus.New() func init() { env := os.Getenv("OOMG_ENV") if env == "development" { log.SetLevel(logrus.DebugLevel) } else { log.SetLevel(logrus.FatalLevel) } log.SetReportCaller(true) } //Well I suposed to be internal use but at least...
package systemd import ( "net/url" "path/filepath" "strings" "time" "github.com/cerana/cerana/acomm" "github.com/cerana/cerana/pkg/errors" "github.com/coreos/go-systemd/dbus" ) // UnitStatus contains information about a systemd unit. type UnitStatus struct { dbus.UnitStatus Uptime time.Duration ...
package odoo import ( "fmt" ) // StockImmediateTransfer represents stock.immediate.transfer model. type StockImmediateTransfer struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` CreateDate *Time `xmlrpc:"create_date,omptempty"` CreateUid *Many2One `xmlrpc:"create_uid,omptempty"` DisplayName...
package models import ( "encoding/json" "strings" "time" "github.com/markbates/validate" "github.com/markbates/validate/validators" "github.com/satori/go.uuid" ) // Race details a specific competition at an event type Race struct { ID uuid.UUID `json:"id" db:"id"` CreatedAt time.Time `json:"created_at...
package track import "github.com/I-Reven/Hexagonal/src/domain/entity" type Track interface { CreateTrack() (string, error) SaveTrack(id string, track *entity.Track) error DeleteTrack(id string) error GetTrack(id string) (entity.Track, error) AddMessage(id string, message string) error AddError(id string, error ...
// Copyright 2019 The gVisor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
package main import ( "archive/tar" "compress/bzip2" "compress/gzip" "fmt" "io" "os" "path/filepath" "regexp" ) // Update GeoLite2-Country.mmdb func UpdateGeoLite2Country() { Verbose("Updating GeoLite2-Country.mmdb") tmp_dir := os.TempDir() gzfile := filepath.Join(tmp_dir, "GeoLite2-Country.tar.gz") // ...
package api import ( "net/http" "strconv" "github.com/gin-gonic/gin" "themis/database" ) func GetId(c *gin.Context, key string) int { id, err := strconv.Atoi(c.Param(key)) if err != nil { AbortWithError(http.StatusBadRequest, err) } return int(id) } func GetKey(c *gin.Context, key string, minLen int) stri...
package main import "fmt" /* - Slices multi-dimensionais são slices que contem slices. - São como planilhas. - [][]type */ func main() { ss := [][]int{ // Índice:0 1 2 // Índice: []int{1, 2, 3, 4, 5, 6}, // 0 []int{7, 8, 9, 10, 11, 12}, // 1 []int{13, 14, 15, 16, 17, 18}, // 2 }...
package system import ( "festival/app/model" ) type SysUser struct { model.BaseModel Account string `form:"account" json:"account" binding:"required,gte=6" gorm:"not null;unique;primary_key;column:account;type:varchar(20);comment:账号;"` UserName string `form:"username" json:"username" binding:"required" gorm:"c...
package ru import ( "regexp" "strconv" "time" "github.com/olebedev/when/rules" "github.com/pkg/errors" ) /* "5pm" "5 pm" "5am" "5pm" "5A." "5P." "11 P.M." https://play.golang.org/p/w2PeQ3l_rp */ func Hour(s rules.Strategy) rules.Rule { return &rules.F{ RegExp: regexp.MustCompile("(?i)(?:\\W|^)" + ...
package model import "testing" func TestNew(t *testing.T) { output := New() if output == nil { t.Error("new constructor returning nil value") } }
// Copyright © 2014-2015 Daniele Tricoli <eriol@mornie.org>. // All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package config // import "eriol.xyz/perpetua/config" import ( "os" "path" "github.com/BurntSushi/toml" ) const ( DEFAULT_LA...
package controllers import ( "encoding/json" "log" "net/http" "books-list/models" "books-list/psql" "database/sql" "github.com/gorilla/mux" ) func logFatal(err error) { if err != nil { log.Fatal(err) } } type Controller struct { queries *psql.Queries } func CreateController(db *sql.DB) *Controller { ...
package alidns import ( "encoding/json" "fmt" "io" "io/ioutil" "log" "net/http" "net/url" "time" "github.com/google/uuid" ) const ( //ALIDNS 云解析API请求的资源地址 ALIDNS = "alidns.aliyuncs.com" apiVersion = "2015-01-09" sigVersion = "1.0" reqProtocol = "https" ) // ErrorResponse alidns 默认错误信息结构 type Er...
///todo: replace the flag to config.json package main import ( "flag" "fmt" "io/ioutil" "net/http" "strings" "time" ) const VERSION = "0.2.0" var ( help = flag.Bool("h", false, "Helps") client = flag.Int("c", 10, "Clients") seconds = flag.Int64("t", 60, "Seconds") url = flag.String("url", "", "URL"...
package main import ( "net/http" "os" "regexp" "github.com/chentanyi/gget/downloader" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) var ( uri string username *string password *string filename *string thread *int hashLen *string start ...
package authlete import ( "bytes" "encoding/json" "fmt" "io" "io/ioutil" "net/http" "net/url" "os" "time" "github.com/dodosuke/authlete-go/pkg/util" ) // Paths of Authlete API Server. const ( PathAuthAuthorization = "/api/auth/authorization" PathAuthAuthorizationFail = "/api/auth/authorizat...
package core import ( "crypto/sha256" "encoding/hex" "errors" "fmt" "regexp" "strings" ) const ( // This is the main regex where an address should confirm to. Much simpler than an email address ADDRESS_REGEX string = "(^[a-z0-9][a-z0-9\\.\\-]{2,63})(?:@([a-z0-9][a-z0-9\\.\\-]{1,63}))...
/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func swapPairs(head *ListNode) *ListNode { if head == nil { return nil } dummy := ListNode{} dummy.Next = head prev := &dummy cur := head for cur != nil && cur.Next != nil { temp := cur.Next ...
package main import ( "context" "encoding/json" "fmt" "github.com/graph-gophers/dataloader" "github.com/graphql-go/graphql" loader_fn "github.com/suaas21/grapgql-demo/books-authors-query/dataloader" graphql_objects "github.com/suaas21/grapgql-demo/books-authors-query/graphql-objects" "github.com/suaas21/grapgq...
package builder import ( "github.com/zlsgo/zdb/driver" ) // Builder is a general SQL builder type Builder interface { Build() (sql string, values []interface{}) } type compiledBuilder struct { args *buildArgs format string } var _ Builder = new(compiledBuilder) func (cb *compiledBuilder) Build() (sql string,...
package ravendb type IndexDefinition struct { Name string `json:"Name"` Priority IndexPriority `json:"Priority,omitempty"` LockMode IndexLockMode `json:"LockMode,omitempty"` AdditionalSources map[string]string `json:"...
package mcquery import ( "net" "time" ) type TimeoutConn struct { conn net.Conn timeout time.Duration } func (i TimeoutConn) Read(buf []byte) (int, error) { if err := i.SetDeadline(time.Now().Add(i.timeout)); err != nil { return 0, err } return i.conn.Read(buf) } func (i TimeoutConn) Write(buf []byte) (...
package parser import ( "github.com/bytesparadise/libasciidoc/pkg/types" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("block delimiter tracker", func() { It("should not be within delimited block", func() { // given t := newBlockDelimiterTracker() // then Expect(t.stack).To...
package packets import "bytes" import "io" type ConnreqPacket struct { ApiKey string DevId string Protocol string Keepalive uint16 FixedHeader } func (co *ConnreqPacket) Unpack(r io.Reader) error{ return nil } func (co *ConnreqPacket) Write(w io.Writer) error{ ...
package main import ( "os" logr "github.com/Sirupsen/logrus" prefixed "github.com/x-cray/logrus-prefixed-formatter" "starters/conts" ) func main() { logr.SetFormatter(new(prefixed.TextFormatter)) logr.SetLevel(logr.DebugLevel) log := logr.WithFields(logr.Fields{ "prefix": "Main", }) // ENV var env stri...
package main type ListNode struct { Val int Next *ListNode } func main() { // 链表测试用例 } func mergeKLists(lists []*ListNode) *ListNode { if len(lists) == 0 { return nil } else if len(lists) == 1 { return lists[0] } return mergeTwoLists(mergeKLists(lists[:len(lists)/2]), mergeKLists(lists[len(lists)/2:])) }...
// 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-2020 Datadog, Inc. package agent import ( "github.com/DataDog/datadog-operator/cmd/kubectl-da...
package provider import ( "github.com/kenlabs/pando/cmd/client/command/api" "github.com/spf13/cobra" ) const groupPath = "/provider" var joinAPIPath = api.JoinPathFuncFactory(groupPath) func NewProviderCmd() *cobra.Command { cmd := &cobra.Command{ Use: "provider", Short: "provider management commands", } ...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package gpucuj tests GPU CUJ tests on lacros Chrome and ChromeOS Chrome. package gpucuj import ( "context" "math" "time" "chromiumos/tast/common/perf" "chromiumos/t...
package main import ( "bufio" "fmt" "log" "os" "strings" ) func cardNumber(q string) bool { var e int s := strings.Split(q, "") t := make([]int, len(s)) for i := range s { fmt.Sscan(s[i], &t[i]) } for i := len(t) - 2; i >= 0; i -= 2 { t[i] *= 2 if t[i] > 9 { t[i] = t[i]%10 + 1 } } for i := ran...
package sgfw import ( "fmt" "net" "os/user" "strconv" "strings" "sync" "time" "github.com/godbus/dbus" "github.com/subgraph/fw-daemon/proc-coroner" ) var DoMultiPrompt = true const MAX_PROMPTS = 5 var outstandingPrompts = 0 var promptLock = &sync.Mutex{} func newPrompter(conn *dbus.Conn) *prompter { p :...
package main import ( "bufio" "fmt" "math/rand" "net" "sort" "strings" "sync" "time" ) type Rank struct { Name string Score int } var ( mux *sync.Mutex = &sync.Mutex{} words []string = []string{"sun", "hello", "world"} ranks []Rank ) type ByScore []Rank func (a ByScore) Len() int { ret...
// Copyright (c) 2016-2018, Jan Cajthaml <jan.cajthaml@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 require...
package main import ( "fmt" peerHelper "github.com/kenlabs/pando/pkg/util/peer" consumerSdk "github.com/kenlabs/pando/sdk/pkg/consumer" "time" ) const ( privateKeyStr = "CAESQAycIStrQXBoxgf2pEazDLoZbL8WCLX5GIb69dl4x2mJMpukCAPbzq1URPtKen4Bpxfz9et2exWhfAfZ/RG30ts=" pandoAddr = "/ip4/52.14.211.248/tcp/9013" ...
package cloudformation // AWSS3Bucket_ServerSideEncryptionByDefault AWS CloudFormation Resource (AWS::S3::Bucket.ServerSideEncryptionByDefault) // See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-bucket-serversideencryptionbydefault.html type AWSS3Bucket_ServerSideEncryptionByDefaul...
// Copyright (C) 2022 Storj Labs, Inc. // See LICENSE for copying information package time2_test import ( "context" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "storj.io/common/sync2" "storj.io/common/time2" ) const ( testDuration = time.Minute // Tests sho...
package dest import ( "fmt" "github.com/slack-go/slack" ) // channelは#をいれない。 func SlackSendContent(token, channel, content string) { fmt.Println(token) fmt.Println(content) c := slack.New(token) ch := "#" + channel _, _, err := c.PostMessage(ch, slack.MsgOptionText(content, true)) if err != nil { panic(er...
package dockeringo import ( "context" "fmt" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/mount" ) func (c *Controller) ContainerRun(image string, command []string, volumes []VolumeMount) (id string, err error) { hostConfig := cont...
package api import ( "github.com/gorilla/mux" "github.com/hsedjame/products-api/src/models" "github.com/hsedjame/products-api/src/repository" "net/http" "strconv" ) type ProductHandler struct { repoditory repository.ProductRepository } func NewProductHandler(productRepository repository.ProductRepository) *Pro...
package arrowtools import ( "fmt" "github.com/apache/arrow/go/arrow" "github.com/apache/arrow/go/arrow/array" ) type ColumnHelper struct { col *array.Column } // NewColumnHelper creates a ColumnHelper for the given column. It can // be used to extract data from the column as raw slices. func NewColumnHelper(co...
package checkout_test import ( "testing" "github.com/cheekybits/is" checkout "github.com/benhawker/checkout-go/checkout" products "github.com/benhawker/checkout-go/products" ) func TestCheckout_AddValidProduct(t *testing.T) { is := is.New(t) co, _ := setup() co.AddProduct(001, 2) is.Equal(co.Basket[001...
package main import ( "fmt" ) type Rpc interface { Call(cmd string) } type ClubRpc struct { } func (ClubRpc) Call(cmd string) { fmt.Println("cmd:", cmd) } func (ClubRpc) Call2(cmd string) { fmt.Println("cmd2: ", cmd) } func main() { var r *ClubRpc fmt.Println(r == nil) //var r1 ClubRpc //直接声明的结构题不能和 nil ...
package sqlite import ( "database/sql" "github.com/dpointeck/go-itsi/pkg/models" ) // BookModel - Sqlite Model type BookModel struct { DB *sql.DB } // Insert - This will insert a new snippet into the database. func (m *BookModel) Insert(title, isbn, released string) (int, error) { stmt, err := m.DB.Prepare(`IN...
package httpexpect import ( "net/http" "net/http/httptest" "testing" "github.com/valyala/fasthttp" ) func createRedirectHandler() http.Handler { mux := http.NewServeMux() mux.HandleFunc("/foo", func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte(`hello`)) }) mux.HandleFunc("/bar", func(w...
package murmurhash3 import ( "bytes" "crypto/rand" "encoding/binary" "testing" ) const ( expected128X64 uint32 = 0x6384BA69 expected128X86 uint32 = 0xB3ECE62A expected32X86 uint32 = 0xB0F57EE3 hashbytes128 int = 128 / 8 hashbytes32 int = 32 / 8 ) func TestValidityX86_32(t *testing.T) { key := m...
// test go's floating point performace package main func main() { for x := 0; x < 100000; x++ { a := float64(1) for i := 200; i < 221; i++ { a *= float64(i + x) } } }
package digraph // Edge represents a labeled or unlabeled directed edge between two // nodes of a graph type Edge interface { // Return the label of the edge. Label cannot be changed. Remove the // edge and add a new one with a different label GetLabel() interface{} // Return the target node GetTo() Node // Retu...