text
stringlengths
11
4.05M
package gherkin import ( "fmt" "io" ) // Passed to each step-definition type World struct { regexParams []string regexParamIndex int MultiStep []map[string]string output io.Writer gotAnError bool ctx interface{} } // Allows World to be used with the go-matchers AssertThat() function. ...
package utils import ( "encoding/json" "fmt" "os" "strconv" "strings" "time" "github.com/MagalixTechnologies/core/logger" "github.com/MagalixTechnologies/uuid-go" ) func ExpandEnv( args map[string]interface{}, flag string, allowEmpty bool, ) string { defer func() { tears := recover() if tears != nil ...
package sessions import ( "github.com/agui2200/GoMybatisV2/sqlbuilder" "github.com/agui2200/GoMybatisV2/templete/ast" ) //sql文本构建 type SqlBuilder interface { BuildSql(paramMap map[string]interface{}, nodes []ast.Node) (string, error) ExpressionEngineProxy() *sqlbuilder.ExpressionEngineProxy SqlArgTypeConvert() a...
package web import ( "github.com/kerinin/hammer/db" ) type DeleteRequest struct { Scalars []db.Key `json:"Scalars" binding:"required"` } type ScalarDeleteResult struct { Scalar db.Key Deleted bool } type DeleteResponse struct { Scalars []ScalarDeleteResult }
package main import "fmt" func main() { var ch chan string ch=make(chan string) for i:=0;i<100;i++{ go PrintStr(i,ch) } for{ msg:=<-ch fmt.Println(msg) } } func PrintStr(i int,ch chan string) { for{ ch<-fmt.Sprintf("hello world from go routine %d",i) } }
/* Copyright IBM Corp 2016 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 law or agreed to in writing...
package main import ( "github.com/strava/go.strava" "log" "net/http" "sort" "time" ) // Strava service. type Strava struct { authenticator *strava.OAuthAuthenticator repo *Repository } // Create new Strava service. func NewStrava(repo *Repository, clientId int, clientSecret string, callbackUrl string...
package cdcpostgres import ( "context" "github.com/batchcorp/plumber-schemas/build/go/protos/opts" "github.com/batchcorp/plumber-schemas/build/go/protos/records" "github.com/batchcorp/plumber/types" ) func (c *CDCPostgres) Write(ctx context.Context, writeOpts *opts.WriteOptions, errorCh chan<- *records.ErrorReco...
// +build leak package z import "unsafe" func init() { // By initializing dallocs, we can start tracking allocations and deallocations via z.Calloc. dallocs = make(map[unsafe.Pointer]*dalloc) }
package bootstrap import ( "github.com/openshift/installer/pkg/asset" ) const ( bootstrapIgnFilename = "bootstrap.ign" ) // Bootstrap is an asset that generates the ignition config for bootstrap nodes. type Bootstrap struct { Common } var _ asset.WritableAsset = (*Bootstrap)(nil) // Generate generates the ignit...
package api import ( "errors" "math/big" "sync/atomic" "time" "github.com/qlcchain/go-qlc/config" "github.com/qlcchain/go-qlc/common" "github.com/qlcchain/go-qlc/common/event" "github.com/qlcchain/go-qlc/common/types" "github.com/qlcchain/go-qlc/ledger" "github.com/qlcchain/go-qlc/log" "github.com/qlcchai...
package main import "fmt" var complete = make(chan int) func loop03() { for i := 0; i < 10; i++ { fmt.Printf("%d ", i) } complete <- 0 } func main() { go loop03() <- complete }
package cmd import ( "github.com/brittonhayes/godb/pkg/reading" "github.com/brittonhayes/godb/pkg/types" scribble "github.com/nanobox-io/golang-scribble" "github.com/spf13/cobra" ) // Read function reads an entry from the db func Read(db *scribble.Driver) *cobra.Command { var ( readCmd = &cobra.Command{ Us...
package git import ( "fmt" "github.com/abhinav/git-pr/gateway" ) const _uniqeBranchAttempts = 10 // CheckoutUniqueBranch atomically finds a unique branch name and checks it // out at the given ref. // // The final branch name is returned. func CheckoutUniqueBranch(git gateway.Git, prefix, ref string) (name string...
package col import ( "math" ) // Given a sequence of integers X and input y, find index i that minimizes // abs(X[i] - y). type Strings struct { idx map[int]string lst []float64 unsorted int } func (st *Strings) Insert(s string, n float64) { if st.idx == nil { st.idx = make(map[int]string) st.lst...
package config import ( "path/filepath" "github.com/spf13/viper" ) // LoadFile . func LoadFile(path string) (config *Config, err error) { defer func() { if re := recover(); re != nil { err = re.(error) } return }() var ( dir = filepath.Dir(path) filename = filepath.Base(path) ext = fil...
package sort import ( "github.com/Pallinder/go-randomdata" "testing" ) var arr = []int{4, 6, 2, 1, 5, 3} func TestBubbleSort(t *testing.T) { BubbleSort(arr) t.Log(arr) } func TestInsertionSort(t *testing.T) { InsertionSort(arr) t.Log(arr) } func TestSelectionSort(t *testing.T) { SelectionSort(arr) t.Log(ar...
//EmBrAcE iT for iT wIlL cOmE package void; func _() { } func _() { type _ struct { } var (); }
package setr import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00200102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:setr.002.001.02 Document"` Message *RedemptionBulkOrderCancellationInstructionV02 `xml:"setr.00...
/* 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 writ...
package main import ( "net" "socketfunctions" ) func main() { servererrc := make(chan error) CERTFILE := "/usr/lib/ssl/certs/certificate.pem" KEYFILE := "/usr/lib/ssl/certs/key.key" // Start OpenSSL Server ServerInst := socketfunctions.ServerInstance{} ServerInst.IP = "127.0.0.1" ServerInst.PORT = "8000" S...
package queries import ( "log" "github.com/jmoiron/sqlx" "gitlab.com/semestr-6/projekt-grupowy/backend/obsluga-formularzy/configuration" "gitlab.com/semestr-6/projekt-grupowy/backend/obsluga-formularzy/units/models" ) const GET_QUANITY_BY_ID_SQL = ` SELECT q."QuantityId" ,q."QuantityNamePl" ,q."QuantityName...
package parser import "github.com/eriklupander/rt/internal/pkg/mat" type Scene struct { Lights []mat.Light World *mat.World Camera *mat.Camera Materials map[string]mat.Material Transforms map[string][]mat.Mat4x4 } func NewScene() *Scene { w := mat.NewWorld() return &Scene{ World: &w, Li...
// Copyright 2019 Google 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 by applicable law or agreed to in ...
package handler import ( "github.com/labstack/echo" ) func (h *Handler) Register(e *echo.Echo) { h.jsonInit() e.POST("/users", h.addUser) e.GET("/users", h.getUsers) e.GET("/users/:id", h.getUserByID) e.PUT("/users/:id", h.updateUserByID) e.DELETE("/users/:id", h.deleteUserByID) }
package main import "fmt" type MethodUtils struct { } func (mu MethodUtils) Print() { for i := 1; i <= 10; i++ { for j := 1; j <= 8; j++ { fmt.Print("*") } fmt.Println() } } func (mu MethodUtils) Print2(m int, n int) { for i := 1; i <= m; i++ { for j := 1; j <= n; j++ { fmt.Print("*") } fmt....
package util_test import( "util" "testing" // "fmt" ) func Test_LogError(t *testing.T){ logger := util.NewLog() logger.Error("This is a logging error!") logger.Error("This is second logging error!") }
package cancel_by_close import ( "fmt" "testing" "time" ) /* 获取取消通知 */ func isCanceled(cancelChannel chan struct{}) bool { select { case <-cancelChannel: return true default: return false } } /* 发送取消消息 */ func cancel_1(cancelChannel chan struct{}) { cancelChannel <- struct{}{} } /* 发送取消消息 */ func can...
// Package strain contains methods for keeping or discarding values in a collection package strain type Ints []int type Lists [][]int type Strings []string // Ints.Keep keeps integers in the collection that return true based on the passed in function func (in Ints) Keep(keepIt func(int) bool) Ints { var ret Ints f...
package api import ( "mvp/integration" "net/http" ) type HttpApi struct { server *http.Server log *integration.Logger } func New() HttpApi { a := HttpApi{&http.Server{Addr:":8080"},integration.NewLogger("Api")} return a } func (a HttpApi) Listen() { a.log.Write("Starting HTTP listener") http.ListenAndServe...
package main type mockStorage struct { urls map[string]Url } func NewMockStorage() *mockStorage { return &mockStorage{make(map[string]Url)} } func (s *mockStorage) UrlStore() UrlStore { return s } func (s *mockStorage) Update(u *Url) error { s.urls[u.Hash] = *u return nil } func (s *mockStorage) Get(hash stri...
package recursivelistener_test import ( "context" "net" "testing" "time" "github.com/rwool/ex/test/helpers/goroutinechecker" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/rwool/ex/log" "github.com/rwool/ex/test/helpers/clientserverpair" "github.com/rwool/ex/test/h...
package flow import ( "context" "encoding/gob" "encoding/json" "fmt" "strings" "sync" "time" cloudevents "github.com/cloudevents/sdk-go/v2" "github.com/cloudevents/sdk-go/v2/event" "github.com/direktiv/direktiv/pkg/flow/bytedata" "github.com/direktiv/direktiv/pkg/flow/database" "github.com/direktiv/direkt...
package data import ( "github.com/astaxie/beego/orm" "github.com/astaxie/beego" "strings" ) type VideoFo struct { Id int64; FileId string UpdateTime string Url string Name string } //根据URL截取视频名称 func (this *VideoFo)GetVideoName()(name string){ name ="" if this.Url!="" { var ind int =strings.Las...
package models type Post struct { PostId int `gorm:"primary_key;AUTO_INCREMENT" json:"postId"` //岗位编号 PostName string `gorm:"type:varchar(128);" json:"postName"` //岗位名称 PostCode string `gorm:"type:varchar(128);" json:"postCode"` //岗位代码 Sort int `gorm:"type:int(4);" json:"sort"` ...
package main import ( "flag" "github.com/iberryful/sproxy/pkg/client" "github.com/iberryful/sproxy/pkg/log" "github.com/pkg/profile" "time" ) var ( secret string remoteAddr string listenAddr string logLevel string poolSize int enableProfile bool timeout time.Duration ) func i...
// Copyright 2021 Matt Layher // 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 tool import ( "fmt" "time" "github.com/faiface/pixel" "github.com/faiface/pixel/pixelgl" "github.com/faiface/pixel/text" ) // Fps : FPS显示组建 type Fps struct { win *pixelgl.Window frames int ticker *time.Ticker txt *text.Text } // NewFps : 创建新的FPS func NewFps(w *pixelgl.Window, atlas *text.Atla...
package imglib import ( "fmt" "image" "log" "github.com/EdlinOrg/prominentcolor" ) func AvgImgColor(img *image.RGBA) (prominentcolor.ColorRGB, error) { colors, err := prominentcolor.KmeansWithAll(3, img, prominentcolor.ArgumentDefault, prominentcolor.DefaultSize, []prominentcolor.ColorBackgroundMask{}) if err ...
package golang import ( "sort" ) func countPairs(deliciousness []int) int { sort.Ints(deliciousness) dict := map[int]int{} ans, modulo := 0, int(1e9+7) for _, val := range deliciousness { anotherVal := findAnotherVal(val) count, exist := dict[anotherVal] if exist { ans = (ans + count) % modulo } ...
package api import ( "github.com/arxdsilva/olist/record" check "gopkg.in/check.v1" ) func (s *S) Test_filterRecordsPeriod(c *check.C) { r := []record.Record{ record.Record{Type: "start", CallID: "123", Month: 1}, record.Record{Type: "end", CallID: "123", Month: 1}, } gotRFiltered := filterRecordsPeriod(r, 1)...
package totp import ( "encoding/base32" "fmt" "time" "github.com/pquerna/otp" "github.com/pquerna/otp/totp" "github.com/authelia/authelia/v4/internal/configuration/schema" "github.com/authelia/authelia/v4/internal/model" ) // NewTimeBasedProvider creates a new totp.TimeBased which implements the totp.Provide...
package tests_test import ( "math/rand" "runtime" "strings" "testing" "time" ecombase "github.com/codedv8/go-ecom-base" ) func TestListSize(t *testing.T) { n := 17 size := (n + 1) / 2 if size != 9 { t.Errorf("Size for %d should be 9 but we got %d\n", n, size) } n = 457 size = (n + 1) / 2 if size != 2...
package main // 外部变量 + 哈希查找 + 递归 var forest []*TreeNode var shouldDelete map[int]bool func delNodes(root *TreeNode, to_delete []int) []*TreeNode { forest = make([]*TreeNode, 0) shouldDelete = make(map[int]bool) for i := 0; i < len(to_delete); i++ { shouldDelete[to_delete[i]] = true } delNodesExec(root, true) r...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/6/25 9:00 上午 # @File : lt_offer_数组中重复的数字.go # @Description : # @Attention : */ package v2 func findRepeatNumber(nums []int) int { for i := 0; i < len(nums); i++ { for nums[i] != i { if nums[nums[i]] == nums[i] { return nums[i] } nums[i], nums[...
package main import ( "context" "fmt" "time" "google.golang.org/grpc" "github.com/reddtsai/goreddprints/grpc/pkg/rpc" ) func main() { conn, err := grpc.Dial("0.0.0.0:6424", grpc.WithInsecure(), grpc.WithBlock()) if err != nil { fmt.Println(err) } defer conn.Close() c := rpc.NewSampleServiceClient(conn) ...
package main import ( "fmt" "net/http" "io/ioutil" "encoding/json" "time" "strconv" "sync" ) type safeCommands struct { commands map[int]string mux sync.Mutex } func (c *safeCommands) addCommand(id int, cmd string) { c.mux.Lock() c.commands[id] = cmd c.mux.Unlock() } type UpdateStruc struct { Agents []A...
/* Copyright The ORAS 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, software distrib...
package syncer import ( "encoding/json" "os" "time" "github.com/cloudfoundry-incubator/route-emitter/nats_emitter" "github.com/cloudfoundry-incubator/route-emitter/routing_table" "github.com/cloudfoundry-incubator/runtime-schema/bbs" "github.com/cloudfoundry-incubator/runtime-schema/models" "github.com/cloudf...
package mongo_test import ( // Standard Library Imports "context" "fmt" "os" "testing" // External Imports "github.com/globalsign/mgo" // Public Imports "github.com/matthewhartstonge/storage/mongo" ) func TestMain(m *testing.M) { // If needed, enable logging when debugging for tests //mongo.SetLogger(log...
package main import piscine "./functions" func main() { //piscine.IsNegative(1) //piscine.IsNegative(0) //piscine.IsNegative(-1) //piscine.PrintComb() //piscine.PrintComb2() piscine.PrintNbr(-123) //piscine.PrintNbr(0) //piscine.PrintNbr(123) }
package hsp import ( "bytes" "encoding/base64" "encoding/json" "fmt" "net/http" ) // BaseURL sets the base URL used by Client to make requests to the HSP API func BaseURL(path string) func(*Client) { return func(c *Client) { c.basePath = path } } // HTTPClient sets the *http.Client used by Client to make re...
//+build wireinject package main import ( "github.com/google/wire" "github.com/o1111001/virtual-disk-management/server/disks" ) func ComposeApiServer(port HttpPortNumber) (*ApiServer, error) { wire.Build( NewDbConnection, disks.Providers, wire.Struct(new(ApiServer), "Port", "DisksHandler"), ) return nil, ...
package suites import ( "testing" "github.com/stretchr/testify/suite" ) func NewMultiCookieDomainSuite() *MultiCookieDomainSuite { return &MultiCookieDomainSuite{ BaseSuite: &BaseSuite{ Name: multiCookieDomainSuiteName, }, } } type MultiCookieDomainSuite struct { *BaseSuite } func (s *MultiCookieDomain...
package main import ( "encoding/gob" "fmt" "log" "net" "os" "os/exec" "strings" "runtime" "syscall" "strconv" ) type Buffer struct { content string } func (buf *Buffer) set(val string) { buf.content = val } func (buf *Buffer) get() string { return buf.content } var ( pidfile_path = "/var/run/share...
package utils var Global map[string]interface{} = make(map[string]interface{}) var AppConfig *HoconConfig const POSTGRES_ENTITY = "POSTGRES_ENTITY"
package cmd import ( "fmt" "os" "github.com/dzkb/wave2stqc/pkg/wave" "github.com/spf13/cobra" ) var ( sampleRate int ) var rootCmd = &cobra.Command{ Use: "wave2stqc", Short: "wave2stqc processes raw waveform and detects STQC tones", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []strin...
package main import ( "log" "runtime" "sync" ) func main() { runtime.GOMAXPROCS(4) var balance float64 var wg sync.WaitGroup var m sync.Mutex deposit := func(amount float64) { m.Lock() defer m.Unlock() balance += amount } withdraw := func(amount float64) { m.Lock() defer m.Unlock() balance -=...
package controller import ( "context" "log" "testing" odm "github.com/SaiNageswarS/mongo-odm" pb "github.com/SaiNageswarS/builder-factory/model/services" "github.com/SaiNageswarS/builder-factory/services/db" . "github.com/smartystreets/goconvey/convey" ) func getApplicationDetailProto(orgName string, appName...
package chunker import ( "io" "sync" ) const ( kiB = 1024 miB = 1024 * kiB // WindowSize is the size of the sliding window. windowSize = 64 // MinSize is the default minimal size of a chunk. MinSize = 512 * kiB // MaxSize is the default maximal size of a chunk. MaxSize = 8 * miB chunkerBufSize = 512 * k...
package rtp import ( "testing" ) func TestToUint(t *testing.T) { tests := []struct { arr []byte exp uint }{ {[]byte{1, 2}, 0x102}, {[]byte{3, 2, 1, 0}, 0x3020100}, } for _, tst := range tests { val := toUint(tst.arr) if val != tst.exp { t.Errorf("%d != %d for % x", val, tst.exp, tst.arr) } } }
package file_disk_cache_test import ( "ms/sun/servises/file_service/file_common" "net/url" "testing" "ms/sun/servises/file_service_kb_without_refrence/file_disk_cache" "fmt" ) var config = &file_common.FileServingConfig{ DiskDirs: []string{"D:/sun/a/", "D:/sun/b/"}, FileServerId: 1, } func Bench...
package services import ( "io" "github.com/devspace-cloud/devspace/pkg/devspace/config/generated" "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/latest" "github.com/devspace-cloud/devspace/pkg/devspace/kubectl" "github.com/devspace-cloud/devspace/pkg/devspace/services/targetselector" "github.c...
var c float32 = 1.1
/* * Copyright 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 to i...
// Go support for Protocol Buffers RPC which compatiable with https://github.com/Baidu-ecom/Jprotobuf-rpc-socket // // Copyright 2002-2007 the original author or authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // Yo...
package main import ( "os" "fmt" "bufio" ) func main() { //全路径 file, err := os.Open("c:/keyvalue.txt") if err != nil { fmt.Println("read file err:",err) return } //关闭文件 defer file.Close() reader := bufio.NewReader(file) str, err := reader.ReadString('\n') if err != nil { fmt.Println("read string e...
package main import ( "testing" _ "net/rpc" _ "net" "tribproto" "tribbleclient" "os" "runjob" "fmt" "math/rand" "time" "runtime" "log" ) const ( START_PORT_NUMBER = 10000 ) func startServerGeneral(t *testing.T, port int, master_port int, lognum int, numservers int) *runjob.Job { // Semantics: If ma...
/* * Copyright (c) 2021 - present Kurtosis Technologies LLC. * All Rights Reserved. */ package files_artifact_mounting_test import ( "github.com/kurtosis-tech/kurtosis-client/golang/networks" "github.com/kurtosis-tech/kurtosis-client/golang/services" "github.com/kurtosis-tech/kurtosis-libs/golang/lib/testsuite"...
package payment type HybridAccount struct { CreditAccount CheckingAccount } func (h *HybridAccount) AvailableFunds() float32 { println("Getting total funds from hybrid account...") return h.CreditAccount.AvailableFunds() + h.CheckingAccount.AvailableFunds() }
package controllers import ( "github.com/astaxie/beego" "scholarship/models" "fmt" middleware "scholarship/middlewares" ) type UserController struct { beego.Controller } // @Title Get // @Description register user // @Param name query string true "userName of the user" // @Param password query string true "p...
/* Here we have created a race condition in the func 'withRaceCondition' This function uses two goroutines to run another 'increment' function that takes two arguments: an integer pointer and an amount to increment by. If we start with x=0 and increment this by 10K twice then we expect x=20K. However, if we run ...
package device import( "time" "github.com/haxpax/goserial" ) func CanOpenPort(port string) bool{ c := &serial.Config{Name: port, Baud: 115200, ReadTimeout: time.Second} s, err := serial.OpenPort(c) if err == nil { s.Close() return true } return false }
package dbfactory import ( "fmt" "strings" terraform "github.com/mattermost/mattermost-cloud-database-factory/internal/tools/terraform" "github.com/mattermost/mattermost-cloud-database-factory/model" "github.com/pkg/errors" ) var templateDir = "terraform/aws/database-factory" // InitCreateCluster is used to ca...
package app import ( "github.com/spf13/cobra" "github.com/ChrisRx/splits/cmd/splits/app/new" "github.com/ChrisRx/splits/cmd/splits/app/run" ) func NewCommand() *cobra.Command { cmd := &cobra.Command{ Use: "splits", Short: "", } cmd.AddCommand( new.NewCommand(), run.NewCommand(), ) return cmd }
package main import ( "errors" "fmt" chain "github.com/g8rswimmer/error-chain" ) type myError struct { code int } func (e *myError) Error() string { return fmt.Sprintf("%d", e.code) } func (e *myError) Is(target error) bool { te, ok := target.(*myError) if ok == false { return false } return e.code == t...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //14. Longest Common Prefix //Write a function to find the longest common prefix string amongst an array of strings. //If there is no common prefix, re...
package main import ( "flag" "fmt" "log" "net/http" "os" "gophercises/adventure/story" ) func main() { port := flag.String("port", ":3000", "server port") filename := flag.String("story", "story/stories.json", "JSON file with the story.") flag.Parse() fmt.Printf("Using the story in %s.\n", *filename) fil...
package main const Name string = "fint-consumer" var Version string = "0.0.0"
// Copyright © 2020 Banzai Cloud // // 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 calculate import "strconv" func calculate(s string) int { if len(s) == 0 { return 0 } return calc(s, 0, '+') } func calc(s string, now int, label byte) int { for index := 0; index < len(s); { switch s[index] { case '(': jndex := findMyRight(s[index:]) next := calculate(s[index+1 : index+jndex...
package types // NumberOfTravelAgencies holds the data for the number of travel agencies. type NumberOfTravelAgencies struct { Year int `json:"year" fake:"{year}"` Quarter string `json:"quarter" fake:"{randomstring:[Q1,Q2,Q3,Q4]}"` Active int `json:"active" fake:"{number:0,10000}"` Entrants int `js...
package main import ( "bytes" "errors" "fmt" "net/http" "os" "strconv" "strings" "github.com/360EntSecGroup-Skylar/excelize" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/dynamodb" "github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute" "github.com/aws/aws-sdk-go/service/s3" "...
//Package handlers : collection of handlers (aka "HTTP middleware") package handlers import ( "net/http" "time" "github.com/layer5io/meshery/models" ) // LoginHandler redirects user for auth or issues session func (h *Handler) LoginHandler(w http.ResponseWriter, r *http.Request, p models.Provider, fromMiddleWare ...
/* 声明: the following types can't be embedded. 1. Defined pointer types. 2. Unnamed non-pointer types. 3. Pointer types whose base types are either interface or poiner types. 举例: 如下情况中: type Encoder interface {Encode([]byte) []byte} type Person struct {name string; age int} type Alias = struct {name str...
package main import ( "bytes" "encoding/json" "fmt" "log" "net/http" "os" "sync" "time" "github.com/kazetora/evermos-assignment/problem_1_ecommerce/configs" "github.com/kazetora/evermos-assignment/problem_1_ecommerce/controllers" "github.com/kazetora/evermos-assignment/problem_1_ecommerce/database" "githu...
/* 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 writ...
package utils import ( "encoding/json" "errors" "fmt" "gitlab.bertha.cloud/partitio/Nextcloud-Partitio/gonextcloud" ) type NextcloudOIDCEntry struct { Name string `json:"name"` Title string `json:"title"` AuthorizeUrl string `json:"authorizeUrl"` TokenUrl string `json:"tokenUrl"` UserInfoUrl string `json:"us...
// Copyright 2021 Clivern. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package controller import ( "fmt" "net/http" "strings" "time" "github.com/clivern/peanut/core/driver" "github.com/clivern/peanut/core/model" "github.com/gin-goni...
package main const defaultWorkingDir = "./config"
// ˅ package main import ( "bytes" ) // ˄ type ListPage struct { // ˅ // ˄ Page // ˅ // ˄ } func NewListPage(title string, author string) *ListPage { // ˅ listPage := &ListPage{} listPage.Page = *NewPage(title, author) return listPage // ˄ } func (self *ListPage) ToHTML() string { // ˅ var buffer ...
package command import ( "context" "fmt" "os" "strings" ) type GetCommand struct { *baseCommand } func (c *GetCommand) Help() string { helpText := ` Usage: b2 get <source> <destination> Downloads the given file to the destination. General Options: ` + c.generalOptions() return strings.TrimSpace(helpTex...
package mongo
package ginit import ( "fmt" "encoding/json" "io/ioutil" "os" ) type GoInitConfig struct { goPackageDirectory string } func runInstallation(config GoInitConfig) error { fmt.Println("Welcome to ginit!\n We just need to set up a few configuration values to start") fmt.Println("What is the directory that you wou...
package apigen //DoPostProcess - This function post process the response returned from the database func DoPostProcess(apimodel API) []string { postProcess := apimodel.Methods.Detail.PostProcess if isPostProcessEnabled(postProcess) { return apimodel.Methods.Detail.PostProcess } return []string{} } func isPostPr...
package controllers import ( "app/manager/middlewares" "github.com/gin-gonic/gin" ) func initRouter(handler gin.HandlerFunc) *gin.Engine { return initRouterWithPath(handler, "/") } func initRouterWithPath(handler gin.HandlerFunc, path string) *gin.Engine { router := gin.Default() router.Use(middlewares.RequestR...
package ports type Converter interface { IsSupported(lang string) error To(number int, lang string) string }
package drivers import ( "io" "github.com/mh-orange/tuner" "github.com/mh-orange/tuner/api" ) const ( PIPE_DRIVER_NAME = "pipe" ) type PipeDriverConfig struct { Exec string Loop bool Channel string } type pipeTuner struct { cfg *PipeDriverConfig } func newPipeTuner(cfg *PipeDriverConfig) (tuner.Tune...
func twoSum(nums []int, target int) []int { m := make(map[int]int) for idx, v := range(nums) { complement := target - v i, ok := m[complement] if ok { return []int{i, idx} } m[v] = idx } return []int{0, 0} // it should never execute }
package set type addTests struct { values []int result []int } type deleteTests struct { start set values []int result []int } type unionTests struct { sets []set result []int } type intersectionTests struct { start set sets []set result []int } type differenceTests struct { a set b set...