text
stringlengths
11
4.05M
// This basic example illustrates how to setup a Self-Service client to make a simple // API call. The reference for the API can be found at // http://reference.rightscale.com/selfservice/manager/index.html#/ package main import ( "flag" "fmt" "io" "os" "sort" "strings" "text/tabwriter" "github.com/rightscale...
package controllers import ( "os" "ss-backend/models" "time" "github.com/astaxie/beego" ) type ( // ReportController ... ReportController struct { beego.Controller } ) // GetNilaiBarang to get all nilai barang func (c *ReportController) GetNilaiBarang() { var resp RespData var rep models.ReportNilaiBaran...
/* You are given an array A of N elements. For any ordered triplet (i,j,k) such that i, j, and k are pairwise distinct and 1≤i,j,k≤N, the value of this triplet is (Ai−Aj)⋅Ak. You need to find the maximum value among all possible ordered triplets. Note: Two ordered triplets (a,b,c) and (d,e,f) are only equal when a=d ...
package di import ( "fmt" "reflect" "github.com/goava/di/internal/reflection" ) // providerInterface type providerInterface struct { res id provider provider } // newProviderInterface func newProviderInterface(provider provider, as interface{}) (*providerInterface, error) { i, err := reflection.InspectIn...
package main import ( "bytes" "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "os" "os/exec" "path/filepath" "time" "github.com/Sirupsen/logrus" "github.com/spf13/afero" ) // appFs is an aero filesystem. It is stored in a variable so that we can replace it // with in-memory filesystems for unit te...
// Copyright (C) 2020 Storj Labs, Inc. // See LICENSE for copying information. package drpcmux import ( "context" "encoding/json" "io" "io/ioutil" "net/http" "net/textproto" "reflect" "github.com/zeebo/errs" "storj.io/drpc" "storj.io/drpc/drpcerr" ) // ServeHTTP handles unitary rpcs over an http request....
package main import ( "io/ioutil" parser "github.com/romshark/llparser" "github.com/romshark/llparser/misc" ) // FragKind represents a dick-lang fragment kind type FragKind parser.FragmentKind const ( _ = misc.FrSign + iota // FrBalls represents the balls FrBalls // FrShaft represents the shaft FrShaft ...
package c38_simplified_srp import ( "crypto/sha256" "math/big" ) type Client struct { Email []byte Password []byte salt []byte Key []byte u *big.Int priv *big.Int Pub *big.Int sPub *big.Int } func (obj *Client) computeK() { xH := sha256.Sum256(append(obj.salt, obj.Password....
package main import ( "io" "io/ioutil" "os" "os/exec" "path/filepath" "reflect" "runtime" "sort" "strings" "testing" "github.com/bradleyjkemp/cupaloy/v2" "golang.org/x/tools/go/packages/packagestest" ) func CreateTestContext(t *testing.T, mode TestMode, debug bool) *TestContext { t.Helper() tc := &Test...
package main import ( "encoding/json" log "github.com/Sirupsen/logrus" "github.com/gorilla/websocket" "github.com/satori/go.uuid" ) type Conn struct { ws *websocket.Conn `json:"-"` SessID string `json:"peerId"` Name string `json:"-"` Room string `json:"-"` // room name ...
/*************************************************************** * * Copyright (c) 2016, Menglong TAN <tanmenglong@gmail.com> * * This program is free software; you can redistribute it * and/or modify it under the terms of the BSD licence * **************************************************************/ /** * ...
package engine import ( "bytes" "encoding/json" "errors" "fmt" ) const ( telemetryInfoVersion1 = "v1" ) var ErrInvalidInstanceTelemetryInfo = errors.New("invalid instance telemetry info") // InstanceTelemetryInfo keeps information useful to our telemetry logic. type InstanceTelemetryInfo struct { Version str...
package main import ( "compress/gzip" "encoding/json" "fmt" "io" "net/http" "os" "strings" "time" ) var port string func main() { assetServer := http.NewServeMux() // Create a separate ServeMux for the asset files if len(os.Args) < 1 && strings.Contains(os.Args[1], "-port=") { port = strings.Replace(os....
package main import ( "flag" "io" "log" "os" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" "strings" ".." ) var ( stderr = flag.Bool("stderr", false, "true if this logs messages from stderr instead of stdout") x = flag.Bool("X", ...
package rpc import ( "context" "errors" "fmt" "io/ioutil" "os" "os/exec" "testing" "github.com/google/go-cmp/cmp" "github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap" "github.com/packethost/pkg/log/logr" "github.com/philippgille/gokv" "github.com/philippgille/gokv/freecache" v1 "github.com/t...
package entity type BlockInfoEntity struct { Previous string `json:"previous"` Timestamp string `json:"timestamp"` TransactionMerkleRoot string `json:"transaction_merkle_root"` Producer string `json:"producer"` ProducerChanges []interface{} `...
package main import ( "fmt" "regexp" "github.com/qaisjp/go-discord-irc/irc/format" ) var colorRegexRepl = regexp.MustCompile(`\x03\d{0,2}(,\d{0,2}|\x02\x02)?`) var msg = "Hello, \u0002Wor\x1dld\u000304,07\x1d!\u000f My name is \x1fqais\x1f patankar. Testing reset\x1f\x1d\x02\x16ONETWO\x0fTHREE. And \x16reverse\x1...
package main // Configuration management for the http server part import ( "encoding/json" "os" ) // Main configuration struct type Configuration struct { // IP on which the webserver should listen on. By default it's 127.0.0.1. // Name in the config file: listener_ip IP string `json:"listener_ip"` // Port on...
// Copyright 2021 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 cluster import ( "fmt" "github.com/nokamoto/grpc-proxy/codec" "github.com/nokamoto/grpc-proxy/server" "github.com/nokamoto/grpc-proxy/yaml" "golang.org/x/net/context" "google.golang.org/grpc" "sync" ) type roundRobin struct { mu sync.Mutex proxies []*proxy next int } // NewRoundRobin return...
package kit import ( "fmt" "log" "os" "os/exec" "path/filepath" "runtime" "strings" ) // FatalOn be careful with it in production, // since it uses os.Exit(1) which affects the control flow. // use pattern: // if err != nil { // .... // } func FatalOn(err error, str ...string) { if err != nil { _, fn, line...
/** * Author: Admiral Helmut * Created: 12.06.2019 * * (C) **/ package classes import "time" type Firmware struct { firmware_id int `db:"firmware_id"` name string `db:"name"` version string `db:"version"` binwalkOutput string `db:"binwalkOutput"` sizeInBytes int `db:"sizeInBytes"` project_id int `db:...
package tracing import ( "testing" "github.com/DavidCai1993/request" "github.com/opentracing/basictracer-go" "github.com/opentracing/opentracing-go" "github.com/stretchr/testify/assert" "github.com/teambition/gear" "github.com/teambition/gear/middleware/requestid" ) func TestGearSession(t *testing.T) { t.Run...
// Copyright © 2021 Attestant Limited. // 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 ginkgotest_test import ( "bytes" "testing" "github.com/mumoshu/gosh" "github.com/mumoshu/gosh/examples/ginkgotest" "github.com/mumoshu/gosh/goshtest" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var app *gosh.Shell var tt *testing.T func TestAcc(t *testing.T) { app = ginkgotest.New() go...
package acmt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00100107 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:acmt.001.001.07 Document"` Message *AccountOpeningInstructionV07 `xml:"AcctOpngInstr"` } func (d *Document00100...
package main import ( "encoding/json" "os" "github.com/mattermost/mattermost-cloud-database-factory/model" "github.com/pkg/errors" "github.com/spf13/cobra" ) func init() { clusterCmd.PersistentFlags().String("server", "http://localhost:8077", "The DB factory server whose API will be queried.") clusterCreateC...
package main import ( "strings" ) func isAnagram(str1 string, str2 string) bool { if len(str1) == 0 && len(str2) == 0 { return true } if len(str1) != len(str2) { return false } // I could make this array's length to 26 but Idk maybe for special characters and whitespaces // not bad after all count := mak...
package repository import ( . "2019_2_IBAT/pkg/pkg/models" "fmt" "reflect" "testing" "github.com/google/uuid" "github.com/jmoiron/sqlx" "github.com/pkg/errors" sqlmock "gopkg.in/DATA-DOG/go-sqlmock.v1" ) func TestDBUserStorage_GetVacancies_Correct(t *testing.T) { db, mock, err := sqlmock.New() defer db.Clo...
package table type Args struct { Quiet bool `name:"quiet" usage:"only print ID" short:"q"` Format string `name:"format" usage:"format(yaml/json/jsoncompact/raw)"` }
package auth import "time" /** * @author 16计算机 Moriaty * @version 1.0 * @copyright :Moriaty 版权所有 © 2020 * @date 2020/4/6 19:35 * @Description TODO * Auth 接口 */ type Auth interface { CheckToken(tokenCode string) *Token PutTokenStorage(token Token) string RemoveToken(tokenCode string) } func NewAuth(name s...
package command import ( "errors" "flag" "fmt" "math" "strconv" "strings" "rsc.io/getopt" "github.com/Vovan-VE/maze-go/internal/cli" "github.com/Vovan-VE/maze-go/pkg/maze" "github.com/Vovan-VE/maze-go/pkg/maze/format" ) // Generate is a "gen" cli command type Generate struct { *command } // NewGenerate ...
package kafka import ( "fmt" "github.com/bsm/sarama-cluster" "os" "os/signal" ) /* kafka消费者 */ type KafkaConsumer struct { consumer *cluster.Consumer subscribers map[string]func(msg string) error } /* 创建kafka消费者实例 */ func NewKafkaConsumer(conf KafkaConsumerConf) (*KafkaConsumer, error) { if conf.Config =...
package rkt import ( "github.com/r3boot/rkt-registrator/utils" "os" ) var ( Log utils.Log Rkt_dir string Cni_dir string ) func Setup(l utils.Log, rkt_dir string, cni_dir string) (err error) { Log = l // Sanity check if _, err = os.Stat(rkt_dir); err != nil { Log.Fatal(rkt_dir + " does not exist") } ...
// Copyright (c) 2019 Chair of Applied Cryptography, Technische Universität // Darmstadt, Germany. All rights reserved. This file is part of go-perun. Use // of this source code is governed by a MIT-style license that can be found in // the LICENSE file. // +build !wrap_test package wallet // import "perun.network/go...
package main import ( "github.com/KyriakosMilad/hello-go/functions" ) func main() { //hello.SayHello() //variables.Variables() //primitives.Primitives() //constants.Constants() //arrays.Arrays() //slices.Slices() //maps.Maps() //structs.Structs() //conditions.Conditions() //loops.Loops() //controls.Contro...
package main import "github.com/golang/protobuf/proto" type msg struct { t uint32 session uint32 data []byte } type msgCB func(*Agent, proto.Message) type msgHandler struct { p proto.Message cb msgCB } var handlers = make(map[uint32]msgHandler) func registerHandler(t uint32, p proto.Message, cb msgC...
// Copyright 2020-2021 Buf Technologies, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law...
package main import ( "testing" "github.com/jackytck/projecteuler/tools" ) func TestP64(t *testing.T) { cases := []tools.TestCase{ {In: 10000, Out: 1322}, } tools.TestIntInt(t, cases, solve, "P64") }
package lawin import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" ) // TransformStrToMap : To string to json map // jsonstr - json String func TransformStrToMap(jsonstr string) map[string]interface{} { var jsonMap map[string]interface{} json.Unmarshal([]byte(jsonstr), &jsonMap) return jsonMap } // ...
package command import ( "github.com/mitchellh/cli" "github.com/romantomjak/b2/version" ) // Commands returns the mapping of CLI commands for B2 func Commands(ui cli.Ui) map[string]cli.CommandFactory { baseCommand := &baseCommand{ ui: ui, } commands := map[string]cli.CommandFactory{ "create": func() (cli.Co...
package main func main() { } func reverseWords(s string) string { length := len(s) ret := []byte{} for i := 0; i < length; { start := i for i < length && s[i] != ' ' { i++ } for p := start; p < i; p++ { ret = append(ret, s[start+i-1-p]) } for i < length && s[i] == ' ' { i++ ret = append(re...
package sessionmanager import ( "context" "testing" "time" bssrs "gx/ipfs/QmYJ48z7NEzo3u2yCvUvNtBQ7wJWd5dX2nxxc7FeA6nHq1/go-bitswap/sessionrequestsplitter" bssession "gx/ipfs/QmYJ48z7NEzo3u2yCvUvNtBQ7wJWd5dX2nxxc7FeA6nHq1/go-bitswap/session" peer "gx/ipfs/QmPJxxDsX2UbchSHobbYuvz7qnyJTFKvaKMzE2rZWJ4x5B/go-libp...
package models import ( "encoding/xml" "reflect" "testing" "github.com/k0kubun/pp" "github.com/ymomoi/goval-parser/oval" ) func TestWalkDebian(t *testing.T) { var tests = []struct { oval string expected []distroPackage }{ { oval: ` <?xml version="1.0" ?> <oval_definitions> <generator> <oval:pr...
package realm_test import ( "testing" "github.com/10gen/realm-cli/internal/cloud/realm" u "github.com/10gen/realm-cli/internal/utils/test" "github.com/10gen/realm-cli/internal/utils/test/assert" ) func TestRealmLogs(t *testing.T) { u.SkipUnlessRealmServerRunning(t) t.Run("with an active session", func(t *test...
package ch06 // these functions are used across examples and exercises func less(value1, value2 int) bool { return value1 < value2 } func more(value1, value2 int) bool { return value1 > value2 }
package main import ( "bytes" "fmt" "os" "sort" "strings" ) // Key–value mappings for the representation of client and server options. // Args maps a string key to a list of values. It is similar to url.Values. type Args map[string][]string // Get the first value associated with the given key. If there are any...
package benchhash2 import ( "sync" ) type HashMap interface { Get(key uint32) (uint32, bool) Put(key, val uint32) } type GoMap struct { sync.RWMutex m map[uint32]uint32 } func (s *GoMap) Get(key uint32) (uint32, bool) { s.RLock() defer s.RUnlock() val, found := s.m[key] return val, found } func (s *GoMap)...
package main import ( "encoding/json" "errors" "flag" "fmt" "github.com/whosonfirst/go-whosonfirst-geojson-v2/feature" "github.com/whosonfirst/go-whosonfirst-geojson-v2/properties/whosonfirst" "github.com/whosonfirst/go-whosonfirst-uri" "io/ioutil" "log" "net/http" "net/url" "strconv" "strings" ) type P...
package main import ( "os" "github.com/codegangsta/cli" ) func main() { app := cli.NewApp() app.Name = "nomadpanel" app.Usage = "nomadpanel" app.Version = serviceVersion app.Author = "antoniofernandezvara@gmail.com" app.Email = "antoniofernandezvara@gmail.com" app.Flags = []cli.Flag{ cli.StringFlag{ ...
package primitives import ( "encoding/xml" "github.com/plandem/ooxml/ml" ) //FontSchemeType is a type to encode XSD ST_FontScheme type FontSchemeType ml.Property //MarshalXML marshal FontSchemeType func (t *FontSchemeType) MarshalXML(e *xml.Encoder, start xml.StartElement) error { return (*ml.Property)(t).Marshal...
package machine import ( "testing" "github.com/stretchr/testify/assert" "github.com/openshift/installer/pkg/asset" "github.com/openshift/installer/pkg/asset/installconfig" "github.com/openshift/installer/pkg/asset/tls" "github.com/openshift/installer/pkg/ipnet" "github.com/openshift/installer/pkg/types" "git...
package main import ( "log" "os" "github.com/tarm/goserial" ) const nLEDs = 92 func main() { // Open the serial port c := &serial.Config{Name: os.Args[1], Baud: 115200} ser, err := serial.OpenPort(c) if err != nil { log.Fatalln("Trouble opening serial: ", err) } buf := make([]byte, (nLEDs*3 + 1)) buf[0...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //28. Implement strStr() //Implement strStr(). //Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystac...
// timer project main.go package main import ( "fmt" "time" ) func main() { fmt.Println("Hello World!") //定时任务开始 for { now := time.Now() fmt.Println("daka——", now.Format("2006-01-02 15:04:05")) // 计算下一个零点 next := now.Add(time.Second * 70) next = time.Date(next.Year(), next.Month(), next.Day(), next.Ho...
package open_im_sdk func triggerCmdFriend() error { return nil } func triggerCmdBlackList() error { return nil } func triggerCmdFriendApplication() error { return nil } type deleteConNode struct { SourceID string ConversationID string SessionType int } func (u *UserRelated) triggerCmdDeleteConver...
package main import ( "fmt" "strconv" "strings" ) func dayOne(data []string) { lines := data freqs := make(map[int]int) answer := 0 dupe := 0 dupeFound := false loops := 0 for !dupeFound { fmt.Println(loops) for _, i := range lines { isPlus := strings.Contains(i, "+") numString := strings.Trim...
package main import "fmt" import "strconv" func main() { fmt.Println("Hello, playground") number := make(map[int]string) number[1] = "one" number[2] = "two" number[3] = "three" number[4] = "four" number[5] = "five" number[6] = "six" number[7] = "seven" number[8] = "eight" number[9] = "nine" number[10] =...
package main import ( "fmt" shortString "sberCloudTest/pkg" ) func main() { str := "aaabbccccdeeeff" res := shortString.Get(str) fmt.Printf("Результат сокращения строки %s: %s\n\n", str, res) stringList := []string{ "aaabbccccdeeeff", "jjjsllkkkkklllllll", "kkkkkffffffjjjjrrrr", "nnnnttttlttttbbbbbb", ...
package routes import ( "github.com/danyalov/shebeke/db" "github.com/labstack/echo" "github.com/labstack/echo/middleware" ) func NewConnection(db *db.DB) *echo.Echo { e := echo.New() env := Env{db} e.Use(middleware.Logger()) e.Use(middleware.Recover()) e.GET("/contracts", env.GetContracts) e.GET("/contract/...
package t2m // Version bla bla const Version = "0.0.7"
package log_test import ( "bytes" "encoding/json" "fmt" . "github.com/nomkhonwaan/myblog/pkg/log" "github.com/stretchr/testify/assert" "net/http" "net/http/httptest" "regexp" "testing" "time" ) type mockTimer time.Time func (timer mockTimer) Now() time.Time { return time.Time(timer) } type mockOutputer s...
package main import ( "fmt" "testing" "log" "os" "os/signal" "github.com/Shopify/sarama" ) // 链接kafka func TestProducer(t *testing.T) { config := sarama.NewConfig() config.Producer.RequiredAcks = sarama.WaitForAll config.Producer.Partitioner = sarama.NewRandomPartitioner config.Producer.Return.Successes =...
package genserver import ( "github.com/Azer0s/quacktors" "github.com/Azer0s/quacktors/typeregister" ) func init() { typeregister.Store(callMessage{}.Type(), callMessage{}) typeregister.Store(castMessage{}.Type(), castMessage{}) typeregister.Store(ReceivedMessage{}.Type(), ReceivedMessage{}) typeregister.Store(R...
/* Write a function that returns true if two arrays, when combined, form a consecutive sequence. Examples consecutiveCombo([7, 4, 5, 1], [2, 3, 6]) ➞ true consecutiveCombo([1, 4, 6, 5], [2, 7, 8, 9]) ➞ false consecutiveCombo([1, 4, 5, 6], [2, 3, 7, 8, 10]) ➞ false consecutiveCombo([44, 46], [45]) ➞ true Notes ...
package api import ( "My-project/conf" "context" "database/sql" "log" "net/http" "time" "github.com/go-chi/chi" ) // API - type for dependency injection type API struct { cnf *conf.Conf ctx context.Context db *sql.DB //hc *http.Client Hs *http.Server } // New initialize api with routes func New(ctx...
package cmd import ( "github.com/niclabs/dhsm-signer/signer" "github.com/spf13/cobra" ) func init() { resetKeysCmd.Flags().StringP("p11lib", "p", "", "Full path to PKCS11 lib file") resetKeysCmd.Flags().StringP("user-key", "k", "1234", "HSM User Login Key (default is 1234)") resetKeysCmd.Flags().StringP("key-lab...
package main import "fmt" func main() { myfunc := Counter() fmt.Printf("%T\n", myfunc) fmt.Println(myfunc()) fmt.Println(myfunc()) fmt.Println(myfunc()) // 创建新的函数, nextNumber1, 并查看结果 //myfunc1 := Counter() //fmt.Println("myfunc1", myfunc1) // //fmt.Println(myfunc1()) //fmt.Println(myfunc1()) //fmt.Prin...
package modules type User struct { Id int Name string Age int Address string Pic string Phone string } type UserInfo struct { Id int Name string Age int Address string Pic string Phone string } type DBUserInfo struct { Id int Name string } type DBXXXUserInfo struc...
package main import "fmt" const Title = "Person Details" var Country = "USA" func main() { fname, lname := "Changxue", "Fan" age := 35 fmt.Println(Title) fmt.Println("First Name: ", fname) fmt.Println("Last Name: ", lname) fmt.Println("Age: ", age) fmt.Println("Country: ", Country) }
package main import "github.com/regit/cmd" func main() { cmd.Execute() }
package main import ( "bufio" "fmt" "io" "log" "net" "time" ) func main() { listener, err := net.Listen("tcp", "localhost:8000") if err != nil { log.Fatal(err) } for { fmt.Println("Hey, I'm listening on port 8000...") conn, err := listener.Accept() if err != nil { log.Print(err) // e.g., connecti...
package iirepo_contents const name string = "contents" // Name returns the name of the repo contents directory. func Name() string { return name }
package authorization import ( "net" "github.com/authelia/authelia/v4/internal/configuration/schema" "github.com/authelia/authelia/v4/internal/utils" ) // NewAccessControlRules converts a schema.AccessControl into an AccessControlRule slice. func NewAccessControlRules(config schema.AccessControl) (rules []*Access...
/* Create a function that expands a decimal number into a string as shown below: 25.24 ➞ "20 + 5 + 2/10 + 4/100" 70701.05 ➞ "70000 + 700 + 1 + 5/100" 685.27 ➞ "600 + 80 + 5 + 2/10 + 7/100" Examples expandedForm(87.04) ➞ "80 + 7 + 4/100" expandedForm(123.025) ➞ "100 + 20 + 3 + 2/100 + 5/1000" expandedForm(50.270) ...
package main type NodeType int64 const ( Directory NodeType = 0 File NodeType = 1 ) func (n NodeType) String() string { switch n { case File: return "file" case Directory: return "dir" } return "unknown" }
package main func findRedundantConnection(edges [][]int) []int { nfs := NewUnionFindSet(len(edges)+1) result := make([]int, 2) for i := 0; i < len(edges); i++ { a, b := edges[i][0], edges[i][1] n1, n2 := nfs.getNode(a), nfs.getNode(b) if n1.find() == n2.find() { result[0],result[1] = a,b }else{ nfs.un...
package payapi import ( "encoding/json" "fmt" "net/url" "strings" "time" "tpay_backend/utils" ) type Tpay struct { Host string // 请求的地址 AccNo string // 商户账号id SecretKey string // 商家通信秘钥 } func NewTpay(host, appId, appSecret string) *Tpay { return &Tpay{Host: host, AccNo: appId, SecretKey: appSecre...
package main import ( "github.com/Jenkins/router" "github.com/Jenkins/setting" "github.com/phjt-go/logger" ) func main() { // 加载日志配置 logger.SetLogger(setting.GetString("logger_jsonFile")) // 启动路由 router.Run() }
package accumulate func Accumulate(list []string, converter func(string) string) []string { accumulation := []string{} for _, s := range list { accumulation = append(accumulation, converter(s)) } return accumulation }
package middleware import ( response "github.com/anraku/echo-sample/response" "net/http" "github.com/labstack/echo" ) // ServerHeader middleware adds a `Server` header to the response. func ServerHeader() echo.MiddlewareFunc { return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) er...
package main import ( "context" "fmt" "log" "net" "os" "os/signal" "syscall" "github.com/bobrovka/calendar/internal" app "github.com/bobrovka/calendar/internal/calendar-app" "github.com/bobrovka/calendar/internal/scheduler" "github.com/bobrovka/calendar/internal/scheduler/producer" "github.com/bobrovka/ca...
package copyfile import ( "io/ioutil" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) var tests = []struct { fromFileName, toFileName string offset, limit int err bool fromFileData, toFileData []byte }{ { offset: -1, err: true, }...
// Package poll provides an easy way to create polls package poll import "errors" var ( ErrorOptionNotFound = errors.New("Option not found") ErrorVoterAlreadyVoted = errors.New("Voter already voted") ) // A poll represents a poll containing a question and options to answer type Poll struct { Question string V...
package lingua import ( "bytes" "errors" "io/ioutil" "net/http" "reflect" "testing" ) type MockClient struct{} var MockedDoFunction = func(req *http.Request) (*http.Response, error) { return nil, errors.New("boom") } func (mc *MockClient) Do(req *http.Request) (*http.Response, error) { return MockedDoFuncti...
package main import ( "fmt" "math" ) func main() { const a = 50 fmt.Println(a) const ( name = "John" age = 50 country = "Canada" ) fmt.Println(name, age, country) const x = 66 //allowed x = 86 // reassignment not allowed var y = math.Sqrt(5) //allowed const z = math.Sqrt(5) //not al...
package parser // scanner represents a sequence-recording lexing source-code scanner type scanner struct { Lexer *lexer Records []Fragment } // newScanner creates a new scanner instance func newScanner(lexer *lexer) *scanner { if lexer == nil { panic("missing lexer during scanner initialization") } return &s...
// Licensed to SolID under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. SolID licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use this file except in compli...
package rados /* #cgo LDFLAGS: -lrados #include "stdlib.h" #include "rados/librados.h" */ import "C" import ( "fmt" "unsafe" ) // Context represents a RADOS IO context for the pool Pool. type Context struct { Pool string ctx C.rados_ioctx_t } // NewContext creates a new RADOS IO context for a given...
// ˅ package main // ˄ type PaintingTarget interface { Paint(paintingPosX int, paintingPosY int) Clear() // ˅ // ˄ } // ˅ // ˄
package drouter_test import "errors" var successError = errors.New("success")
package p09 func diStringMatch(S string) []int { d := make([]int, len(S)+1) i := 0 j := len(S) for k := 0; k < len(S); k++ { if S[k] == 'I' { d[k] = i i++ } else { d[k] = j j-- } } d[len(S)] = j return d }
package ginlogrus import ( "fmt" "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" "time" ) // Logger is the logrus logger handler func Logger(l logrus.FieldLogger) gin.HandlerFunc { if l == nil { l = logrus.StandardLogger() } return func(c *gin.Context) { // other handler can change c.Path so: pa...
package api import "github.com/PhongVX/taskmanagement/internal/app/sprint" func newSprintHandler() (*sprint.Handler, error) { s, err := dialDefaultMongoDB() if err != nil { return nil, err } repo := sprint.NewMongoDBRepository(s) srv := sprint.NewService(repo) handler := sprint.NewHTTPHandler(*srv) return ha...
package utils import ( "io/ioutil" "log" "net/http" "os" "path/filepath" "reflect" "runtime" "testing" "github.com/layer5io/meshery/mesheryctl/internal/cli/root/config" ) func getFixturesDirectory() string { _, filename, _, ok := runtime.Caller(0) if !ok { log.Fatal("helpers_test.go: Cannot get current ...
/* 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...
// Copyright 2019 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 appmanager import ( "context" "errors" "github.com/fintechstudios/ververica-platform-k8s-operator/controllers/utils" appmanager "github.com/fintechstudios/ververica-platform-k8s-operator/appmanager-api-client" ) // GetDeploymentByName fetches a deployment from the VP by namespace and name func GetDeploy...
package Core import ( "sync" "fmt" "com/pdool/DataStruct" ) var eventMgrInstance *EventMgr var eventLock = &sync.Mutex{} func GetEventMgr() *EventMgr { eventLock.Lock() defer eventLock.Unlock() if eventMgrInstance == nil { eventMgrInstance = &EventMgr{msgQueue: &DataStruct.Queue{}} } return eventMgrInstanc...
package config import ( "bytes" "encoding/json" "io/ioutil" "os" "path/filepath" ) type Config struct { LastNamespace string `json:"last_namespace"` LastContext string `json:"last_context"` } func getCfgPath() (string, error) { cfgPath, err := os.UserConfigDir() if err != nil { return "", err } cfgPa...