text
stringlengths
11
4.05M
package main import ( "testing" "github.com/stretchr/testify/assert" ) func Test(t *testing.T) { t.Run("root", func(t *testing.T) { assert.NoError(t, argosay()) assert.Error(t, argosay("garbage")) }) t.Run("assert_contains", func(t *testing.T) { assert.NoError(t, argosay("echo", "foo", "/tmp/foo")) asse...
package install import ( "fmt" "testing" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestDeploymentStatusViewerStatus(t *testing.T) { tests := []struct { generation int64 status appsv1.DeploymentStatu...
package commands import ( "errors" "fmt" "strings" "code.cloudfoundry.org/garden" ) type List struct { Properties []string `short:"p" long:"properties" description:"filter by properties (name=value)"` Verbose bool `short:"v" long:"verbose" description:"print additional details about each container"` Se...
// Copyright 2020 Thomas.Hoehenleitner [at] seerose.net // Use of this source code is governed by a license that can be found in the LICENSE file. package id_test import "testing" func TestUpdateAllEqual(t *testing.T) { sOri := []string{` TRICE32_2( Id(100), "rd_: { (uint32_t*) 0x%08x, 0x%08xu },\r\n", pAddres...
package database import ( "portal/model" ) var insertSql = "INSERT INTO portal_resource(`app_id`, `type`, `resource_id`) VALUES(?, ?, ?)" var menuSql = "SELECT" + " r1.id AS DetailId," + " r1.name," + " r1.parent," + " r3.app AS `group`," + " r2.type," + ...
// Copyright 2023 Google LLC. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applica...
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
package msg import ( "github.com/name5566/leaf/network/protobuf" ) var Processor = protobuf.NewProcessor() // protobuf func init() { Processor.Register(&Number{}) // Processor.Register(&Number{}) // Json 协议 // var Processor = json.NewProcessor() // json } // Number 一个结构体定义了一个 JSON 消息的格式,消息名为 Number...
// NOTE: Generated By hrp v4.3.4, DO NOT EDIT! package main import ( "github.com/httprunner/funplugin/fungo" ) func main() { fungo.Register("SumTwoInt", SumTwoInt) fungo.Register("SumInts", SumInts) fungo.Register("Sum", Sum) fungo.Register("SetupHookExample", SetupHookExample) fungo.Register("TeardownHookExamp...
package routers import ( "github.com/astaxie/beego" "github.com/astaxie/beego/context/param" ) func init() { beego.GlobalControllerRouter["github.com/canghai908/zbxtable/controllers:AlarmController"] = append(beego.GlobalControllerRouter["github.com/canghai908/zbxtable/controllers:AlarmController"], be...
package data import "github.com/aren55555/shepherd-backend/models" type Store interface { GetForms() []*models.Form GetFormBy(string) *models.Form GetApplicationBy(string) *models.Application CreateApplicationFrom(string) (*models.Application, error) UpdateApplicationFormData(string, []byte) (*models.Applicatio...
package trello type Member struct { Id string `json:"id"` AvatarHash string `json:"avatarHash"` Bio string `json:"string"` BioData struct { Emoji struct { } `json:"emoji"` } `json:"bioData"` Confirmed bool `json:"confirmed"` FullName string `json:"fullName"` IdPremOrgsA...
package deployment import ( "github.com/cloudfoundry-incubator/candiedyaml" bosherr "github.com/cloudfoundry/bosh-agent/errors" boshsys "github.com/cloudfoundry/bosh-agent/system" ) type boshDeploymentParser struct { fs boshsys.FileSystem } func NewBoshDeploymentParser(fs boshsys.FileSystem) ManifestParser { r...
package problem0441 func arrangeCoins(n int) int { low := 1 high := n for low <= high{ mid := low + (high - low) / 2 value := (1+mid) * mid / 2 if value == n { return mid }else if value < n { low = mid + 1 }else{ high = mid - 1 } } return high }
package config import ( "fmt" "io/ioutil" "os" "gopkg.in/yaml.v2" ) const Dev = "development" const Test = "test" const Prod = "production" type AppConfig struct { DBUrl string `yaml:"database_url"` Salt string `yaml:"salt"` S3Bucket string `yaml:"bucket"` } func GetConfig() (*AppConfig, error) { en...
package main import ( "fmt" "github.com/gorilla/websocket" "math/rand" "os" ) var address = "ws://10.64.221.117" func main() { token := connectToPayserver() port := enterMatchmaker(token) outcome := enterGame(token, port) fmt.Println("Test concluded, game outcome: " + outcome) } func connectToPayserver() s...
/* * Copyright (c) 2019. Alexey Shtepa <as.shtepa@gmail.com> LICENSE MIT * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. */ package uuid import ( "testing" "github.com/satori/go.uuid" ) func BenchmarkGenerateBytesUUID(b *tes...
package main import "fmt" func main() { fmt.Println(exchange([]int{1, 2, 3, 4})) fmt.Println(exchange([]int{2, 16, 3, 5, 13, 1, 16, 1, 12, 18, 11, 8, 11, 11, 5, 1})) } func exchange(nums []int) []int { l1, l2 := 0, 1 // l1 管基数 l2 管偶数 for l1 < len(nums) && l2 < len(nums) { if nums[l2]%2 == 0 { l2++ } ...
package msgtypetype import ( "encoding/xml" "os" "time" ) type CDATAText struct { Text string `xml:",innerxml"` } //创建菜单微信返回json格式 type MenErrorResponse struct { ErrorCode string ErrMsg string } type msgBase struct { ToUserName string FromUserName string CreateTime time.Duration MsgType string...
package main import ( "fmt" ) const ( HELLO1 = "123" HELLO2 = HELLO1 HELLO4 = HELLO3 HELLO3 = "456" ) func main() { fmt.Println("hello world!", HELLO3, HELLO2) fmt.Println("IMY********", aa, -5/2) }
// Copyright 2016 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...
// go build -race // Sample program to show how to use a read/write mutex to define critical // sections of code that needs synchronous access. package main import ( "fmt" "math/rand" "runtime" "sync" "sync/atomic" "time" ) var ( // data is a slice that will be shared. data []string // wg is used to wait f...
package seev import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00200105 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:seev.002.001.05 Document"` Message *MeetingCancellationV05 `xml:"MtgCxl"` } func (d *Document00200105) AddMessage() *...
package remote import ( "context" "net/http" "strings" "time" "github.com/pterodactyl/wings/api" ) type Client interface { GetBackupRemoteUploadURLs(ctx context.Context, backup string, size int64) (api.BackupRemoteUploadResponse, error) GetInstallationScript(ctx context.Context, uuid string) (api.Installation...
package main import ( "fmt" "log" "net/http" "ocg-be/database" "ocg-be/routes" "github.com/gorilla/handlers" "github.com/gorilla/mux" ) func main() { database.Connect() r := mux.NewRouter() routes.Setup(r) handleCross := handlers.CORS( handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type...
package main import ( "log" mc "github.com/ikascrew/core/multicast" ) func main() { s, err := mc.NewServer( mc.ServerName("ikasbox"), mc.Type(mc.TypeIkasbox), ) if err != nil { log.Fatal(err) } err = s.Dial() if err != nil { log.Fatal(err) } }
package postgres import ( "context" "encoding/json" "fmt" "time" "gorm.io/datatypes" "github.com/odpf/optimus/store" "github.com/google/uuid" "github.com/odpf/optimus/models" "github.com/pkg/errors" "gorm.io/gorm" ) type Resource struct { ID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v...
package main import ( "fmt" "time" ) func fibonacci(mychan chan int) { n := cap(mychan) x, y := 1, 1 for i := 0; i < n; i++ { mychan <- x x, y = y, x+y } close(mychan) fmt.Println("end, close mychan") } func main() { pipline := make(chan int, 10) go fibonacci(pipline) // for k := range pipline { // f...
package main import ( "tetra/lib/gui" "tetra/lib/store" ) // Window wrap operating systems's window object. type Window struct { gui.Window // super } // OnCreate event handler func (w *Window) OnCreate() { w.Window.OnCreate() id := w.ObjID() if id != "" { if err := store.LoadState("state", id, w); err != ni...
// Copyright 2019-2023 The sakuracloud_exporter 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 appl...
package session import ( "crypto/x509" "fmt" "github.com/fasthttp/session/v2" "github.com/authelia/authelia/v4/internal/configuration/schema" "github.com/authelia/authelia/v4/internal/logging" ) // Provider contains a list of domain sessions. type Provider struct { sessions map[string]*Session } // NewProvid...
package method_interface import "fmt" func Do(i interface{}) { switch i.(type) { case int: fmt.Printf("int , value: %d\n", i) case string: fmt.Printf("string, value: %s\n", i) case byte: fmt.Printf("byte, value: %d", i) } }
package parse import ( "fmt" "time" ) const lessThanMin = "less than a minute" // PrettyDuration returns a human-readable duration that should fit the // phrase "X ago", e.g., "less than a minute ago", "2 minutes ago", etc. func PrettyDuration(d time.Duration) string { if d < time.Minute { return lessThanMin }...
package cmd import ( "fmt" "amru.in/cli/db" "github.com/spf13/cobra" ) // listCmd represents the list command var listCmd = &cobra.Command{ Use: "list", Short: "Lists all the to-do tasks", Run: func(cmd *cobra.Command, args []string) { // fmt.Println("list called") taskList, err := db.ListTaskItems() ...
package audit import ( "encoding/json" "reflect" "testing" pc_fields "github.com/square/p2/pkg/pc/fields" "github.com/square/p2/pkg/types" ) func TestRCRetargetingEventDetails(t *testing.T) { podID := types.PodID("some_pod_id") clusterName := pc_fields.ClusterName("some_cluster_name") az := pc_fields.Availab...
// Copyright 2021 PingCAP, Inc. Licensed under Apache-2.0. package utils import ( "os" "testing" "github.com/stretchr/testify/require" ) func TestProxyFields(t *testing.T) { revIndex := map[string]int{ "http_proxy": 0, "https_proxy": 1, "no_proxy": 2, } envs := [...]string{"http_proxy", "https_proxy...
package structs import ( "fmt" "reflect" ) // naming // just like variables first letter capital (Pascal) means it's exported for out package use // and first letter small (camelCase) means it's for in package scope // not just the struct name but also the the fields in the struct should be named the same way // c...
package mysql import ( "project/app/admin/models" orm "project/common/global" ) func migrateModel() error { err := orm.Eloquent.AutoMigrate(&models.SysUser{}) return err }
// Copyright (c) 2021 Alexey Khan // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, d...
package model /* type Student struct { Name string Age int } */ //当Student变成小写student的时候,没法向外调用(其他包没法调用),使用工厂模式来实现跨包创建结构体实例 type student struct { Name string age int } //提供一个函数对外获取到student对象 func NewStudent(name string, age int) *student { return &student{ Name: name, age: age, } } //如果age属性首字母小写,在其他包不能直...
package ring import ( "go.skia.org/infra/go/skerr" ) // StringRing stores the last N strings passed to Put(). It is not thread-safe. type StringRing struct { len int content []string } // NewStringRing returns a StringRing with the given capacity. func NewStringRing(capacity int) (*StringRing, error) { if ca...
package travis func hehe() int { return 1 }
package convexhull import ( "github.com/ivanterekh/qt-go-examples/internal/geometry" ) func SolveJarvis(points []geometry.Point) []geometry.Point { var res []geometry.Point left, right, top, down := getBounds(points) appendSector( &res, left, top, points, func(curr, next geometry.Point) float64 { ret...
package nationstatdb import( "stockdb" ns "entity/nsentity" //"util" "fmt" ) const( IndexInsert = "insert %s set id=?, parent=?, name=?, ename=?, unit=?, eunit=?, note=?, enote=?, readid=?" IndexDelete = "delete from %s where id=?" IndexUpdate = "update %s set parent=?, name=?, ename=?, un...
package config import "os" const ( apiGithubAccessToken = "SECRET_GITHUB_ACCESS_TOKEN" //apiGithubAccessToken = "f36172560521502ab348f31b06d1ea4b98435072" ) var ( githubAccessToken = os.Getenv(apiGithubAccessToken) ) func GetGithubAccessToken() string { //return githubAccessToken return "f36172560521502ab348f3...
package cmdopts import ( "fmt" "reflect" "strings" ) // Options represents map or struct (or pointer to struct as a sequence of long named perameters func Options(src interface{}) ([]string, error) { return generateOptions(src, src) } func generateOptions(orig interface{}, src interface{}) ([]string, error) { v...
package leetcode /*We are given an array A of N lowercase letter strings, all of the same length. Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices. For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final a...
package main import ( "flag" "fmt" "net/url" "os" "os/signal" "time" "github.com/gorilla/websocket" log "github.com/sirupsen/logrus" ) var ( addr = flag.String("addr", "localhost:8080", "http service address") deviceID = flag.String("id", "device0", "device id") ) type Device struct { ID string se...
package req /* ToUserName 开发者微信号 FromUserName 发送方帐号(一个OpenID) CreateTime 消息创建时间 (整型) MsgType 消息类型,文本为text Content 文本消息内容 MsgId 消息id,64位整型 */ type Text struct { ToUserName string `json:"to_user_name"` FromUserName string `json:"from_user_name"` CreateTime int64 `json:"create_time"` MsgType string `json:"m...
package createplayerusecase import ( "backend/internal/adapters/brokenrepo" "backend/internal/adapters/inmemoryrepo" "backend/internal/domain" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "testing" ) func Test_Create_player(t *testing.T) { // Arrange stubbedPlayerId := domain.New...
package router import ( "neosmemo/backend/handler" "neosmemo/backend/handler/memo" "neosmemo/backend/handler/user" "net/http" "github.com/julienschmidt/httprouter" ) // Router router var Router *httprouter.Router = nil // NOTE: 在这里注册路由 func init() { Router = httprouter.New() // user about Router.GET("/api/...
package config import ( "errors" "fmt" "io/ioutil" "log" "os" cfenv "github.com/cloudfoundry-community/go-cfenv" ) type WebConfig struct { commonConfig TopicID string } type WorkerConfig struct { commonConfig SubscriptionID string VisionURL string VisionAPIKey string } type commonConfig struct {...
package cmd import ( "testing" "github.com/stretchr/testify/assert" "github.com/instructure-bridge/muss/proc" ) func TestDcCommand(t *testing.T) { withTestPath(t, func(t *testing.T) { t.Run("all args pass through", func(t *testing.T) { _, _, err := runTestCommand(nil, []string{ "dc", "--no-ansi", ...
package pack import ( "encoding/json" "errors" "fmt" "io" "io/ioutil" "math/rand" "os" "path/filepath" "runtime" "strings" "time" "github.com/ryex/dungeondraft-gopackager/internal/structures" "github.com/ryex/dungeondraft-gopackager/internal/utils" "github.com/sirupsen/logrus" ) // Packer packs up a fo...
package mmap import ( "hash/fnv" "sync" ) var SEGMENT_NUM = 32 // 分段锁 type ConcurrentMap []*ConcurrentMapSegment type ConcurrentMapSegment struct { mu sync.RWMutex data map[string]interface{} } func NewConcurrentMap() ConcurrentMap { cmap := make(ConcurrentMap, 0) for i := 0; i < SEGMENT_NUM; i++ { cmap[...
package fuse // Compilation test for DummyFuse and DummyPathFuse import ( "testing" ) func TestDummy(t *testing.T) { fs := new(DefaultRawFuseFileSystem) NewMountState(fs) pathFs := new(DefaultPathFilesystem) NewPathFileSystemConnector(pathFs) } func TestDummyFile(t *testing.T) { d := new(DefaultRawFuseFile)...
package bitbucket_v2 import ( "errors" "github.com/DaoCloud/go-bitbucket/bitbucket" ) var ( ErrNilClient = errors.New("client is nil") ) // New creates an instance of the Bitbucket Client func New(consumerKey, consumerSecret, accessToken, tokenSecret string) *Client { c := &Client{} c.ConsumerKey = consumerKey...
package handler import ( "github.com/gin-gonic/gin" "github.com/go-playground/validator/v10" _ "github.com/koind/cacher/docs" "github.com/koind/cacher/internal/domain/repository" "github.com/koind/cacher/internal/domain/service" "github.com/pkg/errors" "github.com/swaggo/files" "github.com/swaggo/gin-swagger" ...
// Copyright (c) 2018 Palantir Technologies. 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 require...
package shp import ( "encoding/binary" "fmt" "io" "math" "strings" ) const magic int32 = 0x0000270a // Reader provides a interface for reading Shapefiles. Calls // to the Next method will iterate through the objects in the // Shapefile. After a call to Next the object will be available // through the Shape meth...
// Package goavanza provides a minimialist Avanza API wrapper. package goavanza import ( "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "strings" ) // Client holds session id and state for the wrapper type Client struct { Username string Password string httpClient ...
package dynamodb var machineTypeEntityKind = "MachineType" type machineTypeModel struct { DisplayName string `datastore:"name,noindex"` Features []string `datastore:"features,noindex"` Login string `datastore:"login"` Password string `datastore:"password,noindex"` }
package p9p import ( "net" "testing" ) func testConn(t *testing.T) (client, server *Conn) { t.Helper() fd, err := net.Listen("tcp", "localhost:0") if err != nil { t.Fatal(err) } wait := make(chan interface{}) go func() { bio, err := Accept(fd) if err != nil { wait <- err return } wait <- bio ...
package handlers import ( "net/http" "net/url" "github.com/google/uuid" "github.com/ory/fosite" "github.com/authelia/authelia/v4/internal/middlewares" "github.com/authelia/authelia/v4/internal/model" "github.com/authelia/authelia/v4/internal/oidc" "github.com/authelia/authelia/v4/internal/session" ) func ha...
package golang import ( "reflect" "testing" ) var tests = []struct { encoded []int first int output []int }{ { encoded: []int{1, 2, 3}, first: 1, output: []int{1, 0, 2, 1}, }, { encoded: []int{6, 2, 7, 3}, first: 4, output: []int{4, 2, 0, 7, 4}, }, } func TestDecode(t *testing.T) { for...
package metrics import ( "context" "testing" "go.opencensus.io/plugin/ocgrpc" "go.opencensus.io/stats/view" "google.golang.org/grpc" "google.golang.org/grpc/stats" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/wrapperspb" ) var statsHandler = &ocgrpc.ServerHandler{} type testInvoke...
package ssubnetting import ( "fmt" "os" "strconv" ) // Lee y transforma la configuración del subneteo desde la línea de comandos. // @return (ip, mask, host requirements, sort, flo, subtr, fok) func CaptureData() ([4]int, int, []int, string, bool, int, int, bool) { var ( ip [4]int hostsReq []int f...
// Package simple implements a Transformer that supports basic replacement based transformations package simple import ( "image/color" //nolint:misspell // I dont control others' package names "strings" "awesome-dragon.science/go/goGoGameBot/pkg/format/transformer/intermediate" "awesome-dragon.science/go/goGoGame...
/* Go Language Raspberry Pi Interface (c) Copyright David Thorpe 2016-2018 All Rights Reserved Documentation http://djthorpe.github.io/gopi/ For Licensing and Usage information, please see LICENSE.md */ // Interacts with the BME680 sensor package main import ( "os" // Frameworks "github.com/djthorp...
package petstore type Tag struct { Id int64 `json:"id,omitempty"` Name string `json:"name,omitempty"` }
package sail_perf import "testing" func TestInit(t *testing.T) { scores := New(10,10) if len(scores.samples) != 10 { t.Errorf("Length of samples is not 10.") } if cap(scores.samples) != 10 { t.Errorf("Capacity of samples is not 10.") } for _, item := range scores.samples { if item != nil { t.Er...
// Copyright 2023 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 login import ( "encoding/json" "fmt" "github.com/xeha-gmbh/homelab/proxmox/common" "github.com/xeha-gmbh/homelab/shared" "net/http" "net/url" ) // Arguments for the 'proxmox login' command type ProxmoxLoginRequest struct { shared.ExtraArgs Username string Password string Realm string ApiServe...
// Package mwgrs implements Image Region Metadata as defined by the // Metadata Working Group (MWG). The ExifTool docs contain a good // description of the schema: // // https://exiftool.org/TagNames/MWG.html#Regions package mwgrs import ( "fmt" "trimmer.io/go-xmp/xmp" ) var ( NsMwgRs = xmp.NewNamespace("mwg-rs",...
package main import ( "math/rand" "time" ) type IndividualConfig struct { GeneLength int FitnessCalc FitnessCalcBase } type Individual struct { genes []bool fitness int fitnessCalc FitnessCalcBase } func NewIndividual(c IndividualConfig) *Individual{ individual := Individual{ genes: make([]bool, c.GeneLeng...
package vm import ( "github.com/xeha-gmbh/homelab/shared" "github.com/spf13/cobra" "os" ) var ( output shared.MessagePrinter ) func NewProxmoxVMCommand() *cobra.Command { cmd := &cobra.Command{ Use: "vm", Short: "manage proxmox virtual machine", } cmd.AddCommand(NewProxmoxVMCreateCommand()) return cm...
package main import "os" func main() { a := App{} a.Initialize( os.Getenv("DEV_DB_USERNAME"), os.Getenv("DEV_DB_PASSWORD"), os.Getenv("DEV_DB_NAME")) a.Run(":8080") }
package main import ( "context" "errors" "fmt" "net/http" "os" "strings" "cloud.google.com/go/firestore" firebase "firebase.google.com/go" "github.com/bwmarrin/discordgo" "google.golang.org/api/option" ) const ( collection = "stream" docID = "stream-key" ) func dochieURL(url string) error { opt :=...
package db import ( "errors" "log" "os" "path/filepath" "runtime" "github.com/vmlellis/imersao/codepix-go/domain/model" "github.com/joho/godotenv" "gorm.io/driver/postgres" "gorm.io/driver/sqlite" "gorm.io/gorm" "gorm.io/gorm/logger" ) func init() { _, b, _, _ := runtime.Caller(0) basepath := filepath....
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
// Package greeting provides welcome package greeting // HelloWorld welcomes you to the world func HelloWorld() string { return "Hello, World!" }
package trello type Config struct { APIKey string Token string Board string UserID string Lists *Lists Labels *Labels Debug bool }
package parser import ( "io" "testing" "github.com/lalamove/konfig" "github.com/stretchr/testify/require" ) func TestParserFunc(t *testing.T) { var ran bool var f = Func(func(r io.Reader, s konfig.Values) error { ran = true return nil }) f.Parse(nil, nil) require.True(t, ran) } func TestNopParser(t *te...
package design_pattern_in_go import "testing" func TestNewUser(t *testing.T) { user, err := NewUser("1", "da", WithAge(20), WithEmail("100231")) if err != nil { t.Log(err) } t.Log(user) }
package models import ( _ "github.com/lib/pq" "database/sql" "encoding/json" "log" "fmt" ) type Datastore interface { AllPlayers() ([]*Player, error) } type DB struct { *sql.DB } func (db *DB) QueryD(qs string) (*sql.Rows, error) { return db.Query(qs) } func NewDB(dataSourceName string) (*DB, error) { db,...
package main import ( "fmt" "github.com/achakravarty/30daysofgo/day15" ) func main() { var count int fmt.Scanf("%d", &count) var num int fmt.Scanf("%d\n", &num) node := &day15.Node{} node = node.NewNode(num) for i := 1; i < count; i++ { fmt.Scanf("%d\n", &num) node.Insert(num) } fmt.Println(node.Displ...
package models import ( "github.com/astaxie/beego/orm" "time" ) // TableName 设置OctConf表名 func (a *OtcConf) TableName() string { return OtcConfTBName() } // OtcConfQueryParam 用于查询的类 type OtcConfQueryParam struct { BaseQueryParam Phone string `json:"phone"` //手机号 模糊查询 StartTime string `json:"startTime"` ...
package config type ServerConfig struct{ RpcListenEndPoint map[string]string RethinkDbEndPoint map[string]string RethinkDbName map[string]string AddressTrxDbPath map[string]string SupportCoinType map[string]string SourceDataHost map[string]string SourceDataPort map[string]string PosgresqlConfig map[string]i...
package conf import ( coreinformers "k8s.io/client-go/informers/core/v1" restclient "k8s.io/client-go/rest" clientSet "github.com/gxthrj/apisix-ingress-types/pkg/client/clientset/versioned" seven "github.com/gxthrj/seven/conf" "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/kubernetes" "k8s.io/client-go/in...
/* In many table-top games it is common to use different dice to simulate random events. A “d” or “D” is used to indicate a die with a specific number of faces, d4 indicating a four-sided die, for example. If several dice of the same type are to be rolled, this is indicated by a leading number specifying the number of...
package main import "fmt" func main() { // 支付比较, 只支持 == 或 != , 比较是不是每一个元素都一样 // 2个数组比较, 类型要一样 a := [5]int{1, 2, 3, 4, 5} b := [5]int{1, 2, 3, 4, 5} c := [5]int{1, 2, 3} fmt.Println("a == b ? ", a == b) // true fmt.Println("a == c ? ", a == c) // false var d [5]int d = a fmt.Println("d = ", d) // d = [1 2...
package service import ( "fmt" ovirtsdk "github.com/ovirt/go-ovirt" ) func diskAttachmentByVmAndDisk(connection *ovirtsdk.Connection, vmId string, diskId string) (*ovirtsdk.DiskAttachment, error) { vmService := connection.SystemService().VmsService().VmService(vmId) attachments, err := vmService.DiskAttachmentsS...
package usecases type ResultMap map[string]error // SweepAcceptedStories returns a map of the branches it attempted to delete and an error if that branch was unable to be deleted func SweepAcceptedStories(repo Repository, tracker Tracker) ResultMap { branchErrors := make(map[string]error) branchNames := repo.GetAl...
package log_parser import ( "bytes" ) type FullErrText struct { Text *bytes.Buffer complete bool } func (p *FullErrText) String() string { return p.Text.String() } func NewFullError() *FullErrText { return &FullErrText{bytes.NewBuffer([]byte{}), false} } func (fe *FullErrText) addNewLine() { fe.Text.Writ...
package model import ( "github.com/corbym/gogiven/generator" ) type testResults struct { ID string `json:"id"` Failed bool `json:"failed"` Skipped bool `json:"skipped"` TestOutput string `json:"test_output"` } //newTestResults is internal and creates a new json data object for marshalling tes...
package models import ( "context" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" ) func CheckExist(ctx context.Context, collection *mongo.Collection, key string, value interface{}) (bool, error) { findRes := collection.FindOne(ctx, bson.D{ { Key: key, Value: value, }, }) err...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/6/18 9:51 上午 # @File : lt_数字范围按位与.go # @Description : # @Attention : */ package v2 func rangeBitwiseAnd(left int, right int) int { // 按位与的关键: 全为1 的时候,才会为1 // 并且需要查看规律: 根据规律得出 ,最终会得到一个公共前缀 return 0 }
package santa import ( "github.com/maprost/application/example/max/profile" "github.com/maprost/application/generator/genmodel" ) func New() genmodel.JobPosition { return genmodel.JobPosition{ Title: "Santa Clause", ProfessionalSkills: []genmodel.SkillID{profile.TechSkillWrapping, profile.TechSkil...
package model import ( "Blog/util" "Blog/util/errmsg" "github.com/jinzhu/gorm" ) type Category struct { ID uint `json:"id,omitempty"` Name string `gorm:"type:varchar(20);not null" json:"name,omitempty"` } // 查询类别是否存在 func ExistsCategory(c *Category) errmsg.Code { var cate Category db.Select("id").Where("...
package glog import ( "fmt" "math/rand" "testing" "github.com/onsi/gomega" ) func TestSession(t *testing.T) { g := gomega.NewGomegaWithT(t) ClearBackends() backendName := "session" backend := NewListBackend("", Debug) SetBackend(backendName, backend) // Verify that the list is initially empty g.Expect(...