text
stringlengths
11
4.05M
package bitty /* Copyright 2020 IBM 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, so...
/* The van der Corput sequence is one of the simplest example of low-discrepancy sequence. Its n-th term is just 0.(n written in base 10 and mirrored), so its first terms are : 0.1, 0.2,0.3,0.4, 0.5,0.6,0.7, 0.8,0.9, 0.01, 0.11,0.21,0.31, 0.41,0.51,0.61, 0.71,0.81,0.91, 0.02, 0.12,0.22,0.32, 0.42,0.52,0.62, 0.72,0.82...
package htmlutil import ( "bytes" "strings" "golang.org/x/net/html" "golang.org/x/net/html/atom" ) // SpaceBetweenCharacters is the average amount of space (as a proportion of font size) between characters in a block of text const SpaceBetweenCharacters = 0.0286 // characterWidths contains the relative size of ...
// Copyright 2016 Arsham Shirvani <arshamshirvani@gmail.com>. All rights reserved. // Use of this source code is governed by the Apache 2.0 license // License that can be found in the LICENSE file. // Package rainbow prints texts in beautiful rainbows in terminal. Usage is very // simple: // // import "github.com/ar...
package graph_test import ( "testing" "graph" ) func Test_Graph_AddVert(t *testing.T) { g := new(graph.Graph) v, ok := g.AddVert("foo") if !ok { t.Errorf("Graph.AddVert failed v:%v, ok:%v", v, ok) } v, ok = g.AddVert(nil) if !ok { t.Errorf("Graph.AddVert failed to add nil v:%v, ok:%v", v, ok) } v, ok = ...
package pages import "net/http" type Usage struct { Name, Description string } type Language struct { Name string SkillLevel string Usages []Usage Opinion string } type AboutInfo struct { Languages []Language } func GetGolang() Language { rest := Usage{ Name: "REST APIs", Description: "The concurrency m...
package trie import ( "math/bits" "github.com/openacid/low/bitmap" ) func (st *SlimTrie) getIthInner(ithInner int32, qr *querySession) { ns := st.inner vars := st.vars innWordI := ithInner >> 6 innBitI := ithInner & 63 if ithInner < ns.BigInnerCnt { qr.wordSize = bigWordSize qr.from = ithInner * bigInne...
package honeycombio import ( "context" "fmt" "testing" "time" "github.com/stretchr/testify/assert" ) // create a board with an elaborate QuerySpec as smoke test func TestQuerySpec(t *testing.T) { ctx := context.Background() c := newTestClient(t) dataset := testDataset(t) query := QuerySpec{ Calculations...
package rest_test import ( "io" "net/http" "path/filepath" "testing" "github.com/iris-contrib/httpexpect" r "github.com/jinmukeji/jiujiantang-services/api-v2/rest" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) // MeasurementTestSuite 是measurement的单元测试的 Test Suite type Measurement...
package main import ( "fmt" "unsafe" ) type Part1 struct { a bool b int32 c int8 d int64 e byte } type Part2 struct { e byte c int8 a bool b int32 d int64 } func main() { part1 := Part1{} part2 := Part2{} fmt.Printf("part1 size: %d, align: %d\n", unsafe.Sizeof(part1), unsafe.Alignof(part1)) fmt.Pri...
package xurl import "strings" // TCP unsures that s url contains TCP protocol identifier. func TCP(s string) string { if strings.HasPrefix(s, "tcp") { return s } return "tcp://" + Address(s) } // HTTP unsures that s url contains HTTP protocol identifier. func HTTP(s string) string { if strings.HasPrefix(s, "ht...
/* * @lc app=leetcode.cn id=1897 lang=golang * * [1897] 重新分配字符使所有字符串都相等 */ // @lc code=start // package leetcode func makeEqual(words []string) bool { length := len(words) byteMap := make(map[byte]int) for i := 0; i < length; i++ { for j := 0; j < len(words[i]); j++ { byteMap[words[i][j]]++ } } for _,...
package views import "github.com/xxxmailk/cera/view" type IndexView struct { view.View } func (i *IndexView) Get() { i.Tpl = "index" i.Data["menu"] = "index" }
package math import "fmt" //Q05 求一个整数的所有乘积因子 func Q05(a int, res []int) { if a == 1 { fmt.Println(res) } for i := 2; i < a+1; i++ { if a%i == 0 { res := res res = append(res, i) Q05(a/i, res) } } }
// Copyright 2014 The quotesrv Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* quotesrv is a "quotes server", that exposes a REST API to add and list quotes. Usage: quotesrv [flag] The flags are: -addr=":8001": HTTP service a...
package git /* #include <git2.h> #include <git2/sys/repository.h> #include <git2/sys/commit.h> #include <string.h> */ import "C" import ( "runtime" "unsafe" ) // Repository type Repository struct { doNotCompare ptr *C.git_repository // Remotes represents the collection of remotes and can be // used to add, remo...
package problem0124 import "testing" func TestSolve(t *testing.T) { t.Log(openLock([]string{"0201", "0101", "0102", "1212", "2002"}, "0202")) }
/* * EVE Swagger Interface * * An OpenAPI for EVE Online * * OpenAPI spec version: 0.4.1.dev1 * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ package swagger // The aggressor corporation or alliance that declared this war, only contains either corporation_id or alliance_id type GetWa...
package posthttpadapter import ( "errors" "net/http" "github.com/alejogs4/blog/src/post/domain/like" "github.com/alejogs4/blog/src/post/domain/post" "github.com/alejogs4/blog/src/shared/infraestructure/httputils" ) // TODO: Look how refactor this function func MapPostErrorToHttpError(err error) httputils.HttpEr...
package aoc import ( "strings" ) // SplitLines splits an input to its lines except the last few ones if they are empty func SplitLines(input string) []string { result := strings.Split(input, "\n") for ii := len(result) - 1; ii >= 0; ii-- { if result[ii] == "" { result = result[:ii] } } return result } //...
// DelDirInfo package DaeseongLib import ( _ "fmt" "io/ioutil" "os" "path/filepath" "sort" ) var ( allfileList = []string{} ) func FindFiles(sPath string) { files, err := ioutil.ReadDir(sPath) if err != nil { panic(err) } for _, f := range files { sDir := filepath.Join(sPath, f.Name()) if f.IsDir(...
package backend import ( "context" "reflect" "time" machinev1beta1 "github.com/openshift/cluster-api/pkg/apis/machine/v1beta1" clusterapiclient "github.com/openshift/cluster-api/pkg/client/clientset_generated/clientset" "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimach...
//using conditions operator package main import ( "fmt" ) func main() { x := 10 if x > 3 { fmt.Printf("x is bigger than %v\n",x) } if x > 100 { fmt.Printf("x is very big \n") } else { fmt.Printf("x is not that big \n") } if x > 5 && x<15 { fmt.Println("x is just right") } if x <20 || x > 30 { ...
package server import ( "context" "errors" "fmt" "net/http" "time" "github.com/calvinmclean/automated-garden/garden-app/pkg" "github.com/calvinmclean/automated-garden/garden-app/pkg/influxdb" "github.com/calvinmclean/automated-garden/garden-app/pkg/mqtt" "github.com/go-chi/chi/v5" "github.com/go-chi/render"...
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License. // // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc. package liteconfig import ( "fmt" "math/rand" "os" "path/filepath" "strings" "time" "githu...
// 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 misc import ( "errors" "fmt" parser "github.com/romshark/llparser" ) const ( _ parser.FragmentKind = iota // FrSpace represents a space fragment kind FrSpace // FrWord represents a word fragment kind FrWord // FrSign represents a special character fragment kind FrSign ) // Lexer represents a ba...
package main import ( "bytes" "fmt" "net" "net/http" "net/http/httptest" "net/url" "strings" "testing" "time" "github.com/aws/aws-sdk-go/aws/credentials" v4 "github.com/aws/aws-sdk-go/aws/signer/v4" "github.com/stretchr/testify/assert" ) // func TestMain(m *testing.M) { // log.SetOutput(ioutil.Discard) ...
package global import ( ut "github.com/go-playground/universal-translator" "shop-web/user-api/config" "shop-web/user-api/proto" ) var ( ServerConfig = &config.ServerConfig{} Trans ut.Translator UserServiceClient proto.UserClient NacosConfig = &config.NacosConfig{} )
package image import ( "io" "os" "path/filepath" "regexp" "strings" "github.com/kdada/tinygo" ) var ImgIsoSize = map[string]int{ ``: 500, `user(\\|\/)\d+(\\|\/)headimgs`: 200, `productsets(\\|\/)\d+(\\|\/)carouselpics`: 380, `productsets(\\|\/)\d+(\\|\/)editorimages`: 720, `productsets(\\|\/...
package jq_test import ( "strings" "testing" "github.com/ashb/jqrepl/jq" ) func TestJqNewClose(t *testing.T) { jq, err := jq.New() if err != nil { t.Errorf("Error initializing jq_state: %v", err) } jq.Close() // We should be able to safely close multiple times. jq.Close() } func TestJqCloseRace(t *te...
// Copyright 2013 Bobby Powers. All rights reserved. // Use of this source code is governed by the MIT // license that can be found in the LICENSE file. package main import ( "compress/gzip" "io" "net/http" "strings" ) type gzipHandler struct { http.Handler } type gzipResponseWriter struct { io.Writer http.R...
package queue import ( "sync" "sync/atomic" ) // ArrayQueue .. type ArrayQueue struct { object []interface{} size int32 mu sync.Mutex } // Push .. add x as element Len() func (p *ArrayQueue) Push(x interface{}) { p.mu.Lock() defer p.mu.Unlock() p.object = append(p.object, x) atomic.AddInt32(&p.size, 1...
package main import ( "fmt" ) // Variadic means zero or more i.e. variadic function can be called with zero or more arguments // Variadic parameter have to be the last parameter in the function // If no argument is passed to the variadic function, the value passed will be "nil" func main() { fmt.Println("Cal...
package nanokontrol2 import ( "fmt" "github.com/telyn/midi/korg/korgdevices" "github.com/telyn/midi/korg/korgsysex/format4" "github.com/telyn/midi/sysex" ) const ( SetModeResponseID byte = 0x40 DataDumpTwoByteResponseID byte = 0x5F DataDumpResponseID byte = 0x7F ) const ( ModeResponseFunction...
package linkedlist func hasCycle(head *ListNode) bool { fast, slow := head, head for fast != nil && fast.Next != nil { fast = fast.Next.Next slow = slow.Next if fast == slow { return true } } return false } func inCircle(head *ListNode) *ListNode { fast, slow := head, head for fast != nil && fast.Nex...
// Makes use of my homegrown AWS CLI JSON parser. package main import ( "encoding/json" "fmt" "io/ioutil" "go.jlucktay.dev/golang-workbench/aws2tf/aws2tf" ) func main() { raw, err := ioutil.ReadFile("sg-support.json") if err != nil { panic(err) } var sgsupport aws2tf.SGFile err = json.Unmarshal(raw, &sg...
package math func Max(val int, vals ...int) int { max := val for _, v := range vals { if max <= v { max = v } } return max } func Min(val int, vals ...int) int { min := val for _, v := range vals { if min >= v { min = v } } return min }
package route import ( "fmt" "sort" set "github.com/deckarep/golang-set" xds_route "github.com/envoyproxy/go-control-plane/envoy/config/route/v3" xds_matcher "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3" "github.com/golang/protobuf/ptypes/wrappers" "github.com/openservicemesh/osm/pkg/constant...
package commands import ( "context" "crypto/x509" "fmt" "os" "os/user" "strconv" "strings" "syscall" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/authelia/authelia/v4/internal/authentication" "github.com/authelia/authelia/v4/internal/authorization" "github....
/* * 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://...
package service import ( "github.com/TodoApp2021/gorestreact/pkg/kafka" "github.com/TodoApp2021/gorestreact/pkg/models" "github.com/TodoApp2021/gorestreact/pkg/repository" ) type TodoItemService struct { itemRepo repository.TodoItem listRepo repository.TodoList producer kafka.TodoItem // TODO } func NewTodoIte...
package connect import ( "github.com/micro/go-micro/v2/errors" alipay "github.com/smartwalle/alipay/v3" "time" ) var alipayClient *alipay.Client func ConnectAlipay(srvName string, confName string) (*alipay.Client, error) { if alipayClient != nil { return alipayClient, nil } conf, _, err := ConnectConfig(srv...
package logconfig import ( "go.uber.org/zap" "go.uber.org/zap/zapcore" "github.com/andywow/golang-lessons/lesson-calendar/internal/calendar/config" ) // GetLoggerForConfig get logger for config func GetLoggerForConfig(cfg *config.Config) (*zap.Logger, error) { return zap.Config{ Encoding: "json", // set lo...
package integration import ( "os" "github.com/opencontainers/runc/libcontainer/configs" "golang.org/x/sys/unix" ) var standardEnvironment = []string{ "HOME=/root", "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "HOSTNAME=integration", "TERM=xterm", } const defaultMountFlags = unix.MS_N...
package command import ( "github.com/ikaven1024/bolt-cli/cli/framework" "github.com/ikaven1024/bolt-cli/cli/util/color_str" ) type bucketContext struct { *framework.BaseContext bucketName string } func NewBucketContext(fw framework.Framework, bucketName string) framework.Context { c := &bucketContext{ BaseCo...
package ddl import ( "database/sql" "errors" "fmt" "github.com/iftsoft/gopack/lla" "time" ) // Database Configuration type DBaseConfig struct { DbDriver string HostName string HostPort string BaseName string UserName string UserPass string MaxIdle int MaxOpen int MaxTime int } // Print config data t...
/* 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 distributed under the License i...
// 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 models import ( "encoding/xml" "fmt" "io/ioutil" "math/rand" "os" // postgres db driver _ "github.com/jinzhu/gorm/dialects/postgres" // import sqlite3 driver _ "github.com/jinzhu/gorm/dialects/sqlite" ) // Bill struct type Bills struct { Bill []Bill `xml:"Bill"` } // Bill struct type Bill struct...
package reorganizeString import "testing" func Test_reorganizeString(t *testing.T) { type args struct { S string } tests := []struct { name string args args want string }{ // TODO: Add test cases. { name: "first", args: args{ S: "aab", }, want: "aba", }, { name: "second", arg...
package powerdns import ( "context" "fmt" "io" ) // ZonesService handles communication with the zones related methods of the Client API type ZonesService service // Zone structure with JSON API metadata type Zone struct { ID *string `json:"id,omitempty"` Name *string `json:"name,om...
package handlers import ( "github.com/gin-gonic/gin" "test.com/borzoj/pde/events" ) // EventsPostHandler hndler type EventsPostHandler struct { service events.ServiceInterface } // NewEventsPostHandler new func NewEventsPostHandler() *EventsPostHandler { return &EventsPostHandler{ service: events.NewService()...
// Copyright 2018 Amazon.com, Inc. or its affiliates. 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. A copy of the // License is located at // // http://aws.amazon.com/apache2.0/ // // or in the "license"...
func Run(input []byte, options ...Option) []byte { renderer := CLIRenderer{} renderer.Init(options...) output := bf.Run(input, bf.WithRenderer(&renderer), bf.WithExtensions( bf.NoIntraEmphasis| bf.Tables| bf.FencedCode| bf.Strikethrough| bf.BackslashLineBreak, )) return output }
package controller import ( "github.com/therecipe/qt/core" "github.com/therecipe/qt/internal/examples/showcases/wallet/files/controller" lcontroller "github.com/therecipe/qt/internal/examples/showcases/wallet/view/left/controller" ) type searchController struct { core.QObject _ func(string) `signal...
package api import ( "context" "testing" "github.com/golang/protobuf/proto" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" echopb "github.com/bradenbass/echo/proto" ) func TestEchoServer_Echo(t *testing.T) { // Arrange echoServer := &EchoServer{} expect := &echopb.EchoResponse{Reply: "Echo!...
package binning import "testing" // Some example intervals with pre-calculated bin numbers. // http://genomewiki.ucsc.edu/index.php/Bin_indexing_system var intervalBins = []struct{ start, stop, bin int }{ {0, 1, 585}, {1<<29 - 1, 1 << 29, 4680}, {0, 1 << 29, 0}, {0, 1 << 17, 585}, {1, 1 << 17, 585}, {0, 1<<17 -...
package main import ( "fmt" "strconv" log "github.com/sirupsen/logrus" "texas_real_foods/pkg/connectors/yelp" "texas_real_foods/pkg/utils" updater "texas_real_foods/pkg/auto-updater" ) var ( // create map to house environment variables cfg = utils.NewConfigMapWithValues( map[...
package postgres import ( "github.com/jasonish/evebox/log" _ "github.com/lib/pq" "github.com/stretchr/testify/require" "os" "path/filepath" "strings" "testing" ) func TestPostgresGetVersion(t *testing.T) { version, err := GetVersion() if err != nil { t.Fatal(err) } log.Println(version) } func TestPostgr...
package main import ( "context" "errors" "fmt" "io" "log" "math" "net" "sync" "time" "github.com/gocql/gocql" "github.com/webdevgopi/chatApp-gRPC/db" "github.com/webdevgopi/chatApp-gRPC/interceptors" "github.com/webdevgopi/chatApp-gRPC/proto" "google.golang.org/grpc/codes" "google.golang.org/grpc/statu...
package util import ( "github.com/lucky2me/log" ) type LcLogger struct { } var Logger log.Logger func InintLogWithRoot(path string) { Logger = log.NewLogger(path) Logger.SetCallDepth(2) }
package main import ( "bytes" "fmt" "io" "io/ioutil" "log" "net/http" "github.com/spf13/viper" "github.com/spf13/cobra" ) // ./Configuration-File-Structure.exe get https://httpbin.org/get // ./Configuration-File-Structure.exe get -u foo -p bar https://httpbin.org/basic-auth/foo/bar // ./Configuration-File-S...
package resolvers import ( "context" "github.com/syncromatics/kafmesh/internal/graph/generated" "github.com/syncromatics/kafmesh/internal/graph/model" "github.com/pkg/errors" ) //go:generate mockgen -source=./sink.go -destination=./sink_mock_test.go -package=resolvers_test // SinkLoader is the dataloader for a...
package main import ( "fmt" ) type Animaler interface { // 获取名字 Get() string // 定义吃的方法 Eat(food string) // 定义走的方法 Walk() } type User struct { uName string uAge int uSex string } // User 实现Animaler的接口 func (u User) Get() string { return u.uName } func (u User) Eat(food string) { fmt.Println(food) } f...
func hammingDistance(x int, y int) int { i := x ^ y cnt := 0 for (i & -i) != 0 { i = i - i & -i; cnt += 1 } return cnt }
package randomutils import ( "fmt" "testing" ) func Test(t *testing.T) { fmt.Println("Test") fmt.Println(RandomString(6)) fmt.Println(RandomNumber(6)) }
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func sum(number int) int { result := 0 if number == 0 { return 0 } result = sum(number-1) + number return result } func main() { result := 0 fmt.Print("Input the number : ") reader := bufio.NewReader(os.Stdin) line, _ := reader.ReadString...
package values import ( "bytes" "encoding/json" "fmt" "reflect" "sort" "strings" "github.com/alessio/shellescape" kj "gomodules.xyz/encoding/json" "sigs.k8s.io/yaml" ) func GetValuesDiff(original, modified map[string]interface{}) (map[string]interface{}, error) { return getValuesDiff(original, modified, ""...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //399. Evaluate Division //Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (flo...
// 35. Implement DH with negotiated groups, and break with malicious "g" parameters package main import ( "bytes" "crypto/aes" "crypto/cipher" "crypto/rand" "crypto/sha1" "errors" "fmt" "math/big" "strings" ) const ( dhPrime = `ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024 e088a67cc74020bbea63b139b...
package streamview import ( "flag" "fmt" "net" "net/http" "time" ) func (sv *StreamView) udpStarter() { ServerAddr, err := net.ResolveUDPAddr("udp", ":"+sv.udpPort) _check(err) fmt.Println("listening UDP on :" + sv.udpPort) ServerConn, err := net.ListenUDP("udp", ServerAddr) defer ServerConn.Close() b...
package keeper import ( "context" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/octalmage/gitgood/x/gitgood/types" ) func (k msgServer) CreateGoal(goCtx context.Context, msg *types.MsgCreateGoal) (*types.MsgCreateGoalResponse, error) { ctx := s...
package errors import ( "log" "testing" ) func TestNew(t *testing.T) { log.Print(New(ErrSuccess)) log.Print(New(ErrUnknownError)) log.Print(New(ErrUnstableNetwork)) log.Print(New(ErrPermissionDeny)) log.Print(New(ErrServiceUnderMaintaining)) log.Print(New(ErrTooMuchRequest)) log.Print(New(ErrServiceNotFound)...
package cli import ( "github.com/spf13/cobra" "strconv" "github.com/althea-net/cosmos-gravity-bridge/gravity/x/gravity/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" ) func CmdCreateOrchestratorAddress() *cobra.Command { cmd :=...
// Copyright 2022 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...
package discovery import ( "sync" "time" log "github.com/golang/glog" "golang.org/x/net/context" "github.com/youtube/vitess/go/vt/topo" "github.com/youtube/vitess/go/vt/topo/topoproto" topodatapb "github.com/youtube/vitess/go/vt/proto/topodata" ) // NewCellTabletsWatcher returns a TopologyWatcher that monit...
package mysqldb import ( "context" "errors" "time" ) const ( // QuestionCount 密保问题的数量 QuestionCount = 3 ) // Language 语言 type Language string const ( // SimpleChinese 简体中文 LanguageSimpleChinese Language = "zh-Hans" // TraditionalChinese 繁体中文 LanguageTraditionalChinese Language = "zh-Hant" // English 英文 L...
package util import ( cloudevents "github.com/cloudevents/sdk-go/v2" "github.com/cloudevents/sdk-go/v2/event" "github.com/pkg/errors" "github.com/batchcorp/plumber-schemas/build/go/protos/encoding" "github.com/batchcorp/plumber-schemas/build/go/protos/records" ) func GenCloudEvent(cfg *encoding.CloudEventSettin...
package views import ( "errors" "fmt" "redis/controllers" "redis/models" "github.com/gin-gonic/gin" "github.com/go-redis/redis" ) func GetEmails(c *gin.Context) { emails, err := controllers.GetEmails() if err != nil { c.JSON(400, gin.H{"error": err}) return } c.JSON(200, emails) } func AddEmail(c *gi...
package main import ( "github.com/omise/omise-go" "github.com/omise/omise-go/operations" "github.com/spf13/cobra" ) var AccountCmd = &cobra.Command{ Use: "account", Short: "Retrieve account object.", RunE: runAccount, } func runAccount(cmd *cobra.Command, args []string) error { return do( &omise.Account{...
package testrail import ( "fmt" "net/url" ) // Project represents a Project type Project struct { Announcement string `json:"announcement"` CompletedOn int `json:"completed_on"` ID int `json:"id"` IsCompleted bool `json:"is_completed"` Name string `json:"name"` ...
package main import( "fmt" "net" "os" "encoding/json" ) //Defining json structs type User struct{ Name UserInfo Email []Email } type UserInfo struct { userName string } type Email struct { emailAddress string } //Function to create a user using User struct func (u User) String() string { userStr...
package main import "fmt" type Person struct { Name string Age int } func main() { // 1 var p1 Person fmt.Println(p1) p2 := Person{"Alex", 20} fmt.Println(p2) // 2, 通过new 创建 & var p3 *Person = new(Person) // 因为p3是一个指针,因此标准的给字段赋值方式 // (*p3).Name = "smith" 也可以这样写 p3.Name = "smith" // 原因: go的设计者 为了程序员使用...
package flagutil import ( "bytes" "strings" ) func (sl *SizeList) String() string { buffer := &bytes.Buffer{} buffer.WriteString(`"`) for index, size := range *sl { buffer.WriteString(size.String()) if index < len(*sl)-1 { buffer.WriteString(",") } } buffer.WriteString(`"`) return buffer.String() } ...
package main import ( "flag" "fmt" "github.com/justindh/fizzbuzz/fizzbuzz" ) func main() { amount := flag.Int("amount", 16, "Amount of Numbers to FizzBuzz test") flag.Parse() for i := 1; i <= *amount; i++ { fmt.Println(fizzbuzz.Fizzbuzz(i)) } }
package foo //大文字はpublic //小文字はprivate const ( Max = 100 min = 1 ) func ReturnMin() int { return min }
package cfrida func Frida_init() { frida_init.Call() } func Frida_shutdown() { frida_shutdown.Call() } func Frida_deinit() { frida_deinit.Call() }
package routes func RegistersStock() { ////中间件 //SR.Use(base.Use) ////注册状态钩子 //SR.Hook(websocket_route.HOOK_NEW_CONN, base.HookNewConn) //SR.Hook(websocket_route.HOOK_CLOSED, base.HookClosed) //SR.Hook(websocket_route.HOOK_NOT_MODULE, base.HookNotModule) //SR.Hook(websocket_route.HOOK_ERROR, base.HookError) //...
package collector /* * This exchange only supports BTC-BRL pair. */ import ( "time" "github.com/golang/glog" "github.com/graarh/golang-socketio" "github.com/graarh/golang-socketio/transport" "github.com/prometheus/client_golang/prometheus" ) // Message sent by the server when an order is created. type OrderM...
// Copyright 2021 beego // // 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, s...
package data import ( "github.com/bububa/oppo-omni/model" ) type QListResponse struct { model.BaseResponse Data *QListResult `json:"data,omitemtpy"` } type QListResult struct { ItemCount int64 `json:"itemCount,omitempty"` TotalCount int64 `json:"totalCount,omitempty"` Items []QListItem `json:...
package gosnowth import ( "context" "fmt" ) // RebuildActivityRequest values represent a request to rebuild activity // tracking data. type RebuildActivityRequest struct { UUID string `json:"check_uuid"` Metric string `json:"metric_name"` } // RebuildActivity rebuilds IRONdb activity tracking data for a list o...
package dushengchen /* Submission: https://leetcode.com/submissions/detail/482436348/ */ func exist(board [][]byte, word string) bool { byteWord := []byte(word) for i := range board { for j := range board[i] { if inner_exist(board, byteWord, i, j) { return true } } } return false } const space = ...
package websocket type LoggerI interface { Info(...interface{}) Infof(string, ...interface{}) Error(...interface{}) Errorf(string, ...interface{}) } type l struct{} func (l) Info(v ...interface{}) {} func (l) Infof(s string, v ...interface{}) {} func (l) Error(v ...interface{}) {} func (l...
package mr import ( "encoding/json" "fmt" "hash/fnv" "io/ioutil" "log" "net/rpc" "os" "sort" ) // // 基本数据结构 // // KeyValue -> 数据格式 type KeyValue struct { Key string Value string } // ByKey -> 数据排序, 用于 reduce_func 前同 key 数据的聚堆 type ByKey []KeyValue func (a ByKey) Len() int { return len(a) } fu...
package practice func dailyTemperatures(T []int) []int { out := make([]int, len(T)) // no newly allocated array in append // will get better performance. stack := make([]int, 0, len(T)) for idx, t := range T { for len(stack) != 0 { ls := len(stack) last := stack[ls-1] if T[last] >= t { break } ...
package day3 import ( "github.com/kdeberk/advent-of-code/2019/internal/utils" ) type point struct { x, y int } func (self point) distance(other point) uint { return uint(utils.AbsInt(self.x-other.x)) + uint(utils.AbsInt(self.y-other.y)) }
package main import "fmt" func main() { c :=make(chan int) go func(){ for i:=0;i<10;i++{ c<-i } close(c) }() for v:=range c{ fmt.Println(v) } //for { //print(c) // fmt.Println(<-c) //} //var input string //fmt.Scanln(&input) } /* func print(c chan int){ fmt.Println(<-c) } */
package main import ( "fmt" "github.com/achakravarty/30daysofgo/day21" ) func main() { intArr := []interface{}{1, 2, 3} strArr := []interface{}{"Hello", "World"} fmt.Print(day21.PrintGeneric(intArr)) fmt.Print(day21.PrintGeneric(strArr)) }