text
stringlengths
11
4.05M
package Dogcat import "fmt" type Animal interface { Bark() } type Dog struct { } func (d Dog) Bark() { fmt.Println("dog") } type Cat struct { } func (c *Cat) Bark() { fmt.Println("cat") } func Bark(a Animal) { a.Bark() } func getDog() Dog { return Dog{} } func getCat() Cat { return Cat{} } func main() {...
package main import ( "fmt" "github.com/brianseitel/charlatan" ) // Product ... type Product struct { UUID string `charlatan:"uuid"` Name string `charlatan:"name"` Brand string `charlatan:"name"` Price float64 `charlatan:"price"` Categories struct { Name string `charlatan:"word"` }...
package gopipe_test import ( "io/ioutil" "testing" "github.com/bingoohuang/golog" "github.com/bingoohuang/gopipe/pkg/gopipe" "github.com/stretchr/testify/assert" ) func TestParsePipelineConfig(t *testing.T) { config, err := ioutil.ReadFile("testdata/a.yaml") assert.Nil(t, err) c := &gopipe.PipelineConfig{}...
// Copyright 2021 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 ...
// 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 externaldata import ( "context" "crypto/sha256" "encoding/hex" "fmt" "net" "net/http" "net/url" "sync" "chromiumos/tast/errors" "chromiumos/tast/testing" ...
package html5 const ( preambleTmpl = `{{ if .Wrapper }}<div id="preamble"> <div class="sectionbody"> {{ end }}{{ .Content }}{{ if .Wrapper }}</div> {{ if .ToC }}{{ .ToC }}{{ end }}</div> {{ end }}` )
package main import ( "fmt" "log" "net/http" "path/filepath" "time" "github.com/docopt/docopt-go" "github.com/gin-gonic/gin" ginprometheus "github.com/mcuadros/go-gin-prometheus" "github.com/rmrf/robo/cli" "github.com/rmrf/robo/config" ) var version = "0.5.7" const usage = ` Usage: robo [--config fi...
package main import ( "flag" "net/http" "os" "strconv" "github.com/fils/goobjectweb/internal/api/graph" "github.com/fils/goobjectweb/internal/api/sitemaps" "github.com/fils/goobjectweb/internal/api/tika" "github.com/fils/goobjectweb/internal/digitalobjects" "github.com/fils/goobjectweb/internal/fileobjects" ...
package validate import ( "errors" "fmt" "regexp" "github.com/jrapoport/gothic/config" ) // Username validates a username. func Username(c *config.Config, username string) error { if c.Security.Validation.UsernameRegex == "" { return nil } else if username == "" { return errors.New("invalid username") } ...
package lc // Time: O(n^2) // Benchmark: 0ms 2mb | 100% func maxLengthBetweenEqualCharacters(s string) int { max := -1 for i := 0; i < len(s)/2; i++ { for j := len(s) - 1; j >= len(s)/2; j-- { if s[i] == s[j] { if j-i-1 > max { max = j - i - 1 } break } } } return max }
package sqlite import ( "database/sql" "encoding/json" "log" "github.com/edznux/wonderxss/config" "github.com/edznux/wonderxss/storage/models" sqlite3 "github.com/mattn/go-sqlite3" ) type Sqlite struct { file string db *sql.DB } func New() (*Sqlite, error) { cfg := config.Current file := cfg.Storages["...
package domain import "github.com/traPtitech/trap-collection-server/src/domain/values" type Seat struct { id values.SeatID status values.SeatStatus } func NewSeat(id values.SeatID, status values.SeatStatus) *Seat { return &Seat{ id: id, status: status, } } func (s *Seat) ID() values.SeatID { return...
package main import ( "12306.com/12306/common/middleware" "12306.com/12306/stations" "12306.com/12306/trains" "12306.com/12306/users" "github.com/gin-gonic/gin" ) func CollectRoute(r *gin.Engine) *gin.Engine { //users //注册 r.POST("/user/api/v1/register/", users.Register) //登录 r.POST("/user/api/v1/login/", u...
package controller import "time" const ( // Time allowed to write a message to the peer. writeWait = 10 * time.Second // Time allowed to read the next pong message from the peer. pongWait = 60 * time.Second // Send pings to peer with this period. Must be less than pongWait. pingPeriod = (pongWait * 9) / 10 ...
// Generate SDK from Examle Doc site // +build ignore package main import ( "bytes" "flag" "fmt" "go/format" "io/ioutil" "log" "os" "path" "strings" "text/template" "github.com/PuerkitoBio/goquery" ) var ( docIndex = flag.String("doc", "./api/index.html", "Original doc from") apis []*API ) type E...
package requests import ( "fmt" "net/url" "strings" "github.com/google/go-querystring/query" "github.com/atomicjolt/canvasapi" ) // GetFormattedStudentNumericalAnswer Matches the intended behavior of the UI when a numerical answer is entered // and returns the resulting formatted number // https://canvas.instr...
// 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 wifiutil import ( "bytes" "context" "net" "time" "github.com/golang/protobuf/ptypes/empty" "github.com/google/gopacket" "github.com/google/gopacket/layers" ...
package v1alpha1 import ( "fmt" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "code.cloudfoundry.org/quarks-operator/pkg/kube/apis" ) // This file is safe to edit // It's used as input for the Kube code generator // Run "make generate" after modifying thi...
// Copyright 2021 The LUCI 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...
package main import ( "bufio" "fmt" "os" "path/filepath" "strconv" "strings" ) const MaxUint = ^uint(0) const MaxInt = int(MaxUint >> 1) type Point2d struct { Id int X int Y int } func (p Point2d) String() string { return fmt.Sprintf("{%d, %d, %d}", p.Id, p.X, p.Y) } func main() { // parse input into ...
// Copyright (c) 2018-present, MultiVAC Foundation. // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. package wire import ( "fmt" "io" "github.com/multivactech/MultiVAC/model/shard" "github.com/multivactech/MultiVAC/base/rlp" ) // MsgB...
package sqrtx import ( "testing" ) func TestMySqrt(t *testing.T) { tests := []struct { in int want int }{ { in: 1000001, want: 1000, }, { in: 8, want: 2, }, { in: 144, want: 12, }, { in: 0, want: 0, }, { in: 4, want: 2, }, } for _, test := range t...
package consistent import ( "bytes" "encoding/binary" "fmt" "github.com/cespare/xxhash" "sort" "sync" ) type Hashing interface { AddNode(nodeID uint64) RemoveNode(nodeID uint64) GetNode(key interface{}) uint64 GetNodes(key interface{}, num int) []uint64 } type uint64Slice []uint64 type Consistent struct {...
package main import ( "bufio" "fmt" "io" "os" ) func main() { f, err := os.Open("input.csv") if err != nil { panic(err) } r := bufio.NewReader(f) m := make(map[string]map[string]int) for { date, err := r.ReadString(',') if err == io.EOF { break } date = date[:10] if err != nil { panic(err...
import "strconv" /* * @lc app=leetcode id=150 lang=golang * * [150] Evaluate Reverse Polish Notation * * https://leetcode.com/problems/evaluate-reverse-polish-notation/description/ * * algorithms * Medium (35.80%) * Likes: 1031 * Dislikes: 471 * Total Accepted: 229.5K * Total Submissions: 635.5K * T...
// 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 string import ( "fmt" "github.com/project-flogo/core/data/coerce" "strings" "github.com/project-flogo/core/data" "github.com/project-flogo/core/data/expression/function" ) func init() { function.Register(&fnReplace{}) } type fnReplace struct { } func (fnReplace) Name() string { return "replace" } f...
// Copyright (c) 2018, Sylabs Inc. All rights reserved. // This software is licensed under a 3-clause BSD license. Please consult the // LICENSE.md file distributed with the sources of this project regarding your // rights to use or distribute this software. package client import ( "context" "encoding/json" "fmt" ...
// Copyright (C) 2017 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 proc import ( "github.com/MagalixCorp/magalix-agent/v2/watcher" karma "github.com/reconquest/karma-go" ) // GetPodStatus a helper function to get the status of a pod func GetPodStatus(pod Pod) watcher.Status { context := karma. Describe("application_id", pod.ApplicationID). Describe("service_id", pod.S...
package main import ( "log" "net/http" "github.com/SamuelRamond/xauth" "github.com/SamuelRamond/xauth/store/boltdb" "github.com/SamuelRamond/xauth/web" "github.com/gorilla/mux" "github.com/rs/cors" ) func makeHandler(h func(w http.ResponseWriter, r *http.Request)) http.Handler { return http.HandlerFunc(h) }...
package main import ( "fmt" "unsafe" ) // unsafe包提供了一些跳过go语言类型安全限制的操作 func main() { var hello = Hello{} // 返回类型v本身数据所占用的字节数 // 返回值是“顶层”的数据占有的字节数 // 例如,若v是一个切片,它会返回该切片描述符的大小,而非该切片底层引用的内存的大小 s := unsafe.Sizeof(hello) fmt.Println(s) // 返回类型v所代表的结构体字段在结构体中的偏移量,它必须为结构体类型的字段的形式 // 换句话说,它返回该结构起始处与该字段起始处之间的字节数 ...
package pgpmail import ( "bytes" "io" "io/ioutil" "strings" "testing" "github.com/ProtonMail/go-crypto/openpgp" pgperrors "github.com/ProtonMail/go-crypto/openpgp/errors" ) func checkSignature(t *testing.T, md *openpgp.MessageDetails) { primaryKeyId := testPrivateKey.PrimaryKey.KeyId if md.SignatureError !=...
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you...
package gotojs import ( "net/http" "time" ) func ExampleContainer_handlerbinding() { // Initialize the container. container := NewContainer() // Declare a Hello World handler function. container.ExposeHandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello World! This data is not tra...
package httpexpect import ( "math" "testing" "github.com/stretchr/testify/assert" ) func TestNumberFailed(t *testing.T) { chain := makeChain(newMockReporter(t)) chain.fail("fail") value := &Number{chain, 0} value.chain.assertFailed(t) value.Path("$").chain.assertFailed(t) value.Schema("") value.Equal(...
package pixivapi import ( "os" "testing" ) func TestClient_IllustDetail(t *testing.T) { c := New() _, err := c.Login(os.Getenv("PIXIV_USERNAME"), os.Getenv("PIXIV_PASSWORD")) if err != nil { t.Errorf("Client.Login() experienced error %v", err) } x, err := c.IllustDetail(54642357) t.Log(x.Illust.PageCount)...
// Copyright (C) 2017 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 ( "fmt" "github.com/BTBurke/gitkit" "log" "os" ) func main() { fmt.Println("This example shows a basic dual HTTP and SSH server running on ports 8080 and 2222 respectively.\n\n**Warning** Don't use this model in production as nothing is secured. You should look at the other examples for how ...
// 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 main import "fmt" // func IsEqual(x, y int) bool { // return x == y // } // func IsEqual(x, y interface{}) bool { // func IsEqual(x, y any) bool { // return x == y // } func IsEqual[T comparable](x, y T) bool { return x == y } func main() { fmt.Println(IsEqual(10, 12)) fmt.Println(IsEqual("hello", "he...
package tezos import ( "fmt" "net/url" "github.com/trustwallet/blockatlas/pkg/blockatlas" ) type Client struct { blockatlas.Request } func (c *Client) GetTxsOfAddress(address string) ([]Tx, error) { var account Op path := fmt.Sprintf("account/%s/op", address) err := c.Get(&account, path, url.Values{"limit": ...
package main import ( "flag" "fmt" "log" "os" "runtime" "runtime/pprof" "sort" "strconv" "time" ) var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to `file") var memprofile = flag.String("memprofile", "", "write memory profile to `file`") //ProcessFiles reads dictionaty from dictPath and ca...
package controllers import ( "github.com/revel/revel" "github.com/MoonBabyLabs/kekcontact" "encoding/json" "github.com/MoonBabyLabs/kekaccess" "github.com/MoonBabyLabs/kekspace" ) type App struct { *revel.Controller } func (c App) Index() revel.Result { return c.Render() } func (c App) Token() revel.Result {...
package model // Type Type type Type interface { // @GetName 名称 GetName() string // @GetValue 值 GetValue() int // @GetPkgPath pkgPath GetPkgPath() string // @IsPtrType 是否指针类型 IsPtrType() bool // @Interface 实例化一个类型对应的数据值 Interface() (Value, error) // Elem 获取要素类型(如果非slice,则返回的是本身,如果是slice,则返回slice的elem类型) El...
package server import ( "github.com/gin-gonic/gin" "go.rock.com/rock-platform/rock/server/database" "go.rock.com/rock-platform/rock/server/log" middleware "go.rock.com/rock-platform/rock/server/middleware" "go.rock.com/rock-platform/rock/server/routerEngine" ) type Server struct { Logger *log.Logger ...
package main import ( "io/ioutil" "net/http" "html/template" "regexp" "./handlers.go" ) type Page struct { Title string Body []byte } // Global cache variable. var templates = template.Must(template.ParseFiles("edit.html", "view.html")) var validPath = regexp.MustCompile("^/(edit|save|vie...
package setting import ( "os" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) // InitLogger custom logger for app func InitLogger() *zap.Logger { encoder := zapcore.NewJSONEncoder(zapcore.EncoderConfig{ MessageKey: "msg", LevelKey: "level", EncodeLevel: zapcore.CapitalLevelEncoder, TimeKey: ...
package docker_test import ( "bytes" "io" "io/ioutil" "os" "os/exec" "github.com/cloudcredo/cloudfocker/config" "github.com/cloudcredo/cloudfocker/docker" . "github.com/cloudcredo/cloudfocker/Godeps/_workspace/src/github.com/onsi/ginkgo" . "github.com/cloudcredo/cloudfocker/Godeps/_workspace/src/github.com/...
package bigger import ( "bytes" "compress/gzip" "crypto/md5" "encoding/hex" "github.com/labstack/echo/v4" "github.com/sxueck/k8sodep/model" "io" "log" "net/http" "os" "path" "strconv" ) func DecompressData(compressedData []byte) ([]byte, error) { reader, err := gzip.NewReader(bytes.NewReader(compressedDa...
package main import ( "bytes" "flag" "fmt" "github.com/0xjbb/scyllago" "github.com/bwmarrin/discordgo" ) type ScyllaCfg struct{ session *discordgo.Session message *discordgo.MessageCreate size int start int maxSize int } // $scylla -username Joe Blogs -password test -size 5 -start 0 func ScyllaNew(session ...
package cmd import ( "fmt" "testing" "github.com/klauspost/reedsolomon" ) // /*https://golangcode.com/mocking-s3-upload/ */ // Test performs a simple test to demonstrate some reedsolomon stuff. Go make a better test after RS has been incorporated into the slab properly func Test(t *testing.T) { slab1 := NewS...
package main import ( "flag" "log" "github.com/awslabs/aws-virtual-gpu-device-plugin/pkg/gpu/nvidia" ) var ( vGPU = flag.Int("vgpu", 10, "Number of virtual GPUs") ) const VOLTA_MAXIMUM_MPS_CLIENT = 48 func main() { flag.Parse() log.Println("Start virtual GPU device plugin") if *vGPU > VOLTA_MAXIMUM_MPS_CLI...
package ip import ( "errors" "fmt" "github.com/cenkalti/backoff" "io/ioutil" "net" "net/http" "reflect" "strconv" "strings" "time" ) func getIPBy(dest string) (net.IP, error) { b := backoff.NewExponentialBackOff() b.InitialInterval = 100 * time.Millisecond b.MaxElapsedTime = 10 * time.Second b.Multiplie...
package moby // Adapted from // https://github.com/moby/moby/blob/ecb898dcb9065c8e9bcf7bb79fd160dea1c859b8/pkg/archive/archive_windows.go /* Copyright 2013-2018 Docker, 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 obt...
// Copyright © 2020 The Knative 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 agr...
package search_test import ( "fmt" "testing" "github.com/carolove/Golang/algorithms/datageneration" "github.com/carolove/Golang/algorithms/search" ) func TestChecksumSearch(t *testing.T) { vec := datageneration.GenerationVector() va, vb, isFound := search.ChecksumSearch(vec, 52) if isFound { fmt.Println(va,...
package models import ( "context" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" ) // 商品详情 type ProductDetail struct { ComID int64 `json:"com_id" bson:"com_id"` ProductID int64 `json:"product_id" bson:"product_id"` ProductName string `json:"product_name" bson:"product_name"` A...
// 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 wmp import ( "context" "regexp" "strings" "time" "chromiumos/tast/ctxutil" "chromiumos/tast/errors" "chromiumos/tast/local/apps" "chromiumos/tast/local/chro...
package nsqd import ( "bytes" "container/heap" "errors" "math" "strings" "sync" "sync/atomic" "time" "github.com/nsqio/go-diskqueue" "github.com/nsqio/nsq/internal/lg" "github.com/nsqio/nsq/internal/pqueue" "github.com/nsqio/nsq/internal/quantile" ) type Consumer interface { UnPause() Pause() Close() ...
// Copyright 2020 Liquidata, 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 to...
package gokafka import "testing" func TestGetmetadata(t *testing.T) { _, err := GetMetaData("kafka.test:9092", "test", 0, "gokafka") if err != nil { t.Error("could not get metadata of topic(test) from server(kafka.test)") t.Error(err) } _, err = GetMetaData("kafka.test:80", "test", 0, "gokafka") if err != n...
package server // NewHerokuServer - create new Heroku Server with confguration func NewHerokuServer(params *Config) (server *Server) { server = &Server{ Host: params.Host, Port: params.Port, Single: params.Single, Stats: Stats{}, pool: make(ProxyPackMap), spaceSignal: make(SpaceSignal), } ...
package main import "fmt" func main() { month := 6 s := Season(month) fmt.Printf("this month is %s", s) } func Season(m int) (s string) { switch m { case 3, 4, 5: s = "Spring" case 6, 7, 8: s = "Summer" case 9, 10, 11: s = "Fall" case 12, 1, 2: s = "Winter" } return s }
package main import "fmt" func sortColors(nums []int) { right := len(nums) - 1 left := 0 current := 0 for current < right { if nums[current] == 0 { nums[current], nums[left] = nums[left], nums[current] left++ current++ } else if nums[current] == 2 { nums[current], nums[right] = nums[right], nums[c...
package utils import ( "fmt" "holdempoker/models" "strconv" "strings" "github.com/bradfitz/slice" ) //PokerHandUtil 포커 족보 유틸 type PokerHandUtil struct { hands []interface{} } // CheckHands 족보를 체크한다. func (p *PokerHandUtil) CheckHands(cards []int) models.HandResult { var result models.HandResult var funcRef...
package output import ( "fmt" "strings" "github.com/mandelsoft/cmdint/pkg/cmdint" "github.com/afritzler/garden-examiner/cmd/gex/const" "github.com/afritzler/garden-examiner/cmd/gex/context" "github.com/afritzler/garden-examiner/cmd/gex/util" . "github.com/afritzler/garden-examiner/pkg/data" ) type TableProce...
package main func main() { } func selectSort(array []int) { if len(array) < 2 { return } for i:=0; i < len(array); i++ { min := i for j := i+1; j < len(array); j++ { if array[min] > array[j] { min = j } } if min != i{ array[min], array[i] = array[i], array[min] } } }
package requests import ( "fmt" "net/url" "strings" "github.com/atomicjolt/canvasapi" ) // AddToolToRceFavorites Add the specified editor_button external tool to a preferred location in the RCE // for courses in the given account and its subaccounts (if the subaccounts // haven't set their own RCE Favorites). Ca...
package lang import ( "fmt" ) type number struct { value int64 } func MakeNumber(v int64) *number { return &number{v} } func (n *number) String() string { return fmt.Sprintf("%v", n.value) } func (n *number) Equal(o Expr) bool { switch other := o.(type) { case *number: return n.value == other.value defaul...
package elevengo import ( "net" "net/http" "net/http/cookiejar" ) type Client struct { jar http.CookieJar hc *http.Client ua string info *_UserInfo offline *_OfflineToken } func New(opts *Options) *Client { if opts == nil { opts = NewOptions() } // core component d := &net.Dialer{ Timeout: opts...
package aliyun type IAliYunClient interface { GetResponse(path string, clinetInfo interface{}, bizData interface{}) []byte GetHeaderMap(path string, clientInfo interface{}, bizData interface{}) map[string]string }
package main import ( "bufio" "fmt" "log" "os" "strings" ) func guessNumber(q string) int { s := strings.Fields(q) var c, lo, hi int fmt.Sscan(s[0], &hi) s = s[1 : len(s)-1] for _, i := range s { if i == "Lower" { hi = (lo+hi)/2 + c - 1 } else { lo = (lo+hi)/2 + c + 1 } c = (lo + hi) % 2 } r...
package loader // This file parses a fragment of C with libclang and stores the result for AST // modification. It does not touch the AST itself. import ( "errors" "go/ast" "go/token" "strconv" "strings" "unsafe" ) /* #include <clang-c/Index.h> // if this fails, install libclang-7-dev #include <stdlib.h> int ...
package transeq import ( "bytes" "context" "fmt" "io" ) const ( mb = 1 << (10 * 2) // size of the buffer for writing to file maxBufferSize = 1 * mb // suffixes to add to sequence id for each frame suffixes = "123456" // max line size for the output file maxLineSize = 60 // specific codons stop = '*' ...
// Collection data structure for database package db import ( "encoding/json" "fmt" "github.com/gophergala/echodb/dbcore" "github.com/gophergala/echodb/dbwebsocket" "math/rand" "os" "path" "strconv" ) const ( INDEX_FILE = "_idx" ) type Collection struct { db *Database name string parts []*dbcore.Part...
package runtime_test import ( "testing" "github.com/bmizerany/assert" "github.com/gonitor/gonitor/service/runtime" ) // TestServiceGetGoOS . func TestServiceGetGoOS(test *testing.T) { result := runtime.ServiceGetGoOS() assert.Equal(test, len(result) > 0, true) }
package wallet import ( "../block" "../transaction" ) type Wallet struct { Address string Amount uint64 Timestamp uint32 Height uint32 TxList []transaction.Transaction Fee []block.Block } var Wallets = make(map[string]Wallet) func TransferMoney(bl block.Block) { var miner string var fee ...
package communications import ( "context" "encoding/json" "github.com/niolabs/gonio-framework" "github.com/pubkeeper/go-client" ) type PublisherBlock struct { nio.Consumer client.Connection config PublisherBlockConfig } type PublisherBlockConfig struct { nio.BlockConfigAtom Topic string `json:"topic"` } ...
package main import ( "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/sqlite" "qor-admin-3/admin" ) func main() { // Set up the database DB, _ := gorm.Open("sqlite3", ":memory:") r := gin.New() a := admin.New(DB, "", "secret") a.Bind(r) r.Run("127.0.0.1:8080") }
package recaptcha import ( "bytes" "encoding/json" "fmt" "io" "io/ioutil" "net/http" "os" "strings" "time" "github.com/sirupsen/logrus" ) func init() { logrus.SetLevel(logrus.DebugLevel) } const ( // recaptcha API to ensure the token is valid reCAPTCHALink = "https://www.google.com/recaptcha/api/siteve...
package odoo import ( "fmt" ) // AccountTaxReport represents account.tax.report model. type AccountTaxReport struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` CompanyId *Many2One `xmlrpc:"company_id,omptempty"` CreateDate *Time `xmlrpc:"create_date,omptempty"` CreateUid *Many2One `xm...
package response 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/tools" "github.com/golang/protobuf/proto" ) type HeroQuitResp...
package gntagger_test import ( "io/ioutil" "os" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "testing" ) const ( pathLong = "./testdata/seashells_book.txt" pathShort = "./testdata/short.txt" pathNamesAnnot = "./testdata/names_annot.json" ) var ( dataLong []byte dataShort []...
package main import ( "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" "time" ) var DogeTestNet3GenesisHash = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy. }) //0xe9, 0x55, 0x05, 0x37, 0x0d, 0x4c, 0x3f, 0x46, 0x65, 0xbd, 0x98, 0x1...
package main /** * @website http://albulescu.ro * @author Cosmin Albulescu <cosmin@albulescu.ro> */ import ( "bytes" "fmt" "io" "log" "net/http" "os" "path" "strconv" "time" ) /** * Is called when progress changes */ type ProgressOutput interface { UpdateProgress(progress float64) } type DownloaderWit...
package main import ( "bufio" "errors" "flag" "io" "os" "strconv" "strings" ) type configuration struct { MFA string Region string Bucket string BatchSize int RateLimit int CFactor int CMax int Quiet bool Debug bool SkipFile string } func (conf *configuration) Load() erro...
package main import ( "fmt" "io/ioutil" "log" "net/http" "time" jwt "github.com/dgrijalva/jwt-go" "github.com/dgrijalva/jwt-go/request" ) func CheckAuth() Middleware { return func(f http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { token, err := request.ParseFrom...
package main import ( //"fmt" "strconv" "testing" "net/http" "github.com/ant0ine/go-json-rest/rest/test" "github.com/bcolucci/moocapic-rating/rating" ) var handler http.Handler func Setup() { conf := rating.DevConf() api = rating.NewApi(conf) handler = api.MakeHandler() api.Database.DropDatabase() } func ...
package unifi import ( "bytes" "encoding/json" "net/http" ) // SiteRougeAccessPoint defines a rouge/neighboring access point data type SiteRougeAccessPoint struct { ID string `json:"_id"` Age int `json:"age"` AccessPointMAC string `json:"ap_mac"` Band stri...
// 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 query import ( "github.com/keptn-contrib/dynatrace-service/internal/sli/unit" "testing" ) func TestScaleData(t *testing.T) { if unit.ScaleData("", "MicroSecond", 1000000.0) != 1000.0 { t.Errorf("ScaleData incorrectly scales MicroSecond") } if unit.ScaleData("", "Byte", 1024.0) != 1.0 { t.Errorf("Scal...
package testdefinition import ( "fmt" "path" argov1 "github.com/argoproj/argo/v2/pkg/apis/workflow/v1alpha1" apiv1 "k8s.io/api/core/v1" tmv1beta1 "github.com/gardener/test-infra/pkg/apis/testmachinery/v1beta1" "github.com/gardener/test-infra/pkg/testmachinery" "github.com/gardener/test-infra/pkg/testmachinery...
package courses import ( "bufio" "fmt" "io" "log" "net/http" "os" "strconv" "strings" "time" ) // Course - main struct for course info (№, name, url) type Course struct { CourseNum int CourseName string CourseURL string } func CreateFolderForCourses() { os.Mkdir("./lessons", 0777) } // Download - dow...
package db import ( "database/sql" _ "github.com/go-sql-driver/mysql" "github.com/jmoiron/sqlx" "github.com/ocoscope/face/utils" ) const ( CREATE_USER = ` INSERT INTO users (email, password, first_name, last_name, patronymic_name, number, position, photo, face, access_token, role_id) VALUES (?, ?, ?, ?,...
package main import ( "fmt" "github.com/gin-gonic/gin" "github.com/smartwalle/alipay/v3" "github.com/smartwalle/xid" "log" "net/http" ) var aliClient *alipay.Client const ( kAppId = "2016073100129537" kPrivateKey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC4UOTKtDstRrjyNPvek9eGqv1RYDmHtLw7...
package collections import "time" type KeyObj struct { Key string lru time.Time } func NewKeyObj(key string) *KeyObj { return &KeyObj{ Key: key, lru: time.Now(), } } func (k *KeyObj) IdleTime() time.Duration { return time.Now().Sub(k.lru) } func (k *KeyObj) UpdateTime() { k.lru = time.Now() } func (k *K...
package main // Leetcode 172. (easy) func trailingZeroes(n int) int { count := 0 for n >= 5 { count += n/5 n /= 5 } return count }
// Copyright (c) 2016-2019 Uber Technologies, 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...
package wire type RepoAccessQuery struct { User string Path string } type RepoAccessInfo struct { Path string Push bool } type CreateRepo struct { Name string Description string Public bool } // Repo is used to export basic information about a repository. // Public states whether a repository is ...