text
stringlengths
11
4.05M
/* Copyright 2019 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 requests type SendRequest struct { BaseRequest `mapstructure:",squash"` Source string `json:"source" mapstructure:"source"` Destination string `json:"destination" mapstructure:"destination"` Amount string `json:"amount" mapstructure:"amount"` ID *string `json:"id,omitempty" mapstruct...
package cloudstorage import ( "bytes" "errors" "io/ioutil" "mime/multipart" "net/http" "os" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" ) type S3Storage struct { Region string AccessKey...
package networking import ( "github.com/AminRezaei0x443/quickjs-go" ) func AddNetModule(context *quickjs.Context) *quickjs.Module { m := context.DefineModule("networking", func(ctx *quickjs.Context, module *quickjs.Module) int { net := InitHttpClass(ctx) module.AddProperty("HttpClient", net) return 1 }) m.E...
package middleware import ( "encoding/json" "fmt" "net/http" "strings" "github.com/labstack/echo" ) const ( AppJsonHeader = "application/vnd.api+json" ) type AppBinder struct { echo.Binder } func (AppBinder) Bind(i interface{}, c echo.Context) (err error) { req := c.Request() ctype := req.Header().Get(ech...
package main import ( "image" "image/draw" ) type Mouse struct { Loc image.Point Buttons int } // Context represents the context for a GUI client. type Context struct { // W receives an value when the window changes. W <-chan *Window // K receives an value when a key a pressed. K <-chan rune // M receives...
package main import ( "./routers" "net/http" ) func main(){ router := routers.InitRouters() http.ListenAndServe(":8080",router) } //TODO common configuration file should be implemented //TODO Init folder should be implemented and necessary code should move into that
package sqlx import ( "database/sql" "fmt" "github.com/ellsol/gox/typex" _ "github.com/lib/pq" "log" "strings" ) const ( CreateDatabaseStatement = "CREATE DATABASE %v;" DropDatabaseStatement = "DROP DATABASE IF EXISTS %v;" CreateSchemaStatement = "CREATE SCHEMA %v;" DropSchemaStatement = "DR...
package gedcom import ( "reflect" "sync" ) type Nodes []Node // nodeCache is used by NodesWithTag. Even though the lookup of child tags are // fairly inexpensive it happens a lot and its common for the same paths to be // looked up many time. Especially when doing larger task like comparing GEDCOM // files. var no...
package goil import ( "fmt" "strconv" "time" ) type Category uint8 const ( Divers Category = 8 News = 6 Photos = 1 Videos = 2 Journal = 3 Gazettes = 10 Podcasts = 4 Evenements = 5 Sondages = 9 Annales ...
package stock type Data struct { Symbol string CurrentPrice float64 } type Client interface { FetchCurrentPrice(tickers ...string) ([]Data, error) }
package app import ( "errors" "fmt" "github.com/codegangsta/cli" "github.com/phillihq/racoon/config" "github.com/phillihq/racoon/util" "os" ) var configFileFlag = util.AddFlagString(cli.StringFlag{ Name: "config", EnvVar: "CONFIG", Value: "config.json", Usage: "the path of your config file", }) //应用执行方...
package main import ( "fmt" "main/config" "main/router" ) func main() { e := router.New() e.Logger.Fatal(e.Start(fmt.Sprintf(":%d", config.Port))) }
package todo import ( "context" "github.com/silverspase/todo/internal/modules/todo/model" ) type UseCase interface { CreateItem(ctx context.Context, items model.Item) (string, error) GetAllItems(ctx context.Context, page int) ([]model.Item, error) GetItem(ctx context.Context, id string) (model.Item, error) Upd...
package culturegen import ( "bytes" "html/template" "math/rand" "github.com/ironarachne/random" ) // MusicStyle is a cultural music style type MusicStyle struct { Structure int Vocals int Beat int Tonality int Descriptors []string Instruments []Instrument } // Instrument is a musical inst...
package model type VideoListItem struct { Id string `json:"id"` Name string `json:"name"` Duration int `json:"duration"` Thumbnail string `json:"thumbnail"` Uploaded string `json:"uploaded"` Views string `json:"views"` Status int `json:"status"` Quality string `json:"quality"` }
package mutual import ( "log" "math/rand" "time" ) func init() { log.SetFlags(log.LstdFlags | log.Lmicroseconds) debugPrintf("程序开始运行") } // debugPrintf 根据设置打印输出 func debugPrintf(format string, a ...interface{}) { if needDebug { log.Printf(format, a...) } } func max(a, b int) int { if a > b { return a }...
package auth import ( "encoding/json" "errors" "io" ) type authResponse struct { Token string `json:"token"` } func decodeAuthResponse(serverResponse io.Reader) (response authResponse, err error) { decoder := json.NewDecoder(serverResponse) err = decoder.Decode(&response) if err == nil && response.Token == ...
package cryptutil import ( "encoding/pem" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) // generated using: // // openssl genpkey -algorithm x25519 -out priv.pem // openssl pkey -in priv.pem -out pub.pem -pubout var ( rawPrivateX25519Key = []byte(`-----BEGIN PRIVATE KEY-...
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. package azurestack import ( "context" "github.com/Azure/aks-engine/pkg/armhelpers" "github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization" "github.com/Azure/azure-sdk-for-go/services/g...
package database import ( "log" "time" "database/sql" "portal/config" _ "github.com/go-sql-driver/mysql" "github.com/gomodule/redigo/redis" ) // 定义数据库访问实例 var db *sql.DB var RedisPool *redis.Pool // Connect mysql // dbConfig: "user:password@tcp(127.0.0.1:3306)/dbname" func initMysql() { _db, err := sql.Open("...
package cve // CVE type CVE struct { Affects *Affects `json:"affects,omitempty"` CVEDataMeta *CVEDataMeta `json:"CVE_data_meta"` DataFormat string `json:"data_format"` DataType string `json:"data_type"` DataVersion string `json:"data_version"` Description *Description `json:"descrip...
package main import ( "log" "strconv" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" _ "github.com/jinzhu/gorm/dialects/sqlite" "github.com/lcsphantom/savenote-server/api" "github.com/lcsphantom/savenote-server/api/login" "github.com/lcsphantom/savenote-server/api/note" "github.com/lcsphantom/saven...
package main import ( "fmt" "html/template" "net/http" ) func signup(w http.ResponseWriter, r *http.Request) { fmt.Println("method:", r.Method) //get request method if r.Method == "GET" { fmt.Println("Inside signup") t, _ := template.ParseFiles("signup.html") t.Execute(w, nil) } else { r.ParseForm() /...
package interfaces import "fmt" type Testers interface { Do() } type myInt int func (i *myInt) Do() { fmt.Println(i) } func testSkill() { var myint myInt = myInt(9) var myint2 myInt = 8 fmt.Println(myint) myint.Do() myint2.Do() } // again test //type Animals interface { // Shark() //} type Sayer interface { ...
package pgtune import ( "fmt" "math/rand" "testing" "github.com/timescale/timescaledb-tune/internal/parse" ) const ( walDiskUnset = 0 walDiskDivideUnevenly = 8 * parse.Gigabyte walDiskDivideEvenly = 8800 * parse.Megabyte ) // memoryToWALBuffers provides a mapping from test case memory levels to th...
package main import ( "fmt" "net/http" "os" "os/signal" "syscall" "github.com/gin-gonic/gin" "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles" "github.com/therudite/api/common" "github.com/therudite/api/config" _ "github.com/therudite/api/docs" "github.com/therudite/api/errors" ...
package workloads import ( "fmt" "golang-distributed-parallel-image-processing/api/helpers" "golang-distributed-parallel-image-processing/scheduler" "io" "net/http" "os" "strconv" "strings" "github.com/dgrijalva/jwt-go" "github.com/labstack/echo" "go.mongodb.org/mongo-driver/bson/primitive" ) var NoOfTest...
/* In this challenge you will need to determine whether it's Pi Day, Pi Minute, or Pi Second. Because Pi is irrational, it wants your code to be as short as possible. Examples No input is provided, your program should use the system time. I've just added it for clarity March 14, 2016 0:00:00 Pi Day December 25, 201...
package main import ( "bufio" "flag" "fmt" "github.com/fatih/color" "io" "log" "os" "strings" ) const ( versionString = "kubectl-repl {{{VERSION}}}" ) var ( input *bufio.Reader namespace string context string verbose bool ) func prompt() (string, error) { color.New(color.Bold).Print("# ") if...
package main import ( "net/http" "io" // "io/ioutil" // "fmt" "log" ) func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { resp, err := http.Get("https://drive.google.com/uc?export=download&id=1u2NNJK-2pCe8_8PLc3k8eNJYtHsp5X0j") check(err) de...
package entity type UserReq struct { Username string `json:"username"` Password string `json:"password"` } func (al *UserReq) NewUserLogin(username, password string) *UserReq { return &UserReq{ Username: username, Password: password, } }
package cfrida import "errors" func Frida_device_manager_new() uintptr { r, _, _ := frida_device_manager_new.Call() return r } func Frida_remote_device_options_new() uintptr { r, _, _ := frida_remote_device_options_new.Call() return r } func Frida_remote_device_options_set_certificate(obj uintptr,val uintptr) { ...
package main import ( _ "embed" ) //go:embed main.go var s string func main() { println(s) }
// Copyright 2018 Andrew Bates // // 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 wri...
package handler import ( "encoding/json" "fmt" "net/url" "strings" "github.com/parthiban-srinivasan/mserv/geocode/googlemap" proto "github.com/parthiban-srinivasan/mserv/geocode/proto" "github.com/micro/go-micro/errors" "golang.org/x/net/context" ) type Geomap struct{} func (g *Geomap) Geocode(ctx context....
// This file was generated by github.com/EGT-Ukraine/go2gql. DO NOT EDIT IT package test import ( context "context" fmt "fmt" debug "runtime/debug" errors "github.com/pkg/errors" graphql "github.com/saturn4er/graphql" interceptors "github.com/EGT-Ukraine/go2gql/api/interceptors" scalars "github.com/EGT-Ukrain...
package main import ( "os" "github.com/urfave/cli" ) var ( app = cli.NewApp() cfg config ) func main() { app.Name = "jedie" app.Usage = "Static site generator written in golang" app.Version = "0.0.1" app.Run(os.Args) }
package functions import ( "encoding/json" "fmt" "io/ioutil" "math/rand" "net/http" "strconv" "time" ) // A cumulative probability list for each categroy var categoryProbabilities = map[string]float64{ "area": 0.2, "population": 0.4, "gdpPerCapita": 0.6, "lifeExpectancy": 0.8, ...
package daemons import ( "net/http" "docktor/server/storage" "docktor/server/types" "github.com/labstack/echo/v4" log "github.com/sirupsen/logrus" ) // getAll find all daemons func getAll(c echo.Context) error { user := c.Get("user").(types.User) db := c.Get("DB").(*storage.Docktor) if user.IsAdmin() { d...
// Package mycocontext provides a wrapper over context.Context and some operations on the wrapper. package mycocontext import ( "bytes" "context" ) // Context is the wrapper around context.Context providing type-level safety on presence of several values. type Context interface { context.Context // HyphaName ret...
package aoc2019 import ( "testing" aoc "github.com/janreggie/aoc/internal" "github.com/stretchr/testify/assert" ) func TestDay03(t *testing.T) { assert := assert.New(t) testCases := []aoc.TestCase{ {Input: "R8,U5,L5,D3\nU7,R6,D4,L4", Result1: "6", Result2: "30"}, {Input: "R75,D30,R83,U83,L12,D49,R71,U...
package crypto import ( "crypto/sha256" "golang.org/x/crypto/ripemd160" "fmt" ) // 生成密码, n 截前n个字符 func GeneratePwd(rawPwd, salt string, n int) string { pwd := generateRawPwd([]byte(rawPwd), []byte(salt)) return rawPwd2Str(pwd, n) } func generateRawPwd(rawPwd, salt []byte) []byte { rawPwd = append(rawPwd, salt...
package jutils import ( "container/list" "sync" ) //数组堆栈 type ArrayStack struct { name string //名称 list *list.List lock sync.Mutex //并发锁 } //入栈 func (stack *ArrayStack) Push(ele interface{}) { stack.lock.Lock() defer stack.lock.Unlock() //插入数据 stack.list.PushFront(ele) } //出栈 func (stack *ArrayStack) Pop()...
package storage import "testing" func Test_migrationFileNameRe(t *testing.T) { t.Run("bad migration file names", func(t *testing.T) { t.Parallel() badFileNames := map[string]string{ "12 3-name-apply.sql": "spaces in versions are invalid", "123-n ame-appl.sql": "spaces in names are invalid", "123-name.s...
package main import ( "fmt" "net/http" "github.com/gin-gonic/gin" "github.com/yuneejang/webserver/rpc" ) func SetupRouter(router *gin.Engine) *gin.Engine { //Setp. HTML rendering //Using LoadHTMLGlob() or LoadHTMLFiles() router.LoadHTMLGlob("../../templates/*.html") //경로 지정 다시!!! router = setRouterDefault(r...
package balancetests func fnv1modInit() { methods = append(methods, method{name: "FNV1-mod", f: fnv1mod}, method{name: "FNV1a-mod", f: fnv1amod}) } func fnv1mod(k string) string { var h = 2166136261 for _, c := range []byte(k) { h *= 16777619 h ^= int(c) } return nodeList[h&(Nodes-1)] } func fnv1amod(k...
package controller import ( "fmt" "io/ioutil" "os" "path/filepath" "strings" "sync" "github.com/Sirupsen/logrus" "github.com/andygrunwald/perseus/config" "github.com/andygrunwald/perseus/dependency" "github.com/andygrunwald/perseus/dependency/repository" "github.com/andygrunwald/perseus/downloader" "githu...
// Copyright © 2018 VMware, Inc. All Rights Reserved. // SPDX-License-Identifier: BSD-2-Clause package processors import ( "bytes" "fmt" "reflect" "regexp" "strings" "text/template" "github.com/vmware/kube-fluentd-operator/config-reloader/fluentd" "github.com/vmware/kube-fluentd-operator/config-reloader/util...
// Copyright 2019 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
package qbuilder import ( "reflect" "testing" "github.com/spacycoder/cosmosdb-go-sdk/cosmos" ) func TestQueryBuilder(t *testing.T) { qb := New() params := []cosmos.P{{"@SOMETHING", 20}, {"@NAME", "Lars"}} res := qb.Select("*").From("root").And("root.age > @SOMETHING").And("root.name = @NAME").Params(params......
package main import ( "net/http" "net/http/httptest" "testing" "github.com/kaustavha/gravity-interview/src/authenticator" ) // Testing philosophy: Test the top level to-be-consumed API, and test for the different cases handled by internals func TestAuthMiddleware_withAuthcheckHandler_Success(t *testing.T) { // ...
package hostsfile import ( "fmt" "github.com/AdguardTeam/golibs/errors" ) // ErrEmptyLine is returned when the hosts file line is empty or contains only // comments and spaces. const ErrEmptyLine errors.Error = "line is empty" // ErrNoHosts is returned when the record doesn't contain any delimiters, but // the IP...
package perf import ( "encoding/json" "fmt" "io/ioutil" "net/http" "strings" "time" "github.com/ghodss/yaml" "github.com/gofrs/uuid" log "github.com/sirupsen/logrus" "github.com/layer5io/meshery/mesheryctl/internal/cli/root/config" "github.com/layer5io/meshery/mesheryctl/internal/cli/root/constants" "git...
// Copyright 2018 PingCAP, 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 i...
package testutils import ( "net/http" "github.com/selectel/go-selvpcclient/selvpcclient" "github.com/selectel/go-selvpcclient/selvpcclient/resell" ) // NewTestResellV2Client prepares a client for the Resell V2 API tests. func (testEnv *TestEnv) NewTestResellV2Client() { apiVersion := "v2" resellClient := &selvp...
package mybytes import ( "bytes" "fmt" "testing" ) func TestBytesFirst(t *testing.T) { var buffer1 bytes.Buffer contents := "Simple byte buffer for marshaling data." fmt.Printf("Write contents %q...\n", contents) buffer1.WriteString(contents) fmt.Printf("The length of buffer:%d\n", buffer1.Len())...
package generator import ( "fmt" "strings" ) type action struct { IamPrefix string Name string Endpoint string Signing string HasApi bool HasAction bool } type actions []*action func (s actions) get(iamPrefix, name string) *action { for _, a := range s { if a.IamPrefix == iamPrefix && strings....
/* Description In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digits in the factorial of the number. Input Input consists of several...
package jobs import ( "docktor/server/storage" log "github.com/sirupsen/logrus" ) // CheckDaemonsStatuses updates the status of each daemon in the db func CheckDaemonsStatuses() { log.Info("Checking daemons status...") dock, err := storage.Get() if err != nil { log.WithFields(log.Fields{ "error": err, }...
package service import ( "audit-gateway/middleware" "audit-gateway/model" "fmt" "log" "net/http" "os" ) var sessionCookieName = os.Getenv("SessionCookieName") // UserLoginService 管理用户登录的服务 type UserLoginService struct { UserName string `form:"user_name" json:"user_name" binding:"required,min=5,max=30"` Passw...
package main import ( "fmt" "log" "math" "sort" "strings" "sync" ) // Combination is a struct containing details of a combination type Combination struct { Sequence []string Moves []string NoMoves []string Dist float64 Paths int64 } func main() { log.Println("2x4 Lego Construction") startPos...
package main import "fmt" func main() { f := funk fmt.Println(f()) } func funk() string { return "Funky!" }
package main import ( "errors" "math/rand" "time" "github.com/nsf/termbox-go" ) //directions the snake head is going const ( LEFT = iota UP RIGHT DOWN ) type point struct { x int y int } type snake struct { length int direction int } type board struct { width int height int snake p...
package main import ( "fmt" ) func min(x int, y int) int { if x < y { return x } else { return y } } func LevelSearch(matrix [][]int) int { levels := len(matrix) for level := levels - 1; level > 0; level-- { for item := 0; item < len(matrix[level])-1; item++ { matrix[level-1][item] += min(matrix[level...
type animal []string type bird []string func makeAnimal (newAnimal string) { animal(newAnimal) }
package main import ( "fmt" "io/ioutil" "net/url" "path/filepath" "strings" "github.com/BurntSushi/toml" ) func ReadConfig(filename string) (*Config, error) { c := new(Config) _, err := toml.DecodeFile(filename, c) if err != nil { return nil, err } return c, nil } func ReadSites(dir string) ([]*Site, e...
package main import "fmt" func main() { fmt.Println(maxVowels("abciiidef", 3)) fmt.Println(maxVowels("aeiou", 2)) } func maxVowels(s string, k int) int { target := map[byte]bool{ 'a': true, 'e': true, 'i': true, 'o': true, 'u': true, } left, right := 0, 0 mx := 0 win := 0 for right < len(s) { ...
/* Copyright (c) 2015 Eric Knapik, All Rights Reserved Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the followi...
package main import ( "fmt" "time" "io/ioutil" "os" "os/exec" ) //var path = "~/go/src/github.com/gitders222/sanntid/exercises/Ex06/backup.txt" var path = "/backup.txt" var count int = 0 func main(){ backup := exec.Command("gnome-terminal", "-x", "sh", "-c", "go run backup.go") //CreateFile() go Primary...
package labels import ( "fmt" "sync" "time" "github.com/square/p2/pkg/logging" "github.com/square/p2/pkg/store/consul/consulutil" "github.com/hashicorp/consul/api" "github.com/sirupsen/logrus" "k8s.io/kubernetes/pkg/labels" "github.com/rcrowley/go-metrics" ) // minimum required time between retrievals of ...
package main import "fmt" func calculosMatematicos(n1, n2 int) (suma, resta int) { suma = n1 + n2 resta = n1 - n2 return } func main() { _, resultadoResta := calculosMatematicos(10, 5) fmt.Println(resultadoResta) }
package argument_parsing /* TODO: stick on first matched block */ // state machine type machine = [][][]byte // state type state = [][]byte /* jumps to state according to case in context of current state [i]: <index_of_state> */ type jmp = []byte /* executes stuff according to case in context of current ...
package medasync import ( "context" "github.com/jmoiron/sqlx" "github.com/pkg/errors" "git.scc.kit.edu/sdm/lsdf-checksum/meda" ) type chunker struct { ChunkSize uint64 NextChunkQuery string DB *meda.DB BeginTx func(ctx context.Context, db *meda.DB) (*sqlx.Tx, error) ProcessChunk func(ctx contex...
package parser import ( "github.com/fr3fou/monkey/ast" "github.com/fr3fou/monkey/token" ) // parseStatement is a helper function that parses the current token // with the appropriate parsing function func (p *Parser) parseStatement() ast.Statement { switch p.tok.Type { case token.LET: return p.parseLetStatement...
package helpers import ( "fmt" "log" "net/http" "os" "strings" "time" "github.com/brianvoe/sjwt" "github.com/golang-jwt/jwt" "github.com/labstack/echo/v4" ) type jwtClaim struct { UserId int `json:"user_id"` Role string `json:"role"` jwt.StandardClaims } func GenerateToken(userId int, role string) ...
/* * Copyright (C) 2017-Present Pivotal Software, Inc. All rights reserved. * * This program and the accompanying materials are made available under * the terms of the 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 ...
package collector import ( "bytes" "os" "os/exec" "github.com/prometheus/common/log" "strings" ) func getGlusterBinary(glusterPath string) (string, error) { switch glusterPath { // NoDefine case "": out, err := exec.Command("which","gluster").Output() // Trim `out` with '\n' rout := strings.TrimSuff...
package sqlite import ( "database/sql" "encoding/json" "fmt" "log" "strings" "sync" "github.com/aichaos/rivescript-go/sessions" _ "modernc.org/sqlite" ) var schema string = `PRAGMA journal_mode = WAL; PRAGMA synchronous = normal; PRAGMA foreign_keys = on; PRAGMA encoding = "UTF-8"; BEGIN TRANSACTION; CREATE ...
// Copyright © 2020. All rights reserved. // Author: Ilya Stroy. // Contacts: qioalice@gmail.com, https://github.com/qioalice // License: https://opensource.org/licenses/MIT package privet import ( "strconv" "strings" "github.com/qioalice/ekago/v2/ekaerr" "github.com/qioalice/ekago/v2/ekaunsafe" "github.com/mo...
// This is a "stub" file. It's a little start on your solution. // It's not a complete solution though; you have to write some code. // Package triangle should have a package comment that summarizes what it's about. // https://golang.org/doc/effective_go.html#commentary package triangle import "math" // Notice Kind...
package service type LoadBalancer interface { Balance([]Backend) Backend }
package notion import "net/http" // ClientConfig stores the configuration for the Client type ClientConfig struct { BaseURL string APIVersion string HeaderVersion string Token string } // Client encapsulates the logic for connect to Notion's API type Client struct { // Config encapsulates the c...
package main import ( "context" "encoding/json" "fmt" "log" "sync" "time" "github.com/ethereum/go-ethereum/common" "github.com/Dipper-Labs/dip-bridge/config" "github.com/Dipper-Labs/dip-bridge/dip" "github.com/Dipper-Labs/dip-bridge/eth" "github.com/Dipper-Labs/dip-bridge/redis" "github.com/Dipper-Labs/d...
package apocalisp import ( "apocalisp/core" "errors" "fmt" ) func Rep(sexpr string, environment *core.Environment, eval func(*core.Type, *core.Environment) (*core.Type, error), parser core.Parser) (string, error) { // read t, err := parser.Parse(sexpr) if err != nil { return "", err } else if t == nil { re...
// pengantar: object yang belum diinisialisasi akan bernilai null atau nil // untuk golang. saat pertamakali variable dibuat maka akan langsung memiliki default value // sesuai dengan assignment tipe data yang digunakan // golang tetap memiliki data nil(data kosong) // dan hanya bisa digunakan pada interface, function,...
package main import ( "github.com/cosmos/cosmos-sdk/cmd/cosmos-sdk-cli/cmd" ) func main() { cmd.Execute() }
package main type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func lowestCommonAncestor(root, p, q *TreeNode) *TreeNode { res1 := []*TreeNode{} res2 := []*TreeNode{} path := []*TreeNode{} find := false findPath(root, p, path, &find, &res1) find = false findPath(root, q, path, &find, &res2...
//File : goroutine.go //Author: 燕人Lee&骚气又迷人的反派 //Date : 2019-08-21 package main import ( "fmt" "time" ) func main() { //var a[10] int for i := 0; i < 10; i++ { go func(i int) { // for { //a[i]++ //runtime.Gosched() fmt.Println("hello from"+"goroutine %d \n", i) } }(i) } time.Sleep(time....
/* * Copyright © 2019-2022 Software AG, Darmstadt, Germany and/or its licensors * * SPDX-License-Identifier: Apache-2.0 * * 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://...
/* * @lc app=leetcode.cn id=171 lang=golang * * [171] Excel表列序号 */ package solution // @lc code=start func titleToNumber(s string) (acc int) { for _, b := range s { acc = acc*26 + int(byte(b)-64) } return } // @lc code=end
package autocert import ( "context" "errors" "io" "io/fs" "cloud.google.com/go/storage" "github.com/caddyserver/certmagic" "google.golang.org/api/iterator" ) type gcsStorage struct { client *storage.Client bucket string prefix string *locker } func newGCSStorage(client *storage.Client, bucket, prefix st...
package application import ( "log" "os" "github.com/cloudfoundry-incubator/notifications/cf" "github.com/cloudfoundry-incubator/notifications/config" "github.com/cloudfoundry-incubator/notifications/gobble" "github.com/cloudfoundry-incubator/notifications/models" "github.com/cloudfoundry-i...
package array_test import ( "testing" "github.com/stretchr/testify/assert" "github.com/ywardhana/golib/array" ) func TestEqual(t *testing.T) { tests := []struct { arrA interface{} arrB interface{} expected bool }{ { arrA: []int{1, 2, 3, 4}, arrB: []int{1, 2, 3, 4}, expected: tru...
package main import ( "time" "log" "encoding/json" "github.com/liujianping/consumer" ) type context struct{ stop chan bool } func (c *context) Do(req interface{}) error { r, _ := req.(*MyProduct) return r.Do(c) } func (c *context) Encode(request interface{}) ([]byte, error) { return json.Marshal(request) } ...
package modules import ( "encoding/csv" "encoding/xml" "fmt" "io/ioutil" "net/http" "os" "runtime" "strconv" "strings" "time" ) type QuoteResponse struct { Status string Name string LastPrice float32 Change float32 ChangePercent float32 TimeStamp string...
// Copyright 2023 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applica...
// This file was generated for SObject FeedLike, API Version v43.0 at 2018-07-30 03:47:18.743501415 -0400 EDT m=+5.086298705 package sobjects import ( "fmt" "strings" ) type FeedLike struct { BaseSObject CreatedById string `force:",omitempty"` CreatedDate string `force:",omitempty"` FeedEntityId string `forc...
package main import ( "flag" "fmt" // "io" "os" "github.com/midbel/sdp" ) func main() { flag.Parse() r, err := os.Open(flag.Arg(0)) if err != nil { fmt.Fprintln(os.Stderr, "open:", err) os.Exit(1) } defer r.Close() f, err := sdp.Parse(r) if err != nil { fmt.Fprintln(os.Stderr, "parse:", err) os....
// Package authorize is a pomerium service that is responsible for determining // if a given request should be authorized (AuthZ). package authorize import ( "context" "fmt" "sync" "time" "golang.org/x/sync/errgroup" "github.com/pomerium/pomerium/authorize/evaluator" "github.com/pomerium/pomerium/authorize/in...