text
stringlengths
11
4.05M
package scumbag import ( "encoding/json" "fmt" irc "github.com/fluffle/goirc/client" ) const ( githubUserEventsURL = "https://api.github.com/users/%s/events" githubHelp = cmdPrefix + "gh <username>" ) // GithubEvent stores a Github API response. type GithubEvent struct { Payload GithubPayload `json:"...
package pubsub import "net/url" // Request defines the structure of an RPC call type Request struct { Version string `json:"tomatorpc,omitempty"` ID string `json:"id,omitempty"` Group string `json:"group,omitempty"` Entity string `json:"entity,omitempty"` Method string `json:"method,omitempty"` // der...
// 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 main import ( _ "github.com/airdb/airmd/routers" "github.com/astaxie/beego" ) // func markdown(in string) (out string) { // out = in + "world" // return // } func main() { // beego.AddFuncMap("markdown", markdown) beego.SetLogFuncCall(true) // beego.SetLevel(beego.LevelInformational) beego.SetStati...
// Copyright 2011 Google Inc. All Rights Reserved. // This file is available under the Apache license. package metrics import ( "errors" "fmt" "sync" "sync/atomic" "time" ) type MetricType int const ( Counter MetricType = iota Gauge ) var ( Metric_update_time time.Time ) func (m MetricType) String() strin...
package cc import "fmt" // Piece is the interface used to be able to use different implementation details // for the different kinds of pieces. type Piece interface { String() string Threatening(b *Board, x, y uint8) ([]position, error) } type blank cell type dead cell type king cell type queen cell type bishop ce...
package main import ( "bufio" "fmt" "os" "strconv" ) var in = bufio.NewScanner(os.Stdin) /** * */ func main() { in.Split(bufio.ScanWords) N := NextInt() for i := 0; i < N; i++ { } fmt.Println(N) } func NextInt() int { in.Scan() tmp, _ := strconv.Atoi(in.Text()) return tmp } func NextFloat64() flo...
package ravendb import ( "reflect" "time" ) // Note: ISuggestionDocumentQuery is SuggestionDocumentQuery // SuggestionDocumentQuery represents "suggestion" query type SuggestionDocumentQuery struct { // from SuggestionQueryBase session *InMemoryDocumentSessionOperations query *IndexQuery startTime time.T...
package main import ( "fmt" "log" "os/exec" "strings" "gpbdecoder/goproto/proto" "github.com/golang/protobuf/proto" ) func main() { fmt.Println("hello GPB") u := myobject.User{ Id: proto.Int64(1), Name: proto.String("Mike"), Email: proto.String("12345@html.com"), } data, err := proto.Marshal(&u)...
package iam import ( "context" "golang.org/x/text/language" "github.com/caos/zitadel/internal/eventstore" "github.com/caos/zitadel/internal/eventstore/repository" "github.com/caos/zitadel/internal/repository/policy" ) var ( CustomTextSetEventType = iamEventTypePrefix + policy.CustomTextSetEventType ) type Cu...
package main import ( "flag" "fmt" "net/http" os_user "os/user" "time" "youwillfocus/app/common" "youwillfocus/app/home" _ "youwillfocus/app/user" "youwillfocus/app/about" "github.com/golang/glog" "github.com/gorilla/mux" ) func main() { flag.Parse() defer glog.Flush() router := mux.NewRouter() http...
package gl import ( "errors" "unsafe" "github.com/go-gl/gl/v4.1-core/gl" mgl "github.com/go-gl/mathgl/mgl32" ) type Shader struct { id uint32 } func CompileShader(vertexCode string, fragmentCode string) (*Shader, error) { // Compile the shaders vertexShader := gl.CreateShader(gl.VERTEX_SHADER) shaderSource,...
package api import ( "net/http" "github.com/gin-gonic/gin" "github.com/pegasus-cloud/iam_client/iam" "github.com/pegasus-cloud/iam_client/protos" "github.com/pegasus-cloud/iam_client/utility" ) func getMembershipAndPermission(c *gin.Context) { getMembershipAndPermissionOutput, err := iam.GetMembershipAndPermis...
package controller import ( "net/http" "github.com/gin-gonic/gin" "github.com/naiba/nezha/model" "github.com/naiba/nezha/pkg/mygin" "github.com/naiba/nezha/service/singleton" "github.com/nicksnyder/go-i18n/v2/i18n" ) type memberPage struct { r *gin.Engine } func (mp *memberPage) serve() { mr := mp.r.Group("...
package lock import ( "github.com/garyburd/redigo/redis" "math/rand" "runtime" "sync" "testing" "time" ) var locker *Locker func newPool() *redis.Pool { return &redis.Pool{ MaxIdle: 3000, IdleTimeout: 240 * time.Second, Dial: func() (redis.Conn, error) { c, err := redis.Dial("tcp", "127.0.0.1:637...
package main import ( "fmt" ) func main() { type composer struct { name string birthYear int } antonio := composer { "antonio", 1707} // value agnes := new(composer) // pointer agnes.name = "agnes" agnes.birthYear = 1845 julia := &composer{} // pointer julia.name, julia.birthYea...
package webtable import ( "strings" "time" ) type Class struct { Package string ClassName string Alias string Table string EnableInsert bool EnadbleFind bool EnadbleUpdate bool EnadbleSort bool EnadbleDelete bool ...
// Package logx is a logging package inspired by Sirupsen/logrus and // uber-common/zap that follows these guidelines: // https://dave.cheney.net/2015/11/05/lets-talk-about-logging package logx import ( "fmt" "io" "os" "runtime" "strings" "time" ) // Field is a key/value pair associated to a log. type Field str...
package main import ( "fmt" "net" ) func main() { fmt.Println("Hello world!!") listener, err := net.Listen("tcp4", "8002") if err != nil { fmt.Println("启动服务器失败:" + err.Error()) return } fmt.Println("启动服务器成功 端口:" + "8002") for { conn, err := listener.Accept() if err != nil { fmt.Println("accept 失...
package main import ( "github.com/hashicorp/terraform/helper/schema" ) // Provider allows making changes to Windows DNS server // Utilises Powershell to connect to domain controller func Provider() *schema.Provider { return &schema.Provider{ Schema: map[string]*schema.Schema{ "server": { Type: schem...
package main import ( "bufio" "bytes" "context" "fmt" "log" "regexp" "strings" _ "embed" "cloud.google.com/go/spanner" database "cloud.google.com/go/spanner/admin/database/apiv1" instance "cloud.google.com/go/spanner/admin/instance/apiv1" adminpb "google.golang.org/genproto/googleapis/spanner/admin/datab...
package main import ( "bufio" "crypto/rand" "crypto/rsa" "encoding/json" "fmt" "net/rpc" "os" "strings" data "github.com/teknus/lojaRPC/dataStructs" ) func readShell(toControl chan<- string) { reader := bufio.NewReader(os.Stdin) fmt.Println("Shell") for { text, _ := reader.ReadString('\n') text = str...
package middleware import ( "fmt" "github.com/gin-gonic/gin" "jxc/auth" "jxc/models" "jxc/serializer" "jxc/service" "jxc/util" "net/http" "strings" "time" ) // 权限判断流程 // headers 中 Access-Token 为空,只能访问登录接口 // 不为空则进行解析 // 解析出错则踢出 // 当前域名是否为该公司所有,否则域名错误踢出 // 查询数据库,获取当前用户的所有权限路由 // 判断当前路由是否有权限 // 其他函数里获取com_id,...
package cdp import ( "fmt" "github.com/go-rod/rod/lib/utils" ) func (req Request) String() string { return fmt.Sprintf( "=> #%d %s %s %s", req.ID, fSessionID(req.SessionID), req.Method, dump(req.Params), ) } func (res Response) String() string { if res.Error != nil { return fmt.Sprintf( "<= #%d ...
// Package templates contains methods for the plaintext presentation of Game // state. package templates import ( "fmt" "strings" "t32/game" ) type Templates struct { waitingForOthers string stalemate string message string prompt string divider string // Hungarian "fmt" prefix for strings which ne...
// Copyright © 2020. All rights reserved. // Author: Ilya Stroy. // Contacts: qioalice@gmail.com, https://github.com/qioalice // License: https://opensource.org/licenses/MIT package ekatime import "fmt" type ( // Event represents some unusual days - events. // Like holidays, personal vacation days or work day off,...
package account const ( TransportHttp = "http" TransportHttps = "https" TransportGrpc = "grpc" TransportGateway = "gateway" )
package metrics_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" metrics "github.com/rite2nikhil/kubernetes-node-scaler/pkg/metrics" "k8s.io/api/core/v1" ) type FakeKubeClient struct{} func (f *FakeKubeClient) ListNodes() (objs []*v1.Node, err error) { objs := make([]*v1.Node) return objs, ...
package validation import ( "net" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/fielderrors" sdnapi "github.com/openshift/origin/pkg/sdn/api" ) // ValidateClusterNetwork tests if required fields in the ClusterNetwork are set. func ValidateClusterNetwork(clusterNet *sdnapi.ClusterNetwork) fielderrors.Valida...
package els import ( "context" "os" "time" "log" elastic "github.com/olivere/elastic/v7" "github.com/spf13/viper" _ "github.com/spf13/viper/remote" ) var client *elastic.Client func init() { setClient() } func setClient() { v := viper.New() v.AddRemoteProvider("consul", "127.0.0.1:8500", "elasticsearch"...
// Copyright 2018 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
/** * Copyright (c) 2018-present, MultiVAC Foundation. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ package heartbeat import ( "bytes" "encoding/hex" "os" "sync" "time" "github.com/multivactech/MultiVAC/base/util" "github...
package cmd import ( "fmt" "github.com/fugue/fugue-client/client/users" "github.com/fugue/fugue-client/format" "github.com/fugue/fugue-client/models" "github.com/spf13/cobra" ) type listUsersOptions struct { Offset int64 MaxItems int64 OrderDirection string FetchAll bool Email ...
package models import ( "github.com/cworsnup13/golang-gin/helpers" "log" "fmt" ) const ( configPath = "/tmp/test.yaml" ) var globalGuestTypes *GuestTypes type GuestTypes struct { Types []GuestType `json:"guestTypes" yaml:"guestTypes"` } type GuestType struct { GuestType string `json:"guestType" yaml:"guestTy...
package models import "time" type Follow struct { Id int64 `orm:"auto"` Me *User `orm:"rel(fk)"` To *User `orm:"rel(fk)"` Created time.Time `orm:"auto_now_add;type(datetime)"` Updated time.Time `orm:"auto_now;type(datetime)"` }
/* The app should print out a scoring dashboard as text during a football match. Ex: Match between England and West Germany in the 80th minute in world cup final in 1966: "England 2 (Hurst 18' Peters 78') vs West Germany 1 (Haller 12')" */ package main import ( "bufio" "fmt" "github.com/jasosa/football_scoring_das...
package aursir4go import ( "errors" "time" "github.com/joernweissenborn/aursir4go/appkey" "github.com/joernweissenborn/aursir4go/messages" "github.com/joernweissenborn/aursir4go/util" "github.com/joernweissenborn/aursir4go/calltypes" ) //An ImportedAppKey represents an applications imports and is used to call an...
// // Copyright (c) SAS Institute 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 agre...
package middlewares import "github.com/gofiber/fiber/v2" func V0Middleware() fiber.Handler { return func(c *fiber.Ctx) error { c.Set("X-Api-Version", "experimental") return c.Next() } }
package util import ( "bytes" "crypto/aes" "crypto/cipher" "encoding/base64" ) func AESEncrypt(orig string, key string) string { origData := []byte(orig) k := []byte(key) block, _ := aes.NewCipher(k) blockSize := block.BlockSize() origData = pkcps7Padding(origData, blockSize) blockMode := cipher.NewCBCEncry...
package main import ( "bufio" "flag" "fmt" "io/ioutil" "os" "strings" config "github.com/me-box/GitHubReleaseTool/config" "github.com/me-box/GitHubReleaseTool/githubProvider" tu "github.com/me-box/GitHubReleaseTool/tutils" ) func main() { //Process options configPath := flag.String("config", "./config.js...
package cpu import "testing" func cmp(p *CPU, first byte, second byte) (*CPU) { p.A = first p.Memory.Write(second, 0) p.Cmp(0) return p } func cpx(p *CPU, first byte, second byte) (*CPU) { p.X = first p.Memory.Write(second, 0) p.Cpx(0) return p } func cpy(p *CPU, first byte, second...
/* Copyright © 2021 NAME HERE <EMAIL ADDRESS> 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 writi...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package crosdisks provides a series of tests to verify CrosDisks' // D-Bus API behavior. package crosdisks import ( "context" "reflect" "strings" "github.com/godbus/...
package main import ( "fmt" ) var Age int = 20 // Name := "Tom" // error: 等价于 var Name string // Name = "Jerry" func init() { Name = "Jimy" } func main() { fmt.Println("Age is ", Age) fmt.Println("Name is ", Name) }
package sendpulse import ( "fmt" "github.com/icrowley/fake" "github.com/stretchr/testify/assert" "gopkg.in/jarcoal/httpmock.v1" "net/http" "testing" ) func TestCampaigns_Cancel_BadJson(t *testing.T) { campaignID := 1 apiUid := fake.CharactersN(50) apiSecret := fake.CharactersN(50) url := fmt.Sprintf("%s/ca...
package main import ( "errors" "flag" "fmt" "os" "os/signal" "syscall" "github.com/Cloud-Foundations/Dominator/lib/flags/loadflags" "github.com/Cloud-Foundations/golib/pkg/crypto/certmanager" "github.com/Cloud-Foundations/golib/pkg/crypto/certmanager/storage/awssecretsmanager" "github.com/Cloud-Foundations/...
package main import "fmt" // map // var map1 map[keytype]valuetype // var map1 = make(map[keytype]valuetype) // map1 := make(map[keytype]valuetype) func main() { var mapLit map[string]int mapLit = map[string]int{"one": 1, "two": 2} var mapAssigned map[string]int mapAssigned = mapLit mapAssigned["two"] = 3 ...
package injection import ( "reflect" ) // Provider should be function returning one value, used for registering value providers with Injector RegisterProviders method. // See injector_test.go file for examples type Provider interface{} type singletonProvider struct { provider Provider } // NewSingletonProvider in...
/* * @lc app=leetcode.cn id=926 lang=golang * * [926] 将字符串翻转到单调递增 */ package leetcode // @lc code=start func minFlipsMonoIncr(s string) int { cnt0 := 0 for _, v := range s { if v == '0' { cnt0++ } } res := []int{cnt0} for _, v := range s { if v == '1' { cnt0++ } else { cnt0...
package indexer import ( "io" "github.com/sp0x/torrentd/indexer/search" "github.com/sp0x/torrentd/storage" "github.com/sp0x/torrentd/torznab" ) type Info interface { GetID() string GetTitle() string GetLanguage() string GetLink() string } type ResponseProxy struct { Reader io.ReadCloser Content...
package main import "fmt" func max(a int, b int) int { if a > b { return a } return b } func min(a, b int) int { if a < b { return a } return b } func swap(a int, b string) (string, int) { return b, a } func main() { fmt.Println(max(1, 2)) fmt.Println(min(1, 2)) var a, b = swap(100, "hello") fmt.P...
package main import ( "context" "encoding/json" "fmt" "sync" "cloud.google.com/go/pubsub" util "github.com/rytrose/dist-midi" "gitlab.com/gomidi/midi/mid" driver "gitlab.com/gomidi/rtmididrv" ) const helpKey = 'h' const allKey = 'a' func main() { // Get SoundMap soundMap := util.GetSoundMap() // Create...
/* 1. Write program that finds the smallest number in given list */ package main import "fmt" func main() { x := []int{ 48, 96, 86, 68, 57, 82, 63, 70, 37, 34, 83, 27, 19, 97, 9, 17, } minVal := x[0] for _, value := range x { if value < minVal { minVal = value } } fmt.Println(minVal) }
// Copyright (C) 2018 Satoshi Konno. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package log // SetStdoutDebugEnbled sets a trace stdout logger for debug. func SetStdoutDebugEnbled(flag bool) { if flag { SetSharedLogger(NewStdoutLogge...
package console import "github.com/spf13/cobra" type Serve interface { Command() *cobra.Command }
package main type p struct { x num }
package tracker import ( "github.com/I-Reven/Hexagonal/src/domain/entity" "github.com/gocql/gocql" ) type Track interface { Migrate() error Create(track *entity.Track) error GetById(id gocql.UUID) (*entity.Track, error) GetByTrackId(trackId gocql.UUID) (*entity.Track, error) Update(id gocql.UUID, message strin...
// Copyright 2017 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package firiclient import ( "bytes" "context" "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "strconv" "time" ) func NewAuthenticatedClient(base *url.URL, s *signer, publicClient *publicClient, doer Doer) *authClient { return &authClient{ publicClient: publicClient, baseurl: base, doer: ...
package cmd import ( "log" "github.com/spf13/cobra" "github.com/dan-v/dosxvpn/deploy" ) var name string var removeProfile bool var rmCmd = &cobra.Command{ Use: "rm", Short: "Remove dosxvpn VPN server", Args: func(cmd *cobra.Command, args []string) error { if name == "" { return errorMissingName } ...
package identity import ( "context" "github.com/pkg/errors" mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1" core_ca "github.com/kumahq/kuma/pkg/core/ca" core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh" core_manager "github.com/kumahq/kuma/pkg/core/resources/manager" "github.com/kumahq/kum...
package assigncookies import "sort" func findContentChildren(g []int, s []int) int { result := 0 sort.Ints(g) sort.Ints(s) index, c := 0, 0 for c < len(g) && index < len(s) { if s[index] >= g[c] { result++ c++ } index++ } return result }
package query import ( "context" "github.com/machinebox/graphql" ) // MediaSearchStruct handles data from either manga or anime searches type MediaSearchStruct struct { Media struct { SiteURL string `json:"siteUrl"` Status string `json:"status"` MeanScore int `json:"meanScore"` IsAdult bool `j...
package templates const reducers_template = ` //////////////// // Reducers // //////////////// {{ range .Reducers }} // Reducer: {{ .Name }} // {{ .Description }} func {{ lower .Name }}Reducer(msg {{ .Message }}Message) { fmt.Println("{{ lower .Name }}Reducer()") store := engine.store.{{ lower .Object }}.st...
// 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 even func findNumbers(nums []int) int { evens := 0 for _, num := range nums { digits := 0 for n := num; n > 0; n /= 10 { digits++ } if 0 == digits%2 { evens++ } } return evens } func findNumbers2(nums []int) int { evens := 0 for i := 0; i < len(nums); i++ { digits := 1 for n := nums[...
package requests import ( "encoding/json" "fmt" "io/ioutil" "net/url" "strings" "github.com/google/go-querystring/query" "github.com/atomicjolt/canvasapi" "github.com/atomicjolt/canvasapi/models" "github.com/atomicjolt/string_utils" ) // UpdateOutcome Modify an existing outcome. Fields not provided are lef...
// // February 2016, cisco // // Copyright (c) 2016 by cisco Systems, Inc. // All rights reserved. // // // Provide JSON codec, such as it is. More effort required here to // exploit common bit (Telemetry message) and provide better // implementations exporting metadata. Shipping MDT does not support // JSON yet, thoug...
package settings // Settings app settings type Settings struct { AppParams Params `json:"app"` PostgresMegafonDbParams PostgresMegafonDbParams `json:"postgresMegafondb"` PostgresHamsoyaDbParams PostgresHamsoyaDbParams `json:"postgresHamsoyadb"` LinkForCancelTransaction LinkForCancelT...
package routers import ( "github.com/astaxie/beego" "../controllers" ) func init() { beego.Router("/api/admin/map", &controllers.GmapController{}, "post:Post") beego.Router("/api/admin/map/list", &controllers.GmapController{}, "get:GetList") beego.Router("/api/admin/map/:id([0-9]+)", &controllers.GmapController{...
package providers import ( "fmt" "math/rand" "time" ) type Color struct { Red int Green int Blue int } func (c *Color) Desaturate(sat float64) { gray := float64(c.Red)*0.3086 + float64(c.Green)*0.6094 + float64(c.Blue)*0.0820 c.Red = int(float64(c.Red)*sat + gray*(1-sat)) c.Green = int(float64(c.Green)*...
package firebase import ( "cloud.google.com/go/firestore" "google.golang.org/api/iterator" "github.com/sp0x/torrentd/indexer/search" ) // GetLatest returns the latest `count` of records. func (f *FirestoreStorage) GetLatest(count int) []search.ResultItemBase { var output []search.ResultItemBase collection := f....
package app import ( "testing" "github.com/stretchr/testify/require" ) func TestInitEthClient(t *testing.T) { testCases := []struct { name string endpointStr string expErr bool }{ {"success", rpcEndpoint, false}, {"invalid endpoint", "127.0.0.1:4546", true}, {"empty endpoint", "", true}, ...
package main import ( "sync" ) type SafeBool struct { val bool m sync.Mutex } //Locks when getting the value and unlocks after func (i *SafeBool) Get() bool { i.m.Lock() defer i.m.Unlock() return i.val } //Locks when setting the value and unlocks after func (i *SafeBool) Set(val bool) { i.m.Lock() defer i...
// Copyright 2022 YuWenYu All rights reserved. // Use of this source code is governed by a MIT style // license that can be found in the LICENSE file. package utils import ( "fmt" "github.com/spf13/cast" "github.com/yuw-pot/pot/data" "io" "math/rand" "reflect" "strings" "time" ) type ( PoT struct { } ) ...
package main import ( "errors" "strings" "testing" ) func getMockMembersMap(numMembers int) (MembersMap, error) { alphabet := "abcdefghijklmnopqrstuvwxyz" if numMembers > len(alphabet) { return MembersMap{}, errors.New("Cannot mock more than 26 members") } members := MembersMap{} for i := 0; i < numMembers...
package kubernetes import ( "fmt" "strings" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" ) // Deployment the Deployment service that knows how to interact with k8s to manage them type Deployment interface { GetDeploymentPods(namespace, name string) (*c...
package intersection_of_two_arrays func intersection(nums1 []int, nums2 []int) []int { seen := make(map[int]int8) for _, v := range nums1 { seen[v] |= 1 } for _, v := range nums2 { seen[v] |= 2 } res := make([]int, 0) for v, cnt := range seen { if cnt == 3 { res = append(res, v) } } return res ...
package TwoSum func twoSum(nums []int, target int) []int { mem := make(map[int]int) // value to index for i, value := range nums { if index, ok := mem[target - value]; ok { return []int{i, index} } mem[nums[i]] = i } return []int{-1, -1} }
package printer import ( "fmt" "github.com/jaimelopez/chihuahua/executor" ) const ( checkSymbol string = "✅" crossSymbol string = "❌" betterSymbol string = "▲" worseSymbol string = "▼" equalSymbol string = "➔" ) // Print comparision against standard output func Print(comparisions []executor.Comparision) ...
package main /* Note: In Order to use reflect package, the Methods of Struct MUST be exportable i.e. should start with capital letter (e.g. Addln). else, program will run but return nothing because methods will deemed to be local and not visible externally. */ import ( "fmt" "reflect" ) type Person struct { ...
package services import ( "fmt" "github.com/apulis/AIArtsBackend/configs" "github.com/apulis/AIArtsBackend/models" "math/rand" "net/url" "strings" "time" ) func init() { rand.Seed(time.Now().UnixNano()) } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n...
package boshdirector_test import ( "github.com/cloudfoundry/bosh-cli/v7/director" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/pivotal-cf/on-demand-service-broker/boshdirector" "github.com/pkg/errors" ) var _ = Describe("Get Events", func() { It("gets the right events", func() { fakeDi...
package dumper import ( "database/sql" "fmt" "io" "log" ) // ExtendedInsertDefaultRowCount: Default rows that will be dumped by each INSERT statement const ( // OperationIgnore is used to skip a table when dumping. OperationIgnore = "ignore" // OperationNoData is used when you want to dump a table structure wi...
// Copyright 2018 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package crypto import ( "crypto/rand" "encoding/base64" ) /** Functions GenerateRandomBytes and GenerateRandomString are copied from https://blog.questionable.services/article/generating-secure-random-numbers-crypto-rand/ for the moment. Other reading: - https://flaviocopes.com/go-random/ - https://www.reddit.com/...
// Copyright 2018 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
// SPDX-FileCopyrightText: 2021 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause package protocol // SemanticTokenTypes represents a type of semantic token. // // @since 3.16.0. type SemanticTokenTypes string // list of SemanticTokenTypes. const ( SemanticTokenNamespace SemanticTokenTypes = "...
package main import ( "github.com/olekukonko/tablewriter" "os" "strconv" "strings" ) func listBuilds(org string, branch string, workflowId int) error { fork := org cacheKey := "runs-" + org + "-" apiUrl := "https://api.github.com/repos/" + fork + "/hadoop-ozone/actions/" if workflowId > 0 { cacheKey += "-...
package config func GetJWTSecret() []byte { return []byte("Super secret key") }
package stack // Stack the structure of custom stack type Stack struct { list []interface{} } // NewStack return the object of stack func NewStack() *Stack { return &Stack{ list: make([]interface{}, 0), } } // Push push the value to stack top func (s *Stack) Push(v interface{}) { s.list = append(s.list, v) } ...
package models import ( "github.com/jinzhu/gorm" ) // galleryGorm represents our database interaction layer // and implements the UserDB interface fully. type galleryGorm struct { db *gorm.DB } var _ GalleryDB = &galleryGorm{} type GalleryDB interface { GetOneById(id uint) (*Gallery, error) GetAllByUserId(userI...
package oidcserver import ( "context" "fmt" "net/http" "net/http/httptest" "net/url" "strings" "testing" "github.com/google/go-cmp/cmp" storagepb "github.com/pardot/deci/proto/deci/storage/v1beta1" jose "gopkg.in/square/go-jose.v2" ) func TestParseAuthorizationRequest(t *testing.T) { tests := []struct { ...
/* Copyright 2022 Gravitational, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, soft...
package models import ( "github.com/jinzhu/gorm" ) var db *gorm.DB //InitaliseModels initalisaties the database with all models, this creates the tables if they do not exist. //It also sets the package global 'db' variable, otherwise a pointer deference error will occur func InitaliseModels(Inputdb *gorm.DB) { db...
package models import "time" type CertifiedMessage struct { Facility struct { Address struct { AddressLine1 string `json:"addressLine1"` District string `json:"district"` State string `json:"state"` } `json:"address"` Name string `json:"name"` } `json:"facility"` PreEnrollmentCode string ...
package structs import ( "fmt" "log" "sync" "time" ) // TempStats is used for stats saved in the past 30 hours type TempStats struct { Timeslice time.Time RedirectID uint Revenue float64 Count uint EngagementCount uint LoadCount uint UrlID uint } type TempStats...
// Copyright 2021 Red Hat, Inc. and/or its affiliates // // 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 applic...
package main import ( "crypto/rsa" "crypto/x509" "encoding/pem" "fmt" "io/ioutil" "net" "github.com/kelseyhightower/envconfig" "github.com/parnurzeal/gorequest" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) type ConfigOptions struct { ServerAddress string `envconfig:"server_address"` PrivateKey ...