text
stringlengths
11
4.05M
package main import ( "github.com/kjx98/gobot" ) func main() { cfg := gobot.NewConfig("") rebot, err := gobot.NewWecat(cfg) if err != nil { panic(err) } rebot.SetRobotName("JacK") rebot.RegisterTimeCmd() rebot.Start() }
package handler import ( "k8s.io/klog/v2" "private-dns/endpoint" "private-dns/plan" ) // Handler interface contains the methods that are required type Handler interface { ApplyChanges(changes HashableDNSChanges) error ObjectCreated(obj interface{}) HashableDNSChanges ObjectDeleted(obj interface{}) HashableDNSC...
package handler import ( "echo/server" "fmt" "github.com/labstack/echo" _ "mysql-master" "net/http" ) type menu struct { Id_menu string Nama_menu string Deskripsi string Jenis string Harga string Url_gambar string Total_order string } var data []menu func BacaData(c echo.Context) 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 resolvers import ( "log" "github.com/graphql-go-example/conf" "github.com/graphql-go-example/model" ) //InsertComment - func InsertComment(comment *model.Comment) error { strsql := ` INSERT INTO comments(user_id, post_id, title, body) VALUES (?, ?, ?, ?)` res, err := conf.DB.Exec(strsql, comment.Us...
// Copyright 2021 BoCloud // // 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 wri...
package main import ( "flag" "log" "net/http" ) //go:generate /bin/sh -c "cd ./root-fs && gopherjs build --minify -v -o app.js" var ( addrFlag = flag.String("addr", ":5555", "server address:port") ) func main() { flag.Parse() http.Handle("/", http.FileServer(http.Dir("./root-fs"))) err := http.ListenAndServe...
package main import ( "fmt" ) func stringp(s string) *string { return &s } func main() { type person struct { FirstName string MiddleName *string LastName string } // s := "Perry" // p := person{ // FirstName: "Pat", // MiddleName: &s, // LastName: "Peterson", // } p := person{ FirstNam...
package controller var DEMO bool const DEMO_TRANSACTIONS = ` [ { "Status":"Confirmed", "Date":"08 Jun 17 19:45 +0000", "Amount":"37.80251 C", "Type":"Transaction", "Total":"37.80251 C", "ID":"" }, { "Status":"Confirmed", "Date":"08 Jun 17 22:34 ...
package Problem0258 func addDigits(n int) int { return (n-1)%9 + 1 }
package server import ( "fmt" "time" ) type QProc struct { name string req chan int } func (q *QProc) Start(Qname string) int { c := make(chan int) quit := make(chan int) go run(c, quit) q.req = c fmt.Print("here") for i := 0; i < 4; i++ { c <- 1 fmt.Println("inLoop") time.Sleep(1 * time.Second...
package logs import ( "fmt" "github.com/kalifun/gin-template/config" "github.com/kalifun/gin-template/global" "github.com/kalifun/gin-template/utils" rotates "github.com/lestrrat-go/file-rotatelogs" oplog "github.com/op/go-logging" "io" "os" "strings" "time" ) const ( logDir = "logs" logSoftLink = "l...
// 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...
/* Copyright 2015 The Kubernetes Authors All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or ag...
package cmd import ( "fmt" "io/ioutil" "log" "os" "github.com/spf13/cobra" ) func RootCmd() *cobra.Command { cmds := &cobra.Command{ Use: "suich", Short: "Root command for switch context in k8s config", Long: "", PreRun: func(cmd *cobra.Command, args []string) { ok, err := cmd.Flags().GetBool("d...
// An example package using Go-as-if-it-had-parametric-polymorphism, // with an "iter" package in the standard library, following an // already idiomatic Go iteration pattern. // // The feature is entirely imaginary, but I've tried to write // the code to fit as much within Go's existing idioms as possible. // // Gener...
// This deals with calls coming from Second Life or OpenSimulator. // it's essentially a RESTful thingy package main import ( "crypto/md5" "database/sql" "encoding/hex" "fmt" // "github.com/cznic/ql" "net/http" // "strconv" "strings" ) // GetMD5Hash takes a string which is to be encoded using MD5 and returns a ...
package checklist import ( "errors" "fmt" "os" "strings" "github.com/PuerkitoBio/goquery" "net/http" "image" _ "image/jpeg" _ "image/png" "strconv" ) const ( httpProto = "http://" httpsProto = "https://" propPairSeparator = "=" themeName = "white" embedWidth = "500" ) //...
package types // guardian module event types const ( EventTypeSetFeed = "set_feed" AttributeValueCategory = ModuleName AttributeKeyFeedName = "feed_name" AttributeKeyFeedValue = "feed_value" )
package main import ( "fmt" "io/ioutil" ) func main() { // Create FILE and write some data to this file // f, err := os.Create("output.txt") // if err != nil { // panic("unable to create file") // } // defer f.Close() // cnt, err := f.WriteString("Hello, World!") // if err != nil { // panic("unable to wr...
package chartrepotest import ( "net/http/httptest" "os" "testing" ) // Metadata in Chart.yaml files type Metadata struct { AppVersion string `json:"appVersion"` Name string `json:"name"` Version string `json:"version"` } // ChartVersion type type ChartVersion struct { Name string `json:"name"` ...
package models import ( "bytes" "database/sql" "errors" "fmt" "io/ioutil" "net/http" "os" "path/filepath" "strings" "time" "unicode" "git.hoogi.eu/snafu/go-blog/httperror" "git.hoogi.eu/snafu/go-blog/logger" "git.hoogi.eu/snafu/go-blog/settings" ) // File represents a file type File struct { ID ...
package main import ( "fmt" "math/rand" ) func main() { fmt.Println("my favorite number is ", rand.Intn(10)) // rend.Intn 每次返回同一个数字 } /* 包 每个 Go 程序都由包组成, 程序运行的入口是包 main 上面程序使用并导入包 "fmt" 和 "math/rand" 包名应该与导入路径的最后一个目录一致。例如, "math/rand" 包由 package rand 开始 */
package main import ( "fmt" "math" ) func main() { fmt.Println(maxProfit([]int{7, 1, 5, 3, 6, 4})) } func maxProfit2(prices []int) int { max := func(a, b int) int { if a > b { return a } return b } ans := math.MinInt dp := make([]int, len(prices)) for i := 0; i < len(prices); i++ { for j := i + ...
package main import "fmt" func main() { fmt.Println("Hello") x := []int{2, 2, 1} y := []int{4, 1, 2, 1, 2} fmt.Println(singleNumber1(x)) fmt.Println(singleNumber1(y)) } func singleNumber1(nums []int) int { for i := 1; i < len(nums); i++ { nums[0] ^= nums[i] } return nums[0] }
package database import ( "fmt" "os" mgo "gopkg.in/mgo.v2" ) var db *mgo.Database func init() { host := os.Getenv("MONGO_HOST") dbName := os.Getenv("MONGO_DB_NAME") session, err := mgo.Dial(host) if err != nil { fmt.Println("session err:", err) os.Exit(2) } db = session.DB(dbName) } func GetMongoDB() ...
package main import "fmt" func main() { var a []int // a[0] = 10 //error fmt.Println(a) }
package github import "time" const Url = "https://api.github.com/repos/dah8ra/golangtraining/issues" const IssueUrl = "https://api.github.com/repos/dah8ra/golangtraining/issues/" const BaseUrl = "https://api.github.com/" type Missing struct { Message string Errors *Errors } type Errors struct { Resource strin...
package model import ( "os" "strings" "testing" ) func setupDB() { os.Remove("tmp.db") InitDB("tmp.db") } func cleanDB() { CloseDB() os.Remove("tmp.db") } func setupUser() User { return User{ Name: "Example User", Email: "user@example.com", Password: "foobar"...
package models import ( "encoding/json" ) type Image struct { ID string `json:"ID"` Containers []Container `json:"Containers"` } func NewImages(data []byte) ([]Image, error) { var i []Image err := json.Unmarshal(data, &i) return i, err }
package datastoresql import ( "github.com/direktiv/direktiv/pkg/refactor/core" "github.com/direktiv/direktiv/pkg/refactor/datastore" "github.com/direktiv/direktiv/pkg/refactor/events" "github.com/direktiv/direktiv/pkg/refactor/logengine" "github.com/direktiv/direktiv/pkg/refactor/mirror" "gorm.io/gorm" ) type s...
package filters_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/bosh-prometheus/cf_exporter/filters" ) var _ = Describe("CollectorsFilter", func() { var ( err error filters []string collectorsFilter *CollectorsFilter cfAPIv3Enabled bool ) JustBeforeEach(func() ...
package networkd import ( "fmt" "os" "os/exec" "strings" "text/template" ) type networkDevice struct { Name string Destination string } const ( networkdPath = "/etc/systemd/network" bridgeHostFile = "80-container-bridge.netdev" networkHostFile = "82-container-bridge.network" netw...
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...
/* Pelichan is a disk-backed channel pipe Basic operation is to constantly pipe messages from Source to Sink channels. Whenever Sink blocks, all incoming messages start being stored on disk in a LevelDB database. When Sink cleanups both incoming and previously stored messages will be sent to Sink. Simplified operatio...
package errors import ( "fmt" ) func panicTop1() (err error) { defer func() { r := recover() rerr, ok := r.(error) if !ok { rerr = fmt.Errorf("panic: %v", r) } err = WithStack(rerr) }() return panicMiddle1() } func panicMiddle1() error { return panicBottom1() } func panicBottom1() error { panic("...
package logic import ( "testing" "fmt" ) func TestNewLogicLogDecorator(t *testing.T) { fmt.Println("Process with log.") handler := NewHandler() handler.WrapLog() //Run the process. handler.Operate1() }
package entity type StatisticPerYear struct { YearAndMon string `json:"year_and_month"` Profit int64 `json:"profit"` } type StatisticPerMon struct { Mon string `json:"mon"` Profit int64 `json:"profit"` } type StatisticPerMonRes struct { Year string `json:"year"` Detail []StatisticPerMon `...
// Copyright 2020 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
package llsr import ( "fmt" "strings" ) // Configuration for PostgreSQL connection. type DatabaseConfig struct { Database string User string Password string Host string Port int } // Creates new DatabaseConfiguration with given database name and User set to "postgres" func NewDatabaseConfig(databa...
package main import ( "encoding/binary" "fmt" "net" "os" "sync" "time" ) type numberOfVisitor struct { number int32 lock sync.Mutex } func (nV *numberOfVisitor) increment() int32 { nV.lock.Lock() value:=nV.number nV.number++ nV.lock.Unlock() return value } func (nV *numberOfVisitor) getVisitors() int32...
package frontservice import ( "context" calc "github.com/flexera/calc/front_service/gen/calc" addersvc "github.com/flexera/calc/back_service/gen/calc" adderclient "github.com/flexera/calc/front_service/services/adder" ) // calc service example implementation. // The example methods log the requests and return ze...
package main import ( "fmt" "time" ) /** * created: 2019/5/8 10:12 * By Will Fan */ func main() { ch := make(chan int) for i := 0; i <3; i++ { go func(idx int) { ch <- (idx + 1)*2 }(i) } fmt.Println(<-ch) close(ch) time.Sleep(2 * time.Second) }
//-----------------------------------------------Paquetes E Imports----------------------------------------------------- package Metodos import ( "../Variables" "bufio" "fmt" "github.com/gookit/color" "os" "strings" ) //------------------------------------...
package main import "fmt" func main() { var sum int var nums [5]int fmt.Println("Length:", len(nums), "Capacity:", cap(nums)) for i := 0; i < 5; i++ { var temp int fmt.Scan(&temp) nums[i] = temp sum += temp } fmt.Printf("Arr:%v Type:%T Len:%v\n", nums, nums, len(nums)) fmt.Println("Sum of all element...
/* The goal of this challenge is to determine the angle of a line in a image. Rules on the image: The image background will be white (#FFFFFF) The stroke of the line will be black (#000000) The line will NOT be anti-aliased The image will be 100x100 pixels The line will start at the center of the image The line will...
package service import ( "errors" "github.com/Tanibox/tania-core/src/assets/domain" "github.com/Tanibox/tania-core/src/assets/query" "github.com/Tanibox/tania-core/src/assets/storage" "github.com/gofrs/uuid" ) type AreaServiceInMemory struct { FarmReadQuery query.FarmReadQuery ReservoirReadQuery query.Re...
/* * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obta...
// +build unit package teampasswordmanager import ( "encoding/json" "net/http" "net/http/httptest" "testing" ) func TestCustomFields(t *testing.T) { cf1 := CustomField{ Label: "one", Data: "1", } cf2 := CustomField{ Label: "two", Data: "2", } // Create a Password struct password := Password{ C...
/* Copyright 2019 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, ...
package list import "errors" type ListNode struct { data interface{} next *ListNode } type SingleList struct { root *ListNode } func (l *SingleList) AddNode(value interface{}) { if nil == value { return } newNode := &ListNode{ data: value, } if nil == l.root { l.root = newNode return } tmpNode := ...
package user import ( . "cms/structs" "cms/database/mysql" log "github.com/sirupsen/logrus" ) func GetUserByName(username string) (user User) { user, err := mysql.FindUserByName(username) if err != nil { log.Error(err) } return }
package etcd import ( "time" etctClient "github.com/coreos/etcd/clientv3" "os" "github.com/astaxie/beego/logs" "context" "fmt" ) var ( client *etctClient.Client ) func InitEtcd(Endpoint []string) (err error) { client, err = etctClient.New(etctClient.Config{Endpoints: Endpoint, DialTimeout: 5 * time.Second}...
/* Copyright 2017 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, ...
package notion // Pagination allows an integration to request a part of the list, receiving an array of results and a next_cursor in the response. // The integration can use the next_cursor in another request to receive the next part of the list. type Pagination struct { NextCursor string `json:"next_cursor,omitempty...
// Copyright 2018 Kuei-chun Chen. All rights reserved. package util import ( "reflect" "testing" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" ) func TestCloneDoc(t *testing.T) { var edoc = bson.M{"name": "keyhole"} var doc = bson.M{"_id": primitive.NewObjectID(), "sub": edoc...
package main import ( "log" "os" "github.com/adrg/xdg" "github.com/tidwall/gjson" "github.com/tidwall/sjson" ) const ( SettingsPath = "MasterPlan/settings08.json" SettingsLegacyPath = "masterplan-settings08.json" SettingsTheme = "Theme" Settin...
package protocol import ( "io/ioutil" "net" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("InstructionIO", func() { var server, client net.Conn var io *InstructionIO BeforeEach(func() { server, client = net.Pipe() io = NewInstructionIO(client) }) AfterEach(func() { client.C...
package sqlite import _ "github.com/mattn/go-sqlite3" // Import the sqlite driver.
package uptimed import "sort" func GetStats() (stats *Stats, err error) { var records *Records var yesterday *Record stats = new(Stats) stats.Score, err = GetScore() if err != nil { return nil, err } records, err = GetRecords() if err != nil { return nil, err } sort.Sort(BySince(*records)) yesterda...
/* Create a for loop using this syntax for condition { } Have it print out the years you have been alive. */ package main import "fmt" func main() { for birthYear := 1992; birthYear <= 2021; birthYear++ { fmt.Println(birthYear) } }
package cache import ( "fmt" ) type FormatManager interface { Save(entries *[]DBCacheEntry, path string) error } // available formatters - lazy loaded formatters var availableFormatters = map[string]func() FormatManager{ "csv": GetSingletonCSVFormatter, "parquet": GetSingletonParquetFormatter, } func GetFor...
package main import "fmt" func main() { arrays := []int{1,232,545,12,56,12,10} input := 10 for i,num := range arrays { if num == input { fmt.Println("value : ",num) fmt.Println("Index",i) arrays = RemoveIndex(arrays, i) } } fmt.Println(arrays) } func RemoveIndex(s []int, index int) []int { retu...
package main import "fmt" func lessThanTen(i int) (response string, error string) { if i < 10 { response = "The number is less than 10" error = "" } else { response = "The number is too big" error = "ERROR: hit an error" } return response, error } func main() { result, err := lessThanTen(5) if er...
package iirepo import ( "os" ) // Init creates the (hidden) .ii/ repo directory, if it doesn't exist, under ‘rootpath’. func Init(rootpath string) error { repopath := Path(rootpath) if err := os.MkdirAll(repopath, os.ModePerm); nil != err { return err } return nil }
package chat import ( "github.com/sirupsen/logrus" "net/http" "simple_websocket/internal/handlers" ) //Конфигурация логгирования func (chat *Chat) configLogger() error { log_level, err := logrus.ParseLevel(chat.config.LoggerLevel) if err != nil { chat.logger.SetLevel(log_level) return nil } return err } /...
// 匿名字段也可以进行嵌套和继承 package main import "fmt" type A struct { name string Age int } type B struct { A int // 匿名字段~~ n int } func main() { var b B b.int = 20 // 如何使用匿名字段~~~ b.n = 15 // n是int类型的变量~~ 引用的话也得直接说明 fmt.Printf("匿名字段int=[%v]\nint变量n=[%v]", b.int, b.n) }
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //739. Daily Temperatures //Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have ...
package awssqs import ( "fmt" "time" ) // the maximum number of messages in a block var MAX_SQS_BLOCK_COUNT = uint(10) // the maximum size of a block var MAX_SQS_BLOCK_SIZE = uint(262144) // the maximum size of a message var MAX_SQS_MESSAGE_SIZE = MAX_SQS_BLOCK_SIZE // the maximum queue wait time (in seconds) va...
package openstack import ( "github.com/openshift/installer/pkg/terraform" "github.com/openshift/installer/pkg/terraform/providers" "github.com/openshift/installer/pkg/terraform/stages" ) // PlatformStages are the stages to run to provision the infrastructure in // OpenStack. var PlatformStages = []terraform.Stage{...
// Copyright 2015 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 controller import ( "encoding/json" "fmt" "net/http" "github.com/gorilla/mux" "github.com/nicobianchetti/Go-CleanArchitecture/cache" "github.com/nicobianchetti/Go-CleanArchitecture/model" "github.com/nicobianchetti/Go-CleanArchitecture/service" ) //IPermisoController interac with IPermisoService type ...
package main import ( "fmt" "log" "net" "os" "sort" "strings" "sync" // "time" ) func main() { if len(os.Args) < 2 { fmt.Println("You need to provide an IP or CIDR block.\n") } else { ipPtr := make(map[string]string) //ipPtr := make(map[ip]string) for _, cidr := range os.Args[1:] { fmt.Println("...
// echo loop package main import ( "bufio" "log" "os" "time" "./client" "./server" ) func main() { port := string(":8080") ch := make(chan string) go func() { if err := server.Listen(port); err != nil { log.Fatal("main:server:", err) } }() time.Sleep(time.Second) go func() { for { if err :...
/* Here is the (quite scary) Five little ducks song(it is not long): Five little ducks went out one day, over the hills and up away. Mother Duck said, "Quack Quack Quack Quack", but only four little ducks came back. Four little ducks went out one day, over the hills and up away. Mother Duck said, "Quack Quack Quack ...
package main import ( "fmt" "time" "github.com/aws-controllers-k8s/dev-tools/pkg/cache" ) func main() { c, err := cache.NewFSStore("test.txt", 3600*time.Second) fmt.Println(err) v, err := c.Get("a") fmt.Println("++", err == nil) fmt.Println(err, v.([]byte)) defer c.Save() }
package stack import "errors" var Underflow = errors.New("stack underflow"); type cell struct { next *cell value interface{} } type Stack struct { top *cell } func New() Stack { return Stack{nil} } func (s *Stack) Push(v interface{}) error { s.top = &cell{s.top, v} return nil } func (s *Stack) P...
package meda import ( "context" "database/sql" "github.com/jmoiron/sqlx" "github.com/pkg/errors" ) // ChunkIterator is a utility to iterate over fixed-size chunks of a table. // Each chunk consists of a number of rows whose IDs are in between two // values. ChunkIterator has no associated resources and does not ...
/* Copyright IBM Corporation 2020 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 di...
package main import ( "fmt" "strconv" "strings" ) func main() { for i := 1; i <= 20; i++ { values := []string{} d3 := i%3 == 0 d5 := i%5 == 0 if !d3 && !d5 { values = append(values, strconv.Itoa(i)) } else { if d3 { values = append(values, "Fizz") } if d5 { values = append(values, ...
/* * KSQL * * This is a swagger spec for ksqldb * * API version: 1.0.0 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) */ package swagger type Format string // List of format const ( JSON_Format Format = "JSON" AVRO_Format Format = "AVRO" PROTOBUF_Format Forma...
// Copyright Jetstack Ltd. See LICENSE for details. package cmd import ( "fmt" "path/filepath" "github.com/spf13/cobra" "github.com/jetstack/vault-helper/pkg/read" ) // initCmd represents the init command var readCmd = &cobra.Command{ Use: "read [vault path]", Short: "Read arbitrary vault path. If no output...
package operations import ( "encoding/csv" "errors" "math" "math/rand" "os" "strconv" "time" ) // Compare returns func Compare(bc1 []byte, bc2 []byte) (bool, int, int) { //comparable := true firstBigger := 0 secondBigger := 0 for i := 0; i < len(bc1); i++ { if bc1[i] < bc2[i] { secondBigger += int(bc2...
package api import ( "encoding/json" "github.com/gorilla/mux" "github.com/gorilla/schema" "github.com/sirsean/packhunter/model" "github.com/sirsean/packhunter/mongo" "github.com/sirsean/packhunter/ph" "github.com/sirsean/packhunter/rank" "github.com/sirsean/packhunter/service" "github.com/sirsean/packhunter/w...
package gokun import ( "crypto/tls" "errors" ) type Config struct { Server string Port uint Password string Nick string User string RealName string Channnels string SSL bool SSLConfig *tls.Config } func (cfg *Config) IsValid() error { if cfg.Server == "" { return errors.New("P...
package pathfileops import "testing" func TestPathValidityStatusCode_EqualOperator_01(t *testing.T) { status1 := PathValidStatus.Unknown() status2 := PathValidStatus.Unknown() result := false if status1==status2 { result = true } if !result { t.Error("Error: For status1=PathValidStatus.Unkno...
//Package vugufmt provides gofmt-like functionality for vugu files. package vugufmt
package port import ( "github.com/mirzaakhena/danarisan/domain/repository" "github.com/mirzaakhena/danarisan/domain/service" ) // BayarSetoranOutport ... type BayarSetoranOutport interface { repository.FindOneTagihanRepo repository.FindOnePesertaRepo repository.FindLastSaldoAkunRepo repository.SaveTagihanRepo ...
package main import ( "github.com/gin-gonic/gin" "github.com/rs/xid" "log" ) //跨域访问:cross origin resource share func CrosHandler() gin.HandlerFunc { return func(context *gin.Context) { context.Header("Access-Control-Allow-Origin", "*") // 设置允许访问所有域 context.Header("Access-Control-Allow-Methods", "PUT, POST, ...
package middleware import ( "github.com/dgrijalva/jwt-go" mdl "github.com/huf0813/pembukuan_tk/entity" "github.com/huf0813/pembukuan_tk/utils/delivery/customJSON" "github.com/joho/godotenv" "net/http" "os" "strings" "time" ) type TokenMiddleware struct { Res customJSON.JSONCustom } type TokenMiddlewareInter...
// Copyright 2015 Google Inc. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable...
package binance import ( "testing" "github.com/stretchr/testify/suite" ) type marginOrderServiceTestSuite struct { baseOrderTestSuite } func TestMarginOrderService(t *testing.T) { suite.Run(t, new(marginOrderServiceTestSuite)) } func (s *marginOrderServiceTestSuite) TestCreateOrder() { data := []byte(`{ "sy...
package main import "math" //Definition for a binary tree node. type TreeNode struct { Val int Left *TreeNode Right *TreeNode } var last = -math.MaxFloat64 func isValidBST(root *TreeNode) bool { if root == nil { return true } if isValidBST(root.Left) { if last < root.Val { last = root.Val return ...
use std::str::FromStr; use metalog::{set_logger, Log, LogLevelFilter, LogMetadata, LogRecord, MaxLogLevelFilter}; struct Logger { max_log_level: MaxLogLevelFilter } impl Log for Logger { fn enabled(&self, metadata: &LogMetadata) -> bool { metadata.level() <= self.max_log_level.get() } fn lo...
package aoc2015 import ( "testing" aoc "github.com/janreggie/aoc/internal" "github.com/stretchr/testify/assert" ) func TestDay17(t *testing.T) { assert := assert.New(t) testCases := []aoc.TestCase{ {Details: "Y2019D17 sample input", Input: day17myInput, Result1: "654", Result2: "57"}, } for _, tt...
package nsm import ( nsmv1alpha1 "github.com/acmenezes/nsm-operator/pkg/apis/nsm/v1alpha1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) func (r *ReconcileNSM) serviceForWebhook(nsm ...
package main import ( . "foo" ) func 界() { return } func main() { Bla(1) 界() }
package middleware import ( "context" "encoding/json" "net/http" "strconv" "github.com/lokichoggio/gateway/internal/types" "github.com/tal-tech/go-zero/core/metric" "github.com/tal-tech/go-zero/core/trace/tracespec" ) const ( SuccessCode = 0 ) // A WithBodyResponseWriter is a helper to delay sealing a http...
package model //User is a structure with user's data type User struct { Email string Password string EncryptedPassword string }
package drivers import ( "testing" "github.com/volatiletech/strmangle" ) type testMockDriver struct{} func (m testMockDriver) TranslateColumnType(c Column) Column { return c } func (m testMockDriver) UseLastInsertID() bool { return false } func (m testMockDriver) UseTopClause() bool ...