text
stringlengths
11
4.05M
package http import ( "bytes" "io/ioutil" "net/http" ) func Get(url string, data []byte, headers map[string]string) (*http.Response, []byte, error) { body := bytes.NewReader(data) req, err := http.NewRequest("GET", url, body) if err != nil { return nil, nil, err } for k, v := range headers { req.Header.Se...
package codecs // Codec foo type Codec interface { Foo(msg string) } // Codecs foo type Codecs map[string]Codec // CodecFunc foo type CodecFunc func(c Codecs) // AddCodec foo func AddCodec(name string, codec Codec) CodecFunc { return func(c Codecs) { c[name] = codec } } // User foo type User struct { Codecs ...
package main import ( "context" "fmt" "net/url" "strings" "github.com/hashicorp/errwrap" "github.com/hashicorp/vault/sdk/framework" "github.com/hashicorp/vault/sdk/helper/tokenutil" "github.com/hashicorp/vault/sdk/logical" ) func (b *backend) pathConfig() *framework.Path { p := &framework.Path{ Pattern: "...
package main import ( "fmt" "math/rand" "time" ) func main() { rand.Seed(time.Now().UnixNano()) const geneSet = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!." target := "Not all those who wander are lost." calc := func(candidate string) int { return getFitness(target, candidate) } start := time...
package room import "errors" var ( ErrMessageIsNil = errors.New("message is nil") ErrChatMessageIsEmpty = errors.New("chat message is empty") )
package services import ( "KServer/manage" "KServer/proto" "KServer/server/utils/msg" "fmt" "time" ) type UnLock struct { m manage.IManage } func NewUnLock(m manage.IManage) *UnLock { return &UnLock{m: m} } func (u *UnLock) UnlockHandle(data proto.IDataPack) { //fmt.Println("收到请求",data.GetMsgId()) switch ...
/* * @lc app=leetcode.cn id=1725 lang=golang * * [1725] 可以形成最大正方形的矩形数目 */ // @lc code=start package main func countGoodRectangles(rectangles [][]int) int { maxLen := 0 count := 0 for i := 0; i < len(rectangles); i++ { curLen := 0 if rectangles[i][0] > rectangles[i][1] { curLen = rectangles[i][1] } els...
package main import ( "bufio" "fmt" "io" "log" pb "myapp/models/grpc/service/echo" "os" "golang.org/x/net/context" "google.golang.org/grpc" ) const ( address = "192.168.34.134:50051" ) func echoTimeService(c pb.EchoClient) { stream, err := c.EchoTime(context.Background(), &pb.Request{Message: "time strea...
package cars import ( "fmt" "github.com/astaxie/beego" "github.com/astaxie/beego/logs" "github.com/astaxie/beego/orm" "ions_zhiliao/models/auth" "ions_zhiliao/utils" "math" "time" ) type CarsApplyController struct { beego.Controller } func (c *CarsApplyController) Get() { o := orm.NewOrm() var cars_data [...
package arch import ( "jugonz/chip8/src/gfx" "testing" ) func TestSetup(t *testing.T) { c8 := MakeChip8(false) if c8.PC != 0x200 { t.Errorf("c8 Opcode was not initialized properly! Was: %v\n", c8.Opcode) } // Check fontset. for i := 0; i < 80; i++ { if c8.Fontset[i] == 0x00 { t.Errorf("c8 Fontset wa...
/* Copyright 2021 The KubeVela 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, softw...
package queue import ( "queueman/libs/queue/rabbitmq" "queueman/libs/queue/redis" ) // QInterface queue interface type QInterface interface { Dispatcher(queueConfig interface{}) } // QFactory queue factory func QFactory(queueType string) QInterface { switch queueType { case "RabbitMQ": return &rabbitmq.Queue{...
// Copyright (c) 2020 by meng. All rights reserved. // Use of this source code is governed by an MIT-style // license that can be found in the LICENSE file. /** * @Author: meng * @Description: * @File: stack * @Version: 1.0.0 * @Date: 2020/4/10 16:24 */ package base import "sync" type StackValue interface {...
package main import ( "regexp" "strconv" ) var hclrex *regexp.Regexp = regexp.MustCompile("^#([0-9a-f]{6})$") var eclrex *regexp.Regexp = regexp.MustCompile("^(amb|blu|brn|gry|grn|hzl|oth)$") var pidrex *regexp.Regexp = regexp.MustCompile("^(\\d{9})$") type check func(map[string]string) bool func and(p map[string...
package types type AddressList []*Address type AddressToBool func(*Address) bool func (al AddressList)Filter(f AddressToBool) AddressList { var ret AddressList for _, a := range al { if f(a) { ret = append(ret, a) } } return ret }
package proxy import ( "context" "fmt" "strconv" "testing" "github.com/golang/protobuf/proto" "github.com/milvus-io/milvus/internal/log" "github.com/milvus-io/milvus/internal/proto/commonpb" "github.com/milvus-io/milvus/internal/proto/internalpb" "github.com/milvus-io/milvus/internal/proto/milvuspb" "github...
/* Overview Given an image in plain PPM (P3) format as input, for each pixel p in the image, replace each of the following 4 pixels' red, green, and blue with the floored average value of the respective channels of all 4 pixels: p itself The pixel located at p's location when the image is flipped vertically The pix...
package sese import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document03800102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:sese.038.001.02 Document"` Message *SecuritiesSettlementTransactionModificationRequestV...
package ircserver import "gopkg.in/sorcix/irc.v2" type modeCmd struct { Mode string Param string } type modeCmds []modeCmd func (cmds modeCmds) IRCParams() []string { var add, remove []modeCmd for _, mode := range cmds { if mode.Mode[0] == '+' { add = append(add, mode) } else { remove = append(remove...
package benchmark import ( "database/sql" ) type PilotXorm struct { Id int `xorm:"pk"` Name string `xorm:"not null"` Languages []LanguageXorm `xorm:"extends"` } type JetXorm struct { ID int `xorm:"pk"` PilotID int `xorm:"not null"` AirportID int `xorm:"not n...
package errmsg const ( SUCCSE = 200 ERROR = 500 // code= 1000... user error ERROR_USERNAME_USED = 1001 ERROR_PASSWORD_WRONG = 1002 ERROR_USER_NOT_EXIST = 1003 ERROR_TOKEN_EXIST = 1004 ERROR_TOKEN_RUNTIME = 1005 ERROR_TOKEN_WRONG = 1006 ERROR_TOKEN_TYPE_WRONG = 1007 ERROR_USER_NO_RIGHT ...
/* Copyright 2021 The KubeVela 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, softw...
package main import ( "fmt" "os" ) /** * Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders. **/ func main() { // lightX: the X position of the light of power // lightY: the Y position of the light of power // initialTX: Thor's starting X p...
package terminal import ( "fmt" "strings" "github.com/10gen/realm-cli/internal/utils/flags" ) // set of supported terminal flags const ( FlagAutoConfirm = "yes" FlagAutoConfirmShort = "y" FlagAutoConfirmUsage = "Automatically proceed through CLI commands by agreeing to any required user prompts" FlagDis...
//return statement in a function with a return type package main; func main () { } func pain () int { return; }
package yai // Bucket retrieves manifest files. // NB: Manifest files could be on disk, online, ftp server... type Bucket interface { // app should be the name of the application you want to install. Get(app string) (Manifest, error) } // Shim abstracts how the executables are put on the system path. type Shim int...
package main import f "fmt" type test interface { } func main() { var i test f.Println(i) }
package main import ( "errors" "github.com/khomkovova/MonoPrinterTerminal/api" "github.com/khomkovova/MonoPrinterTerminal/constant" "github.com/khomkovova/MonoPrinterTerminal/helper" "github.com/khomkovova/MonoPrinterTerminal/storage_helper" "github.com/khomkovova/MonoPrinterTerminal/storage_helper/csv_helper" ...
/* Package is to support getting an IP address from a client's browser and returing IP Address It provides functionality comparable to http://jsonip.appspot.com */ package getipaddress import ( "encoding/json" "net/http" ) func init() { http.HandleFunc("/GetClientIPAddress", handlerGetClientIPAddress) } func h...
package p03 func isPowerOfFour(num int) bool { if num <= 0 { return false } if num == 1 { return true } k := 4 for k <= num { if k == num { return true } k = 4 * k } return false }
package cli import ( "encoding/json" "flag" "fmt" "github.com/kohirens/stdlib" "github.com/kohirens/stdlib/log" "io/ioutil" "os" "path/filepath" "regexp" "strings" ) type Config struct { AnswersJson *AnswersJson // data use for template processing AnswersPath string // flag to get the path to ...
package discount import ( "encoding/json" "sort" "github.com/amanbolat/furutsu/internal/cart" ) type Rule interface { // Check checks if the given items satisfy the rule. // If true it returns set of product_ids and discount applied // also the set items left without discount Check(map[string]cart.Item) (disc...
// Copyright 2019-present Open Networking Foundation. // // 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 applica...
package main import "fmt" func temp(name string){ for i:=0; i<3; i++{ fmt.Println(name,":",i) } } func main(){ temp("sushil") go temp("sanjay") go func(str string){ fmt.Println(str) }("bhile") // needs some pause till execution of asynchronous go-routine completes for i:=0;i<100000000;i++{} // fmt.Sc...
package users import "github.com/jinzhu/gorm" type User struct { gorm.Model AuthID string `json:"AuthId" gorm:"not null;unique"` IsAdmin bool `json:"IsAdmin"` }
package requests import ( "encoding/json" "testing" "github.com/mitchellh/mapstructure" "github.com/stretchr/testify/assert" ) func TestDecodeWorkGenerateRequest(t *testing.T) { encoded := `{"action":"work_generate","hash":"my hash","difficulty":"my difficulty","subtype":"my subtype","bpow_key":"my bpow key"}` ...
package main import ( "bufio" "fmt" "os" "github.com/alexandervantrijffel/gonats/eventsourcing" "github.com/alexandervantrijffel/gonats/eventsourcing/examples/bitcoinwallet/contracts" "github.com/alexandervantrijffel/gonats/eventsourcing/examples/bitcoinwallet" ) func main() { repo, err := eventsourcing.NewR...
package testdata import ( "github.com/frk/gosql/internal/testdata/common" ) type SelectWithOffsetFieldQuery struct { Users []*common.User `rel:"test_user:u"` Offset int }
package resolver import ( "github.com/taktakty/netlabi/models" genModels "github.com/taktakty/netlabi/models/generated" "context" "github.com/jinzhu/gorm" ) func (r *mutationResolver) CreateDevice(ctx context.Context, input genModels.CreateDeviceInput) (*models.Device, error) { var device models.Device device.N...
package controllers type EchartController struct { BaseController } //URLMapping st func (c *EchartController) URLMapping() { c.Mapping("GetHistory", c.GetHistory) } // GetHistory controller // @Title Get One // @Description get item by key // @Param X-Token header string true "x-token in header" // @Param item...
package main import "fmt" func main() { // 一年四季的例子 // 1 => 第一季度 // 2 => 第二季度 var num int fmt.Println("请输入1-4之间的一个数值:") fmt.Scanln(&num)// 6 switch num {// 6 case 1: fmt.Println("第一季度") case 2: fmt.Println("第二季度") case 3:// case 2 出现错误:Duplicate case 2 fmt.Println("第三季度") case 4: fmt.Println("第四季度")...
package model import ( "go_code/project1/94chatroom/common/message" "net" ) //因为在客户端,很多地方要 type CurUser struct { Conn net.Conn message.User }
/* * Copyright (c) 2020 - present Kurtosis Technologies LLC. * All Rights Reserved. */ package testsuite_impl import ( "github.com/kurtosis-tech/kurtosis-libs/golang/lib/testsuite" "github.com/kurtosis-tech/kurtosis-libs/golang/testsuite/testsuite_impl/advanced_network_test" "github.com/kurtosis-tech/kurtosis-l...
package repl import ( "bufio" "fmt" "io" "monkey/lexer" "monkey/token" ) const PROMPT = ">> " // Read from the input source until encountering a \n, // take the just read line and pass it to an instance of our // lexer and finally print all the tokens the lexer gives us // until we encounter EOF. func Start(in ...
package sshmgr import ( "errors" "io" "net" "sync/atomic" "time" "github.com/pkg/sftp" "golang.org/x/crypto/ssh" ) var ( errClientClosed = errors.New("client already closed") ) // Client is a shared managed ssh client type Client struct { client *ssh.Client conn net.Conn atime int64 refs int32 } /...
package saihon import "golang.org/x/net/html" // Collection type Collection struct { Nodes []*html.Node } // Length func (e Collection) Length() int { return len(e.Nodes) } // Get returns the "*Element" given index func (e Collection) Get(index int) *Element { if len(e.Nodes) > 0 && index < len(e.Nodes) { retu...
// Package cats is a plugin that queries some cat API's and returns responses. // It queries a cat fact API and a cat image/gif API package cats import ( "encoding/json" "io/ioutil" "net/http" "regexp" "strings" "github.com/handwritingio/deckard-bot/log" "github.com/handwritingio/deckard-bot/message" ) // Plu...
package bitset import ( "testing" ) func TestBitset32(t *testing.T) { bs := NewBitset(32) if bs.IsSet(30) { t.Error("bitset should be all cleared at initialization") } bs.Set(2) if !bs.IsSet(2) { t.Error("Test after set got false") } bs.Clear(2) if bs.IsSet(2) { t.Error("Test after clear got true") }...
package utils import ( "crypto/tls" "fmt" "mime" "net" "net/mail" "net/smtp" "strings" "time" "github.com/IcanFun/utils/utils/log" ) const ( CONN_SECURITY_TLS = "TLS" CONN_SECURITY_STARTTLS = "STARTTLS" ) type EmailSettings struct { EnableSignUpWithEmail bool EnableSignInWithEmail ...
package gatekeeper import "errors" // Global errors var ( UpstreamNotFoundErr = errors.New("upstream not found") BackendNotFoundErr = errors.New("backend not found") RouteNotFoundErr = errors.New("route now found") ) // Plugin specific errors var ( NoManagerErr = errors.New("no upstream_plugin.Manager avail...
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-08-14 14:12 * Description: *****************************************************************/ package gcontext import ( "bytes" "fmt" "github.com/g...
package main import ( "fmt" "log" "net/http" "github.com/adammohammed/groupmebot" ) /* Test hook functions Each hook should match a certain string, and if it matches it should return a string of text Hooks will be traversed until match occurs */ func hello(msg groupmebot.InboundMessage) string { resp := fmt...
package test import ( "testing" "github.com/icrowley/fake" ) func TestNames(t *testing.T) { for _, lang := range fake.GetLangs() { fake.SetLang(lang) v := fake.MaleFirstName() if v == "" { t.Errorf("MaleFirstName failed with lang %s", lang) } v = fake.FemaleFirstName() if v == "" { t.Errorf("F...
// This file was generated for SObject Topic, API Version v43.0 at 2018-07-30 03:47:55.986308731 -0400 EDT m=+42.330503521 package sobjects import ( "fmt" "strings" ) type Topic struct { BaseSObject CreatedById string `force:",omitempty"` CreatedDate string `force:",omitempty"` Description string `for...
package processors import ( "context" sdk "github.com/identityOrg/oidcsdk" "github.com/identityOrg/oidcsdk/impl/sdkerror" ) type DefaultScopeValidator struct { } func NewDefaultScopeValidator() *DefaultScopeValidator { return &DefaultScopeValidator{} } func (d *DefaultScopeValidator) HandleAuthEP(_ context.Cont...
package cmd import ( "fmt" "os" "os/exec" "strings" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/authelia/authelia/v4/internal/utils" ) func newBootstrapCmd() (cmd *cobra.Command) { cmd = &cobra.Command{ Use: "bootstrap", Short: cmdBootstrapShort, Long: cmdBootstrapLo...
package semt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00200102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:semt.002.001.02 Document"` Message *CustodyStatementOfHoldingsV02 `xml:"CtdyStmtOfHldgsV02"` } func (d *Docume...
package graph import ( "github.com/dwaynelavon/es-loyalty-program/internal/app/eventsource" "github.com/dwaynelavon/es-loyalty-program/internal/app/user" ) // This file will not be regenerated automatically. // // It serves as dependency injection for your app, add any dependencies you require here. type Resolver ...
package handler type ReadHandler interface { Read(c Context, obj interface{}) } type WriteHandler interface { Write() } type readHandler struct { }
package main import ( "bytes" _ "embed" "encoding/xml" "fmt" "log" "os" "os/exec" "strings" "text/template" flag "github.com/spf13/pflag" ) type Frame struct { PictType string `xml:"pict_type,attr"` KeyFrame int `xml:"key_frame,attr"` PktSize int `xml:"pkt_size,attr"` Count int } //go:embed ...
/* * Copyright 2018-present Open Networking Foundation * 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 mysql import ( "database/sql" "strconv" "time" "github.com/Tanibox/tania-core/src/helper/paginationhelper" "github.com/Tanibox/tania-core/src/tasks/domain" "github.com/Tanibox/tania-core/src/tasks/query" "github.com/Tanibox/tania-core/src/tasks/storage" "github.com/gofrs/uuid" ) type TaskReadQueryMys...
package lambda import ( "context" "fmt" "strings" "github.com/juju/errors" "github.com/urfave/cli/v2" "github.com/projecteru2/cli/cmd/utils" "github.com/projecteru2/cli/interactive" corepb "github.com/projecteru2/core/rpc/gen" ) type runLambdaOptions struct { client corepb.CoreRPCClient opts ...
package libraries import ( "bufio" "bytes" "encoding/json" "log" "net/http" "os" "strings" ) /* Send the LDAP credentials to Vault to retrieve the Vault Token Configuration details - env, url, and username can be retrieved from config.file */ func VaultConnection() map[string]interface{}{ username := G...
package testdata import "github.com/shitakemura/myapi/models" var articleTestData = []models.Article{ models.Article{ ID: 1, Title: "firstPost", Contents: "This is my first blog", UserName: "saki", NiceNum: 2, CommentList: commentTestData, }, models.Article{ ID: 2, Ti...
/* We have two monkeys, a and b, and the parameters a_smile and b_smile indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling. Return True if we are in trouble. */ package main import ( "fmt" ) func monkey_trouble(a_smile bool, b_smile bool) bool { return (a_smile ...
package main import ( "bufio" "fmt" "log" "os" "strconv" "strings" ) func part1() { lines := readLines("input") streamStart := true startIndex := 0 endIndex := 0 passports := Passports{} valid1 := 0 valid2 := 0 for i, line := range lines { if streamStart { startIndex = i } if line == "" ...
// +build ABISupport package abi import ( "context" "fmt" "io/ioutil" "net" "os" "strconv" "strings" "syscall" "github.com/containers/common/pkg/config" "github.com/containers/libpod/libpod/define" api "github.com/containers/libpod/pkg/api/server" "github.com/containers/libpod/pkg/cgroups" "github.com/c...
package models import ( "database/sql" "fmt" // Postgres driver _ "github.com/lib/pq" ) // StorageConnInfo stores all info needed to establish a database connection. type StorageConnInfo struct { Username, Password, DBName, Driver string } // Datasource objects can perform CRUD operations on the different type...
package day14 type IntArray []int type Difference struct { elements IntArray MaxDifference int } func (d Difference) NewDifference(elements []int) Difference { return Difference{elements: elements} } func (d *Difference) ComputeDifference() { max, min := d.elements.maxMin() d.MaxDifference = max - min } ...
package cmd import ( "fmt" "os" "path" "syscall" "github.com/mitchellh/go-homedir" "github.com/spf13/cobra" "github.com/spf13/viper" "golang.org/x/crypto/ssh/terminal" ) // configCmd represents the config command var configCmd = &cobra.Command{ Use: "config", Short: "Configure atcoder-cli", RunE: func(c...
package handlers import ( "aws-lambda-api/pkg/fundraiser" "net/http" "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface" ) var ErrorMethodNotAllowed = "method Not allowed" type ErrorBody struct { ErrorMsg *string `json:"error,omitemp...
package dushengchen /** Submission: https://leetcode.com/submissions/detail/369640113/ */ func maxSubArray(nums []int) int { if len(nums) == 0 { return 0 } else if len(nums) == 1 { return nums[0] } max := nums[0] dp := nums[0] for i := 1; i < len(nums); i++ { if nums[i] > dp+nums[i] { dp = nums[i] ...
package nats import ( "testing" ) func TestMsg(t *testing.T) { }
package main import ( "fmt" ) type Person struct { name string age int } type Employee struct { id int Person } func main() { e := &Employee{ id: 1, Person: Person{ name: "Jack", age: 28, }, } fmt.Printf("%v\n%+v\n%#v", e, e, e) }
package main import ( "encoding/json" "fmt" "io/ioutil" "log" "regexp" "strconv" "strings" "time" "github.com/PuerkitoBio/goquery" "github.com/go-resty/resty/v2" ) type Provinsi struct { ID string `json:"id"` Nama string `json:"nama"` } type Kabupaten struct { ID string `json:"id"` Nama string `js...
package main import ( "crypto/sm2" "crypto/x509" "fmt" ) func main() { sm2PriKey, err := sm2.GenerateKey() if err != nil { fmt.Println(err) } fmt.Println("-----------------SM2私钥-----------------") fmt.Println(sm2PriKey) pwd := []byte("123456") priKeyStream, _ := x509.MarshalSm2EcryptedPrivateKey(sm2PriKe...
package eventsource import "github.com/pkg/errors" // Aggregate consumes a command and emits Events type Aggregate interface { // EventVersion returns the current event version EventVersion() int // Apply is a method used to apply a history of events to an aggregate instance Apply(History) error } // AggregateB...
package config import "github.com/spf13/viper" type AppConfig struct { AppEnv string AppEnvTest string AppEnvProd string AppPoliceUrl string } func NewAppConfig() *AppConfig { return &AppConfig{ AppEnv: viper.GetString("APP_ENV"), AppEnvTest: "test", AppEnvProd: "prod", AppPoliceUrl: viper.Get...
package commands import ( "errors" "fmt" "os" "regexp" "strings" "text/tabwriter" "github.com/codegangsta/cli" "github.com/docker/machine/libmachine" "github.com/docker/machine/log" ) // FilterOptions - type FilterOptions struct { SwarmName []string DriverName []string State []string Name []...
package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "log" "net/http" "net/url" "strconv" "strings" ) var ( host = flag.String("host", "", "Specify the server host to listen on") port = flag.Int("port", 8001, "Specify the server port to listen on") memeStorage = newMemoryStorage() ...
// Copyright 2018 Authors of Cilium // // 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 ( "os" "github.com/gobwas/glob" "github.com/imdario/mergo" "github.com/kovetskiy/ko" "github.com/reconquest/hierr-go" "gopkg.in/yaml.v2" ) type FileConfig struct { Pull struct { Format string `yaml:"format,omitempty"` } `yaml:"pull,omitempty"` Push struct { Type string ...
package main import ( "time" ) //struct com os fields que serão inseridos na tabela type Registry struct{ ID int64 PersonCompanyDocument string ValidDocument bool Private bool Incomplete bool DateLastPurchase time.Time MedianTicket float64 LastTicket float64 FrequentStore string ValidFrequentSto...
package main import ( "flag" "fmt" "log" "net/http" "os" "time" "github.com/dhnt/oci/pkg/registry" ) func main() { var port int var store string flag.IntVar(&port, "port", 5000, "port") flag.StringVar(&store, "store", "memory:", "image store URI") flag.Parse() addr := fmt.Sprintf(":%d", port) logge...
/* Package webserver has the logic to process the requests. */ package webserver import ( "fmt" "github.com/efark/data-receiver/authenticator" "github.com/efark/data-receiver/configuration" "github.com/efark/data-receiver/extractor" "github.com/efark/data-receiver/logger" "github.com/efark/data-receiver/writer" ...
/** Write a program that a. assigns an int to a variable b. prints that int in decimal, binary and hex c. shifts the bits of that int over 1 position to the left, and assigns that to a variable d. prints that variable in decimal, binary and hex */ package main import "fmt" func main() { //a... num1 := 20 //...
package oidc_test import ( "net/url" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/authelia/authelia/v4/internal/configuration/schema" "github.com/authelia/authelia/v4/internal/oidc" ) func TestOpenIDConnectProvider_NewOpenIDConnectProvider_NotConfigured(t *t...
// Goloris - slowloris[1] for nginx. // // The original source code is available at http://github.com/valyala/goloris. // package main import ( "crypto/tls" "flag" "fmt" "gopkg.in/yaml.v2" "io" "io/ioutil" "log" "net" "net/url" "os" "runtime" "strings" "time" ) type Configuration struct { URL ...
package cli import ( "context" "fmt" "time" "github.com/billglover/character-stats/database" "github.com/billglover/character-stats/skritter" "github.com/spf13/cobra" ) func init() { rootCmd.AddCommand(syncCmd) syncCmd.Flags().String("token", "", "Skritter API token") syncCmd.MarkFlagRequired("token") syn...
package sinks /* #cgo CFLAGS: -DGM_PROTOCOL_GUARD #cgo LDFLAGS: -L. -Wl,--unresolved-symbols=ignore-in-object-files #include <stdlib.h> // This is a copy&paste snippet of ganglia.h (BSD-3 license) // See https://github.com/ganglia/monitor-core // for further information enum ganglia_slope { GANGLIA_SLOPE_ZERO = 0...
package p01 func reverseBits(num uint32) uint32 { var ret uint32 = 0 for i := 0; i < 32; i++ { ret = (ret << 1) | (num & 1) num >>= 1 } return ret }
package field_test import ( "bytes" "encoding/hex" "io" "reflect" "testing" "github.com/tombell/go-serato/serato/field" ) func TestNewField72Field(t *testing.T) { data, _ := hex.DecodeString("000000480000000400000000") buf := bytes.NewBuffer(data) hdr, err := field.NewHeader(buf) if err != nil { t.Fatal...
package main import( "manager/stmanager" "fmt" ) func main(){ var c chan int c = make(chan int) shm := stmanager.NewSHSECompanyManager() go func(){ shm.Process() c <- 1 }() szm := stmanager.NewSZSECompanyManager() go func() { szm.Process() c <- 2 ...
package game import ( "fmt" "strings" "awesome-dragon.science/go/goGoGameBot/internal/command" "awesome-dragon.science/go/goGoGameBot/internal/config/tomlconf" "awesome-dragon.science/go/goGoGameBot/internal/interfaces" "awesome-dragon.science/go/goGoGameBot/pkg/util/systemstats" ) const ( gameNotExist ...
package pkcs11 import ( "crypto/ecdsa" "crypto/elliptic" "encoding/asn1" "errors" "fmt" "math/big" "github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp" ) type ecdsaSignature struct { R, S *big.Int } var ( curveHalfOrders map[elliptic.Curve]*big.Int = map[elliptic.Curve]*big.Int{ elliptic.P224(): new(big.Int).Rs...
package models import ( "fmt" "go_script/dataReport/gettime" "log" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" ) var ( db124 *gorm.DB err error ) func Initialize(config map[string]string) { var dbHost, dbUser, dbPwd, dbName, dbPort string dbConnentBaseStr := "%s:%s@tcp(%s:%s)/%s?charset=u...
package main import "fmt" func teste1() { defer fmt.Println("1. com defer") defer fmt.Println("2. com defer") fmt.Println("3. sem defer") } func teste2() { var x int defer fmt.Println("1", x) x = 10 fmt.Println("2", x) } func main() { teste1() fmt.Println() teste2() }
package io import ( "bufio" "log" "os" ) type Reader interface { Open() Read(chan string) Close() } type FileReader struct { file *os.File } func (f *FileReader) Open(filePath string) *FileReader { if ok, _ := f.Exists(filePath); !ok { log.Fatalf("file not found create empty: %s", filePath) _, err := os...
package live import ( "encoding/json" "fmt" ) const ( MessageTypeHello = "HELLO" MessageTypePing = "PING" MessageTypePong = "PONG" MessageTypeMessage = "MESSAGE" MessageTypeGoodbye = "GOODBYE" ) type MessageType string type Message struct { Type MessageType ContentType string ContentLen...