text
stringlengths
11
4.05M
package main import ( "fmt" "crypto/sha1" "encoding/hex" ) func main() { }
// Copyright 2020 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 ( "fmt" "net/http" "strconv" "strings" "time" ) func printRequest(r *http.Request) { logD.Printf(">> [%s %s]", r.Method, r.URL.Path) logD.Printf(">> %v", r) } type loggingResponseWriter struct { http.ResponseWriter response string statusCode int } func (lrw *loggingResponseWriter) Wr...
/* Copyright 2017 The Kubernetes 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, ...
package stringcase_test import ( "github.com/adamluzsi/frameless/pkg/stringcase" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/assert" "github.com/adamluzsi/testcase/pp" "github.com/adamluzsi/testcase/random" "strings" "testing" ) func TestToSnake(t *testing.T) { type TC struct { In string...
// Goroutines-plus package main import ( "fmt" "math/rand" "sync" ) func main() { numberChan1 := make(chan int64, 3) // 数字通道1。 numberChan2 := make(chan int64, 3) // 数字通道2。 numberChan3 := make(chan int64, 3) // 数字通道3。 // 用于等待一组操作执行完毕的同步工具。 var waitGroup sync.WaitGroup // 该组操作的数量是3。 waitGroup.Add(3) go fun...
package models type Genre struct { BaseModel Name string `json:"name"` } func (genre *Genre) Fields() []interface{} { return []interface{}{&genre.Name} }
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package deskscuj import ( "context" "fmt" "time" "chromiumos/tast/common/action" "chromiumos/tast/errors" "chromiumos/tast/local/chrome" "chromiumos/tast/local/chrom...
package iot import ( "context" "fmt" "time" "github.com/rareinator/Svendeprove/Backend/packages/mongo" . "github.com/rareinator/Svendeprove/Backend/packages/protocol" ) type IotServer struct { UnimplementedIotServiceServer ListenAddress string DB *mongo.MongoDB } func (i *IotServer) GetHealth(ctx...
package main import ( "fmt" "html/template" "net/http" ) // InfoHandler Info接口的回调处理函数 func InfoHandler(w http.ResponseWriter, req *http.Request) { t, err := template.ParseFiles("info.html", "ul.html") if err != nil { fmt.Printf("Parse HTML file failed, err=%v\n", err) return } t.Execute(w, nil) } func mai...
package leetcode import ( "strconv" ) //func factor(m, n int) int { // if n == 0 { // return m // } // // return factor(n, m%n) //} func factor(m, n int) int { for m != 0 { m, n = n%m, m } return n } //func removeDuplicates(s []string) []string { // e := map[string]bool{} // var r []string // // for v := ra...
package main import ( "log" "net/http" "github.com/emicklei/go-restful" gintonic "github.com/gin-tonic/pkg/api/services/gintonic/endpoint" "github.com/gin-tonic/pkg/api/services/health/pingservice" "github.com/gin-tonic/pkg/api/services/user/userservice" utils "github.com/gin-tonic/pkg/api/utils" ) func main...
package db import ( "github.com/evergreen-ci/sink" "github.com/pkg/errors" "gopkg.in/mgo.v2/bson" ) // PROPOSAL: these functions should be private with exposed // functionality via methods on the db.Q type. // Insert inserts a document into a collection. func Insert(collection string, item interface{}) error {...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package hwsim setups a simulated Wi-Fi environment for testing. package hwsim import ( "context" "time" "chromiumos/tast/errors" "chromiumos/tast/local/arc" "chromi...
package main import ( "fmt" "os" "github.com/spf13/cobra" ) /* TODO: - Document types with golang // <StructName> description style */ func main() { var glancCmd = &cobra.Command{ Use: "glanc", Short: "gyors lanc - the fastest bchain ever!", Run: func(cmd *cobra.Command, args []string) {}, } glanc...
package main import "fmt" func main() { digits := []int{4, 3, 2, 1} fmt.Println(plusOne(digits)) } func plusOne(digits []int) []int { n := len(digits) - 1 digits[n]++ // 加1后开始处理进位 for i := n; i > 0; i-- { // 没有进位直接跳出 if digits[i] < 10 { break } digits[i] -= 10 digits[i-1]++ } // 处理首位 if digits[0...
package detector import ( "errors" "io" "os" "regexp" "strings" "testing" "fmt" "github.com/stretchr/testify/assert" ) func TestIsPotentialDelimiter(t *testing.T) { tests := []struct { input byte expected bool }{ { byte('a'), false, }, { byte('A'), false, }, { byte('1'), ...
package main import ( "flag" "fmt" "os" ) var VersionStr = "unknown" func main() { version := flag.Bool("v", false, "Show Version") flag.Parse() if *version { fmt.Println(VersionStr) os.Exit(0) } }
// SPDX-License-Identifier: MIT package lsp import ( "path/filepath" "github.com/issue9/sliceutil" "github.com/caixw/apidoc/v7/build" "github.com/caixw/apidoc/v7/core" "github.com/caixw/apidoc/v7/internal/ast" "github.com/caixw/apidoc/v7/internal/lang" "github.com/caixw/apidoc/v7/internal/lsp/protocol" ) //...
package main import ( "benchmark/controllers" "github.com/astaxie/beego" ) func main() { beego.Router("/", &controllers.MainController{}) beego.Router("/benchmark",&controllers.BenchmarkController{}) beego.Router("/run",&controllers.RunController{}) beego.Run() }
package proteus import ( "context" "reflect" "sync" "fmt" "strings" "github.com/jonbodner/multierr" "github.com/jonbodner/proteus/logger" "github.com/jonbodner/stackerr" ) /* struct tags: proq - SQL code to execute If the first parameter is an Executor, returns new id (if sql.Result has a non-zero value fo...
package graylogger // SendGELF sends GELF messages into Graylog instance. // If the Graylog host is unreachable, it writes an error message to stdOut. func (g *GrayLogger) SendGELF(level int, keysAndValues ...interface{}) { if g.validateGraylogArguments(level) { g.connect().send(level, keysAndValues) } }
package main import ( "bytes" "context" "encoding/json" "io/ioutil" "net/http" "github.com/epsagon/epsagon-go/epsagon" epsagonhttp "github.com/epsagon/epsagon-go/wrappers/net/http" ) func doTask(ctx context.Context) { client := http.Client{Transport: epsagonhttp.NewTracingTransport(ctx)} // This password wi...
// Copyright 2017 Baidu, 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 in writing...
package helper import ( "QRcodeBillApi/database" "QRcodeBillApi/models" "strconv" "time" "github.com/gofiber/fiber/v2" ) // Add a new menu func Menu(c *fiber.Ctx) error { price, _ := strconv.ParseFloat(c.FormValue("fprice"), 64) path := key(5) if c.FormValue("fname") == "" || c.FormValue("ftype") == "" ||...
package array_dyncon import ( "testing" "math/big" ) func TestSetGet(t *testing.T) { const arrayLength = 3; myContract := NewArrayPush() for i := 0 ; i<arrayLength ; i++ { bigI := big.NewInt(int64(i)) startLen := myContract.ArrayLength(bigI) if 0 != startLen.Cmp(big.NewInt(0)) { t.Fatalf("Inital arra...
package main func p12928(n int) int { ret := 0 for i := 1; i*i <= n; i++ { if n%i == 0 { ret += i ret += n / i } if i*i == n { ret -= i } } return ret }
package main import ( "os" ) func main() { os.Mkdir("E:/test/", 0777) }
package raft type Entry struct { Term int Index int Command interface{} } type ApplyMsg struct { CommandValid bool Command interface{} CommandIndex int } type RequestVoteArgs struct { Term int CandidateId int LastLogIndex int LastLogTerm int } type RequestVoteReply struct { Term ...
package errors import ( "fmt" ) type InvalidError struct{} func (e *InvalidError) Error() string { return fmt.Sprintf("Invalid or unsupported SFO Museum date string") } func Invalid() error { return &InvalidError{} } func IsInvalid(e error) bool { switch e.(type) { case *InvalidError: return true default:...
package main import ( "errors" "github.com/smallfish/simpleyaml" "io/ioutil" "log" "sort" "strings" ) // ReadYaml reads a file and parse it as YAML thanks to github.com/smallfish/simpleyaml func ReadYaml(fileName string) (*simpleyaml.Yaml, error) { file, err := ioutil.ReadFile(fileName) if err != nil { log...
package usecase import "github.com/jerolan/slack-poll/domain/entity" func (uc *UseCase) UpsertPollAnswer(pollAnswer *entity.PollAnswer) error { _, err := uc.pollService.GetPollByID(pollAnswer.PollID) if err != nil { return err } err = uc.pollService.CreatePollAnswer(pollAnswer) if err != nil { return err ...
package main import ( "github.com/go-flutter-desktop/go-flutter" "github.com/go-flutter-desktop/plugins/go-plugin-example/battery" "github.com/go-flutter-desktop/plugins/go-plugin-example/complex" ) var options = []flutter.Option{ flutter.WindowInitialDimensions(100, 100), flutter.PopBehavior(flutter.PopBehavior...
package handler import ( "encoding/json" "github.com/k1dan/string-encryptor/randomizer/encryptor" string_creator "github.com/k1dan/string-encryptor/randomizer/string-creator" "net/http" "strconv" ) type Number struct { N string `json:"n"` } type Strings struct { S []string `json:"s"` } func CreateStrings(w h...
package reload import ( "github.com/wudiliujie/common/log" "io/ioutil" "yxlserver/services/tb" "yxlserver/services/tb/tbArea" ) func Reload() { data, errcode := ioutil.ReadFile("conf/cfg_data.json") if errcode != nil { log.Error("bReload %v", errcode) return } tb.InitCfgData(data) tbArea.Init() }
package main import "fmt" func main() { // Run this before returning. defer func() { str := recover() fmt.Println(str) }() panic("should be recovered.") fmt.Println("Unreachable code.") }
package main import ( "fmt" "reflect" ) type Person struct { Name string Age int } type Teacher struct { Person } func (this *Person) GetName() string { return this.Name } func main() { t := &Teacher{} p := &Person{Name: "cuihang", Age: 10} t.Person = *p fmt.Println(t.Person.Name) v := reflect.Value...
package golog import ( "fmt" "io" "os" ) // WriterLogger implements the Logger interface using different io.Writers for // the different log levels. type WriterLogger struct { // BaseLogger is used to provide the basic functionality of a Logger *BaseLogger // FatalWriter is used to output FATAL level log messa...
package config import ( "encoding/json" "log" "os" ) // Database 数据库配置对象 type Database struct { Type string `json:"type"` User string `json:"user"` Password string `json:"password"` Host string `json:"host"` Port string `json:"port"` Name string `json:"name"` TablePrefi...
package main import ( // "errors" "fmt" ) func main() { ifController() forController() whileController() forCollectionIterator() switchController() } func ifController() { if x := 1; x == 1 { fmt.Println("x == 1, ", x) } else if x == 2 { fmt.Println("x == 2") } else { fmt.Println("x != 1 and x != 2")...
package main import ( "fmt" "github.com/chidakiyo/benkyo/go-opai-codeegen-test/api" "github.com/go-chi/chi/v5" "net/http" ) type Server struct{} // Returns all pets // (GET /pets) func (s Server) FindPets(w http.ResponseWriter, r *http.Request, params api.FindPetsParams) { fmt.Fprintf(w, "GET: /pets") } // Cr...
/* * Copyright IBM Corporation 2020, 2021 * * 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 serve import "net/http" type dirWithIndexFallback struct { dir http.Dir } func CreateDirWithIndexFallback(path string) http.FileSystem { return dirWithIndexFallback{http.Dir(path)} } func (d dirWithIndexFallback) Open(name string) (http.File, error) { file, err := d.dir.Open(name) if err != nil { retu...
package operations import ( "strconv" "strings" ) type FractionDestructured struct { numerator int denominator int } type BasicOperations struct { } func (bo BasicOperations) IntegerToFraction(element string) string { partsFraction := strings.Split(element, "_") if len(partsFraction) == 2 && len(partsFraction...
package client import ( "encoding/base64" "fmt" "github.com/arunvelsriram/sftp-exporter/pkg/constants/viperkeys" log "github.com/sirupsen/logrus" "github.com/spf13/viper" "golang.org/x/crypto/ssh" ) func parsePrivateKey(key, keyPassphrase []byte) (parsedKey ssh.Signer, err error) { if len(keyPassphrase) > 0 {...
package parsers import ( "bufio" . "github.com/ruxton/tracklist_parsers/data" "github.com/ruxton/term" "io" "os" "regexp" ) func ParseBasicTracklist(bufReader *bufio.Reader) []Track { var list []Track regex,err := regexp.Compile(`([0-9]+)(?:.{1}?\s)(.+)(?:\s-\s)(.+)`) if(err != nil) { term.OutputErro...
package crypto import ( "bytes" "crypto/ecdsa" "crypto/rsa" "encoding/hex" "encoding/json" "errors" "io" "io/ioutil" "regexp" "strings" "time" "golang.org/x/crypto/openpgp" "golang.org/x/crypto/openpgp/armor" pgperrors "golang.org/x/crypto/openpgp/errors" "golang.org/x/crypto/openpgp/packet" xrsa "gol...
// Copyright © 2020. All rights reserved. // Author: Ilya Stroy. // Contacts: qioalice@gmail.com, https://github.com/qioalice // License: https://opensource.org/licenses/MIT package ekalog // ----- // Integrator is the why this package called 'logintegro' earlier. // The main idea is: "You integrate your log messages...
package integration import ( "fmt" "net/http" "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Sender", func() { Describe("Event", func() { It("should receive event", func() { startDate := time.Now() title := fmt.Sprintf("Test Send Event %d", startDate.Unix()) payload...
/* GTVM is Golang Tools Version Manager Manage Golang versions and LiteIDE versions install/uninstall Basics All configs, archives, installed tools stored in $HOME/.gtvm in Linux and %USERPROFILE%\.gtvm in Windows */ package main import ( "database/sql" "fmt" "os" "os/user" "path/filepath" "github.com/Puer...
package structil_test import ( "fmt" "strconv" "testing" "github.com/google/go-cmp/cmp" . "github.com/goldeneggg/structil" ) type ( FinderTestStruct struct { Byte byte Bytes []byte Int int Int64 int64 Uint uint Uint64 uint64 Float32 float3...
package main import fmt "fmt" func main() { a := make([]int,100) for i := 0; i<100; i++ { a[i]=i } end := search(a,11) fmt.Println(end) } func search(a []int, x int) int { left := 0 right := len(a)-1 for left < right { // fmt.Println(left,right) mid := (left+right)/2 if a[mid] < x { left = ...
// Copyright 2015 The Vanadium Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package profiles import ( "fmt" "os" "path/filepath" "sort" "strconv" "strings" "v.io/jiri/project" "v.io/jiri/tool" "v.io/jiri/util" "v.io/x/...
package main import "fmt" // map is reference type func set(m map[string]string, k string, v string) { m[k] = v } func print(m map[string]string) { for k, v := range m { fmt.Println("k", k, "v", v) } } func main() { colors := map[string]string { "red": "#ff0000", "green": "#00ff00", "blue": "#0000ff", ...
package dtclient import ( "net/http" "testing" "github.com/stretchr/testify/assert" ) func TestNewClient(t *testing.T) { { c, err := NewClient("https://aabb.live.dynatrace.com/api", "foo", "bar") if assert.NoError(t, err) { assert.NotNil(t, c) } } { c, err := NewClient("https://aabb.live.dynatrace.c...
package cmd import ( "fmt" "os" "strings" "text/tabwriter" sunspec "github.com/andig/gosunspec" bus "github.com/andig/gosunspec/modbus" "github.com/andig/gosunspec/smdx" "github.com/evcc-io/evcc/util" "github.com/spf13/cobra" "github.com/spf13/viper" "github.com/volkszaehler/mbmd/meters" quirks "github.co...
package person_infrastructure import ( "net/http" person_application "github.com/MeliCGS/go-project-api-arq-hexa/api/person/application" "github.com/gin-gonic/gin" ) type PersonController struct { PeopleSearcher *person_application.PeopleSearcher } func (p *PersonController) GetAllHandler(ctx *gin.Context) { p...
package rock func (I *Int) makeW() { I.p.w.c = make(chan []byte, I.Len) go postIfClient(I.p.w.c, Tint, I.Name) } func (I *Int) makeR() { I.p.r.c = make(chan []byte, I.Len) go getIfClient(I.p.r.c, Tint, I.Name) } func (I *Int) makeNIfServer() { if IsClient { return } I.p.n.c = make(chan int) } func (I *Int)...
package adminApp import ( "github.com/gin-gonic/gin" "hd-mall-ed/packages/common/pkg/app" ) func ApiInit(c *gin.Context) *ApiFunction { return &ApiFunction{app.ApiFunction{C: c}} }
package fs func Defaults() FsConfig { return FsConfig{ DataDir: defaultDataDir(), } }
package k8s import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "github.com/tilt-dev/tilt/internal/container" "github.com/tilt-dev/tilt/internal/k8s/testyaml" ) func TestCRDImageObjectInjecti...
package bot import ( "regexp" "strings" "fmt" "github.com/VG-Tech-Dojo/vg-1day-2017-05-20/hironomiu/env" "github.com/VG-Tech-Dojo/vg-1day-2017-05-20/hironomiu/model" ) const ( keywordApiUrlFormat = "https://jlp.yahooapis.jp/KeyphraseService/V1/extract?appid=%s&sentence=%s&output=json" ) type ( // Processor は...
/** * (C) Copyright IBM Corp. 2021. * * 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 usage() { return } func main() { var v1 int32 = 10 var v2 = 10 v3 := 10 v4 := 9.9 const ( a int = 1 << iota b int = 1 << iota c int = 1 << iota ) fmt.Println("hello word!") fmt.Println(a, b, c) fmt.Println(1 << 0) if int(v4) > v2 { fmt.Println(int(v1) + v2 + v...
// Copyright 2020 The Cockroach Authors. // // Licensed as a CockroachDB Enterprise file under the Cockroach Community // License (the "License"); you may not use this file except in compliance with // the License. You may obtain a copy of the License at // // https://github.com/cockroachdb/cockroach/blob/master/li...
/* * Flow CLI * * Copyright 2019-2021 Dapper Labs, 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 appl...
package main import ( "fmt" "time" "github.com/aliyun/aliyun-datahub-sdk-go/datahub" ) func listProjects(dh datahub.DataHubApi) { projects, err := dh.ListProject() if err != nil { fmt.Println(err) return } fmt.Println(projects) } func getProject(name string, dh datahub.Da...
package main import ( "net/http" "github.com/gorilla/mux" "github.com/muslim-teachings/api-orchestrator/src/main/controllers" // "github.com/muslim-teachings/api-orchestrator/src/main/controllers" // "github.com/muslim-teachings/api-orchestrator/src/main/middleware" ) const ( // POST methods POST = "POST" //...
package docs import ( "github.com/gregoryv/draw" "github.com/gregoryv/draw/design" "github.com/gregoryv/draw/shape" ) func ExampleClassDiagram() *design.ClassDiagram { var ( d = design.NewClassDiagram() record = d.Struct(shape.Record{}) arrow = d.Struct(shape.Arrow{}) line = d.Struct(shape...
package scaffold import ( "bytes" "fmt" "github.com/shurcooL/httpfs/vfsutil" log "github.com/sirupsen/logrus" tmpl "github.com/snowdrop/generator/pkg/template" "io/ioutil" "os" "path" "path/filepath" "regexp" "strings" "text/template" ) const ( dummyDirName = "dummy" allVersionsSelector = "_all_"...
package main import ( "fmt" //"time" // mysql connector _ "github.com/go-sql-driver/mysql" sqlx "github.com/jmoiron/sqlx" ) const ( StudentID = "18307130112" User = "root" Password = "123456" DBName = "ass3" AdminInit = "1" AdminInitPassword = "a" ) type Library struct { db *sqlx.DB } func (lib ...
// Copyright (C) 2018 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed t...
package chain import ( "github.com/ethereum/go-ethereum/common" "math/big" ) type Output struct { Owner common.Address Denom *big.Int DepositNonce *big.Int } func NewOutput(newOwner common.Address, amount, depositNonce *big.Int) *Output { return &Output{ Owner: common.BytesToAddress(newOwner...
// +build js,wasm package main import "syscall/js" var document js.Value func init() { document = js.Global().Get("document") } func main() { div := document.Call("getElementById", "target") node := document.Call("createElement", "div") node.Set("innerText", "Hello World") div.Call("appendChild", node) }
package main func main() { state := initState("Engineering") state.generateConstraints() state.generateCandidates() state.solve() state.generateXLSX() }
package main import( "fmt" ) func main() { count := 0 for i := 0000; i <= 9999; i++ { for n := i; n <= 9999; n++ { // don't count twice q := i * n num := fmt.Sprintf("%d", q) if num[0] == num[len(num)-1] { count++ } } } fmt.Println(count) }
package packet import ( "fmt" "github.com/google/gopacket" "github.com/google/gopacket/layers" "github.com/pkg/errors" "golang.org/x/net/icmp" ) func FindProtocol(p []byte) (layers.IPProtocol, error) { version, err := FindIPVersion(p) if err != nil { return 0, err } switch version { case 4: if len(p) <...
package scraper import ( "bytes" "fmt" "io/ioutil" "net/http" _ "regexp" "strconv" "strings" "sync" r "github.com/mohakkataria/kfit-scraper/retriever" "github.com/PuerkitoBio/goquery" ) // Partner stores details of a single partner type Partner struct { Name string `csv:"name"` City string `c...
package k8s import ( "fmt" "go.starlark.net/starlark" "github.com/pkg/errors" "github.com/tilt-dev/tilt/internal/k8s" "github.com/tilt-dev/tilt/internal/tiltfile/value" ) // Deserializing locators from starlark values. type JSONPathImageLocatorListSpec struct { Specs []JSONPathImageLocatorSpec } func (s JSO...
package logconsts const ( INFO = 1 DEBUG = 2 )
// -*- Mode: Go; indent-tabs-mode: t -*- package main import ( "fmt" "log" "net" "os" ) func echoServer(c net.Conn) { for { buf := make([]byte, 512) nr, err := c.Read(buf) if err != nil { log.Fatal("Read: ", err) } data := buf[0:nr] fmt.Println("Server got: ", string(data)) _, err = c.Write(da...
package "atomic_stream"; #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> #include <fcntl.h> import stream from "../deps/stream/stream.module.c"; static int _type; export int type() { if (_type == 0) { _type = stream.register("atomic"); } return _type; } typed...
package management import ( "context" "github.com/caos/zitadel/pkg/grpc/management" "github.com/golang/protobuf/ptypes/empty" ) func (s *Server) GetZitadelDocs(ctx context.Context, _ *empty.Empty) (*management.ZitadelDocs, error) { return &management.ZitadelDocs{ Issuer: s.systemDefaults.ZitadelDocs....
package config_test import ( "encoding/json" "testing" "time" "github.com/stretchr/testify/assert" "github.com/gojek/fiber/config" ) type durCfgTestSuite struct { input string duration time.Duration success bool } func TestDurationUnmarshalJSON(t *testing.T) { tests := map[string]durCfgTestSuite{ "va...
package main import( "image" ) func (c *Challenge) Challenge016() { path:=".\\Data\\016" EnsureDir(path) gif:="http://www.pythonchallenge.com/pc/return/mozart.gif" filename:=path+"\\mozart.gif" DownloadWithBasicAuth(gif, filename, "huge", "file") im:=OpenImage(filename) newImg:=straightImage(im) giffile ...
package notifier import ( "sync" "time" "github.com/void616/gm.mint.sender/internal/sender/db/types" "github.com/void616/gotask" ) // Task loop func (n *Notifier) Task(token *gotask.Token) { var wg sync.WaitGroup var stopper = make(chan struct{}) var sleep = func(d time.Duration) { select { case <-stoppe...
package config import ( "log" "time" "github.com/BurntSushi/toml" ) // ConfStruct is used to unmarshal the config.toml type ConfStruct struct { Prefix []string `toml:"Prefix"` BotToken string `toml:"Bot_Token"` MongoURL string `toml:"Mongo_URL"` BotStatus string `tom...
package analytics import ( "context" "fmt" "strconv" "time" "github.com/tilt-dev/clusterid" "github.com/tilt-dev/tilt/internal/analytics" "github.com/tilt-dev/tilt/internal/container" "github.com/tilt-dev/tilt/internal/controllers/apis/liveupdate" "github.com/tilt-dev/tilt/internal/feature" "github.com/tilt...
package anchors import ( "net/rpc" ) type NewResonanceTask struct { Address string Amount string Signature string } type SigResonance struct { Address string Amount string Signature string } type Client struct { client *rpc.Client path string } func NewClient(url string) (*Client, error) { cli...
package main import ( "strconv" "fmt" ) func main() { fmt.Println(genPalindrome(3)) fmt.Println(superpalindromesInRange("4", "1000")) } func superpalindromesInRange(L string, R string) int { l64, _ := strconv.ParseInt(L, 10, 0) r64, _ := strconv.ParseInt(R, 10, 0) ...
package main import ( "fmt" ) func main() { nums := []int{2, 3, 1, 1, 4} fmt.Println(canJump(nums)) } // 从前先后 // func canJump(nums []int) bool { // start, end := 0, 0 // for start <= end && end < len(nums)-1 { // end = int(math.Max(float64(end), float64(nums[start]+start))) // start++ // } // return end >...
/* @Time : 2018/10/24 15:02 @Author : zhaoxiaoqiang @File : mong.go @Software: GoLand */ package main import ( "fmt" mgo "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) type Person struct { Name string Phone string } func main() { session, err := mgo.Dial("localhost:27017") if err != nil { fmt.Println(...
package main import ( "fmt" "strconv" ) func main() { //inteiro para float64 x := 2.4 y := 2 fmt.Println(x / float64(y)) //utilizamos esses conversores explicitos para que o compilador possa realizar a conta //float64 para int nota := 6.9 notaFinal := int(nota) fmt.Println(notaFinal) //int para string ...
/* trader API Engine */ package chbtc import ( . "common" . "config" "encoding/json" "errors" "logger" "util" ) type ChTicker struct { Ticker ChTickerPrice } type ChTickerPrice struct { Buy string High string Last string Low string Sell string Vol string } func (w *Chbtc) getTicker(symbol string)...
// 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 "math" func MinNumberOfCoinsForChange(n int, denoms []int) int { numOfCoins := make([]int, n+1) for i := range numOfCoins { numOfCoins[i] = math.MaxInt32 } numOfCoins[0] = 0 for _, denom := range denoms { for amount := range numOfCoins { if denom <= amount { numOfCoins[amount] = mi...
package main import ( "fmt" "reflect" ) type User struct { Id int Name string Age int } func (user User) Hello(name string) { fmt.Println("hello world") } func main() { u := User{1, "ok", 12} Info(u) x:=123 v:=reflect.ValueOf(&x) v.Elem().SetInt(99) fmt.Println(x) v2:=reflect.ValueOf(u) mv:=v2.Me...
package bcio import ( "debug/elf" "log" "os" "sort" ) type memSegment struct { Vaddr uint64 Offset int64 Memsz uint64 Data []uint8 changes map[int]byte } type codeSection struct { Addr uint64 Size uint64 } // Binary type stores information about how to load a file to memory. type Binary struct { ...
package console import ( "fmt" "io/ioutil" "os" "strings" ) // init command list var commands = map[string]Command{ "HELP": NewHelpCommand(), "DIR": NewDirCommand(), "LS": NewDirCommand(), "CD": NewCDCommand(), "MKDIR": NewMkDirCommand(), "RUN": NewRunCommand(), } type command struct { Name str...
package mappers import ( "RBStask/app/models/entity" "database/sql" "fmt" ) type PersonMapper struct { db *sql.DB } func (m *PersonMapper) Init(db *sql.DB) error { m.db = db return nil } func (m *PersonMapper) Add(receivedPerson *entity.Person) error { fmt.Println(receivedPerson) sqlSelect := ` INSERT INTO p...