text
stringlengths
11
4.05M
package basic import ( "fmt" "io/ioutil" ) func bounded(v int) bool { if v > 100 { return true } else if v < 0 { return false } else { return true } } func Aa() { const filename = "README.md" contents, err := ioutil.ReadFile(filename) if err != nil { fmt.Println(err) } else { fmt.Printf("%s\n", c...
package model import ( "reflect" "testing" ) func mockUserTest() *User { return &User{ Id: 1, Username: "test", Email: "test", Password: []byte{}, PasswordHash: []byte{0x24, 0x32, 0x61, 0x24, 0x31, 0x30, 0x24, 0x72, 0x45, 0x73, 0x37, 0x75, 0x64, 0x69, 0x4b, 0x77, 0x4b, 0x65, 0x46, 0x69, 0x...
package api import ( "context" "net/http" jwtmiddleware "github.com/aiden0z/go-jwt-middleware" jwt "github.com/dgrijalva/jwt-go" "github.com/hirondelle-app/api/users" ) type contextUser string type AuthMiddleware struct { *jwtmiddleware.JWTMiddleware `inject:""` *users.Manager `inject:""` } fu...
package responseform // AddressResponse DTO for createAddress // // swagger:model type AddressResponse struct { Address1 string `json:"address1"` Address2 string `json:"address2,omitEmpty"` City string `json:"city"` State string `json:"state"` Zip string `json:"zip"` Country string `json:"country,om...
package main import ( "path/filepath" "strings" "sync" "text/template" "github.com/reconquest/hierr-go" ) var ( // because we can have specific formats for different file types defined // in config file, we need to cache templates to prevent overhead in // runtime compiledFormatsCache = struct { sync.Mute...
// Copyright 2019 Drone.IO Inc. All rights reserved. // Use of this source code is governed by the Blue Oak Model License // that can be found in the LICENSE file. package gc // Option configures a garbage collector option. type Option func(*collector) // WithImageWhitelist returns an option to set an image // white...
package utils import ( "github.com/gin-gonic/gin" "github.com/gin-contrib/sessions" ) func SetSession(c *gin.Context, k string, o interface{}) { session := sessions.Default(c) session.Set(k, o) session.Save() } func GetSession(c *gin.Context, k string) interface{} { session := sessions.Default(c) return sessi...
/* Written by mint.zhao.chiu@gmail.com. github.com: https://www.github.com/mintzhao 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...
// time: O(2n), space: O(n) func firstUniqChar(s string) int { memo := make(map[rune]int) for _, c := range s { memo[c]++ } for i, c := range s { if memo[c] == 1 { return i } } return -1 }
package model import ( "database/sql" "fmt" "strings" "time" "github.com/tal-tech/go-zero/core/stores/cache" "github.com/tal-tech/go-zero/core/stores/sqlc" "github.com/tal-tech/go-zero/core/stores/sqlx" "github.com/tal-tech/go-zero/core/stringx" "github.com/tal-tech/go-zero/tools/goctl/model/sql/builderx" ) ...
package analyzer import ( "fmt" "go/ast" "go/types" "reflect" "golang.org/x/tools/go/analysis" "golang.org/x/tools/go/analysis/passes/inspect" "golang.org/x/tools/go/ast/inspector" ) var MarshalPlan = &analysis.Analyzer{ Name: "marshalplan", Doc: "Checks that calls that take an interface{} are pass...
package waktu // Version current version. const Version = "v0.0.1-alpha.4"
package main import ( // "fmt" // "html" "log" "net/http" "time" ) func _indexHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(200) w.Write([]byte(`{"num":7}`)) // fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) } func main() { ht...
package cmd import ( "github.com/spf13/cobra" ) var rootCmd = &cobra.Command{ Use: "covid19-service", Short: "Covid19 Service is a service that provide data about Covid-19", Long: `A service that can be a portal for all information about Covid-19 from all over the world`, } func Execute() error { return r...
package main import ( "crypto/tls" "net/http" "os" "github.com/kovetskiy/godocs" "github.com/kovetskiy/lorg" "github.com/reconquest/hierr-go" ) const ( version = `manul 1.6` usage = version + ` manul is the tool for vendoring dependencies using git submodule technology. Usage: manul [options] -I [<de...
package hotel import "github.com/rbpermadi/bobobox/internal/repository" type AccessProvider struct { HotelRepo repository.IHotelRepo }
package main import ( "bufio" "fmt" "os" "strings" ) type calciatore struct { ovr int pos string nome string vel int tir int pas int dri int def int phy int } func main() { var database []calciatore var menu int scanner := bufio.NewScanner(os.Stdin) database = []calciatore{{88, "AT", "Depay"...
/* Copyright 2018 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, ...
// Copyright © 2018-2020 Wei Shen <shenwei356@gmail.com> // // 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, mo...
package tezos import ( "fmt" "strings" "testing" "os" ) const ( CUR_VER = "2.2.9" CUR_HASH = "b28c2364" ) var tledger *TezosLedger func TestMain(m *testing.M) { var err error // Get device tledger, err = Get() if err != nil { fmt.Printf("Cannot get Ledger device: %s\n", err) os.Exit(1) } defer tl...
package main import ( "encoding/json" "fmt" ) func main() { p := person{Name: "josiah", Age: 24} //ppv := reflect.ValueOf(&p) //ppv.Elem().Field(0).SetString("zhangsan") //ppv.Elem().Field(1).SetInt(34) //fmt.Print(p) jsonB, err := json.Marshal(p) if err == nil { fmt.Println(string(jsonB)) } respJSON :=...
package main import ( "bufio" "fmt" "io" "os/exec" "golang.org/x/text/encoding/simplifiedchinese" ) type Charset string const ( UTF8 = Charset("UTF-8") GB18030 = Charset("GB18030") ) // 工程属性 type VsProj struct { Atom bool Projname string Buildflag string Env1 string Env2 string } //...
package database import ( "github.com/gorilla/mux" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" "encoding/json" _ "log" "net/http" "strconv" "time" ) type DownloadsStore struct { db *gorm.DB } type DownloadsResource struct { Store *DownloadsStore Ctl *Control } type DownloadsI...
package products import ( "context" "encoding/json" "log" "net/http" "go.mongodb.org/mongo-driver/bson" ) // GetProducts : Method for get all products in the DB func GetProducts(w http.ResponseWriter, r *http.Request) { collection := DB.Collection("productos") var products []*Product cur, err := collectio...
package main import ( "log" "net/http" "github.com/gin-gonic/gin" "github.com/seaung/Go-Scaffolding/routers/v1" ) var router *gin.Engine func init() { router := gin.New() apiRouterGroup := router.Group("/api") v1.InitRouters(apiRouterGroup) } func main() { log.Fatal(http.ListenAndServe(":9000", router)) }
package week12 // 1248. 统计「优美子数组」 https://leetcode-cn.com/problems/count-number-of-nice-subarrays/ func numberOfSubarrays(nums []int, k int) (ans int) { accNums := make([]int, len(nums)+1) // 计数数组,统计和为index出现的次数 (index为数值,value为次数) count := make([]int, len(accNums)) count[0] = 1 // nums下标的取值范围是0~n-1 // accNums下标...
package service import ( "encoding/json" "fmt" "io/ioutil" "log" "os" "reflect" "strconv" "time" ) type Negativacoes struct { Data []*Data } type Data struct{ CompanyDocument string `json:"companyDocument"` CompanyName string `json:"companyName"` CustomerDocument string `json:"customerDocument"` Value...
package cryptoki import ( "crypto" "crypto/ecdsa" "crypto/rsa" "fmt" "hash/crc64" "github.com/miekg/pkcs11" ) // Supported algorithm strings. Compatible with CFSSL. const ( RSA = "rsa" ECDSA = "ecdsa" ) // A keyRequest is a request for generating a new key pair. type keyRequest interface { Algo() string ...
package main import ( "context" "flag" "github.com/getsentry/sentry-go" "github.com/gorilla/mux" "github.com/heptiolabs/healthcheck" "github.com/pkg/profile" "net/http" "os" "os/signal" "redis/internal/user" "redis/internal/user/cache" psql "redis/internal/user/db" "redis/pkg/logging" "redis/pkg/monitori...
package loop import "testing" func TestWhileLoop(t *testing.T) { n:=0 for n<5{ t.Log(n) n++ } }
package pg import ( "github.com/kyleconroy/sqlc/internal/sql/ast" ) type OnConflictExpr struct { Action OnConflictAction ArbiterElems *ast.List ArbiterWhere ast.Node Constraint Oid OnConflictSet *ast.List OnConflictWhere ast.Node ExclRelIndex int ExclRelTlist *ast.List } func (n ...
package main import ( "bytes" "encoding/binary" weak "math/rand" "testing" "time" "golang.org/x/crypto/md4" ) func init() { weak.Seed(time.Now().UnixNano()) } func TestPrefixedMD4(t *testing.T) { for i := 0; i < 10; i++ { h := md4.New() b1 := make([]byte, weak.Intn(1024)) weak.Read(b1) h.Write(b1) ...
package codec import ( "fmt" "github.com/ttacon/chalk" "github.com/popodidi/log" ) var ( styleMap = map[log.Level]chalk.Style{ log.Debug: chalk.ResetColor.NewStyle(), log.Info: chalk.Green.NewStyle().WithTextStyle(chalk.Bold), log.Notice: chalk.Cyan.NewStyle().WithTextStyle(chalk.Bold), log.War...
package operators import ( "context" "fmt" "time" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" . "github.com/onsi/ginkgo/v2" . "github.com/ons...
package main import ( "fmt" . "leetcode" ) func main() { fmt.Println(removeElements(NewListNode(1, 2, 3, 4), 4)) fmt.Println(removeElements(NewListNode(1, 2, 6, 3, 4, 5, 6), 6)) } /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func removeElements...
package functions import ( "math/rand" ) // Random returns a random element by your rand.Source, or zero func (ss SliceType) Random(source rand.Source) ElementType { n := len(ss) // Avoid the extra allocation. if n < 1 { return ElementZeroValue } if n < 2 { return ss[0] } rnd := rand.New(source) i := rn...
package greetings import ( "errors" "fmt" "math/rand" "time" ) func Hello(name string) (string, error) { if name == "" { return "", errors.New("please provide a name") } message := fmt.Sprintf(randomFormat(), name) return message, nil } func Hellos(names []string) (map[string]string, error) { messages :=...
package main import ( "fmt" "net" ) func main() { listerner, err := net.ListenUDP("udp", &net.UDPAddr{IP: net.ParseIP("127.0.0.1"), Port: 9999}) if err != nil { fmt.Println(err.Error()) return } fmt.Printf("Local: <%s> \n", listerner.LocalAddr().String()) data := make([]byte, 1024) for { n, remoteAddr, ...
// package service provide an API to expose bluetooth services package service
package domain const ( AreaErrorNameEmptyCode = iota AreaErrorNameNotEnoughCharacterCode AreaErrorNameExceedMaximunCharacterCode AreaErrorNameAlphanumericOnlyCode AreaErrorFarmNotFound AreaErrorReservoirNotFound AreaErrorSizeEmptyCode AreaErrorInvalidSizeUnitCode AreaErrorTypeEmptyCode AreaErrorInvalidArea...
package di import ( "reflect" ) // createStructProvider creates embed provider. func providerFromEmbedParameter(p parameter) *providerEmbed { var embedType reflect.Type if p.typ.Kind() == reflect.Ptr { embedType = p.typ.Elem() } else { embedType = p.typ } return &providerEmbed{ id: id{ Name: p.name, ...
package main import ( "flag" "os" "sync" "github.com/mayflower/docker-ls/cli/docker-ls/response" "github.com/mayflower/docker-ls/cli/util" "github.com/mayflower/docker-ls/lib" ) type tagsCmd struct { flags *flag.FlagSet repositoryName string cfg *Config } func (r *tagsCmd) execute(argv ...
/* The sum of the squares of the first ten natural numbers is, 1^2 + 2^2 + ... + 10^2 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)^2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385...
package fields import ( "encoding/json" "testing" . "github.com/anthonybishopric/gotcha" "github.com/square/p2/pkg/manifest" ) func TestJSONMarshal(t *testing.T) { mb := manifest.NewBuilder() mb.SetID("hello") m := mb.GetManifest() rc1 := RC{ ID: "hello", Manifest: m, ReplicasDesir...
package sudokuparser import ( "testing" ) func TestParseSudokuFromFile(t *testing.T) { const sample800wi = "7....3..2..4...1.9..52.9....2..15.7...........9.47..8....7.48..3.2...5..9..3....1" const sample800wiFile = "../samples/800wi.png" if sudokuString, _ := ParseSudokuFromFile(sample800wiFile); sudokuString !=...
package local import ( "fmt" "io/ioutil" "log" "path/filepath" "sort" "strings" "sync" "time" ) // NewGroup creates a new Group with the given parent and path func NewGroup(parent *Group, path string) (*Group, error) { g := &Group{Parent: parent, Path: path, PreTestPath: parent.PreTestPath, PostTestPath: par...
// 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...
/* We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through 5 pandigital. The product 7254 is unusual, as the identity, 39 × 186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital. Fin...
package auto import ( "fmt" "io" "net/http" "os" "os/exec" "path/filepath" "strings" "text/template" ) const ( flavorUbuntuBionic64NonLive = "ubuntu/bionic64" flavorUbuntuXenial64 = "ubuntu/xenial64" flavorBionic64 = "bionic64" flavorXenial64 = "xenial64" preseedScript ...
package db import ( "db/mongodb" "db/mysqldb" _ "pb" "server" "server/libs/log" "time" ) var ( App *DBApp ) type DBer interface { InitDB(db string, source string, threads int, entity string, role string, limit int, nameunique bool) error Close() KeepAlive() } type DBApp struct { *server.Server roleEntit...
package response_mode import ( "testing" ) func TestCompareSecurityLevel(t *testing.T) { defaultRM := Query // flow.AuthorizationCode if !CompareSecurityLevel(Query, defaultRM) { t.Error("CompareSecurityLevel should be ok") } if !CompareSecurityLevel(Fragment, defaultRM) { t.Error("CompareSecurityLevel shoul...
package leetcode /*The data structure TreeNode is used for binary tree, but it can also used to represent a single linked list (where left is null, and right is the next node in the list). Implement a method to convert a binary search tree (implemented with TreeNode) into a single linked list. The values should be kep...
package appdynamics import ( "github.com/HarryEMartland/terraform-provider-appdynamics/appdynamics/client" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "strconv" ) func resourcePolicy() *schema.Resource { return &schema.Resource{ Create: resourcePolicyCreate, Read: resourcePolicyRead, Update:...
package k8s import ( "context" "log" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/serializer/yaml" "k8s.io/client-go/discovery" "k8s.io/client-go/discovery/cached/memory" "k8s.io/client-...
package module import "buddin.us/eolian/dsp" func init() { Register("VariableRandomSeries", func(Config) (Patcher, error) { return newVariableRandomSeries() }) } type variableRandomSeries struct { multiOutIO clock, size, random, min, max *In idx int memory, gateMemory []dsp....
package main import "fmt" func main() { /* this is my first go language program. (It's not) */ fmt.Println("Hello, World!") }
package QuadraticEquation import ( "math" "strconv" "strings" ) const less0 = "There are no roots" func Calc(a, b, c float64) (D, x1, x2 float64, conclusion string) { // Discriminant D = b*b - 4*a*c switch { case D < 0: conclusion = less0 case D == 0: x1 = -b / 2 / a x2 = x1 conclusion = strings.Jo...
// Copyright 2018 Kuei-chun Chen. All rights reserved. package util import ( "encoding/json" "fmt" "io/ioutil" "math" "math/rand" "regexp" "strconv" "strings" "time" "github.com/simagix/gox" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" ) const metaEmail = "$email" cons...
package main import ( "context" "errors" "go.guoyk.net/nrpc/v2" "os" "os/signal" "sync/atomic" "syscall" ) type AddService struct { Count int64 } type AddIn struct { A int `json:"a" query:"a" default:"1"` B int `json:"b" query:"b" default:"1"` } type AddOut struct { V int `json:"v" query:"v"` } func (a ...
package import_tests_test import ( "fmt" "io/ioutil" "os" "testing" //"github.com/sirupsen/logrus" "github.com/golang/protobuf/proto" google_protobuf "github.com/golang/protobuf/protoc-gen-go/descriptor" plugin "github.com/golang/protobuf/protoc-gen-go/plugin" . "github.com/onsi/ginkgo" . "github.com/onsi/g...
package keva import ( "fmt" "io/ioutil" "os" "testing" ) func TestStore(t *testing.T) { newTempStoreWithPrefix := func(prefix string, t *testing.T) *Store { rootPath, err := ioutil.TempDir("", prefix) if err != nil { t.Fatalf("Could not create temporary location for store: %v", err) } store, err := ...
package main import ( "html/template" "log" "net/http" "os" ) var tmpl = template.Must(template.ParseFiles("websockets.html")) type TmplData struct { Port string Schema string } func serveHome(w http.ResponseWriter, r *http.Request) { tmplData := TmplData{ os.Getenv("TMPL_PORT"), "ws", } if os.Geten...
package crypto import ( "bytes" "errors" "math/big" ) const ( BitcoinBase58Chars = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" Base = 58 ) var ( ErrInvalidLengthBytes = errors.New("invalid length bytes") ErrInvalidChar = errors.New("invalid char") ) type Base58 struct { ...
package vaku // MaxConcurrency is the maximum number of threads/workers to use when calling Folder-based // functions that execute concurrently. The default value is 10, but a stable and well-tuned // Vault server should be able to handle up to 100 without issues. Use with caution and tune // specifically to your envi...
package storage import ( "bytes" "encoding/gob" "encoding/json" "fmt" "github.com/APTrust/exchange/models" "github.com/boltdb/bolt" "io" "strings" "time" ) const FILE_BUCKET = "files" const OBJ_BUCKET = "objects" // BoltDB represents a bolt database, which is a single-file key-value // store. Our validator ...
package charts import ( "github.com/go-echarts/go-echarts/v2/opts" "github.com/go-echarts/go-echarts/v2/render" "github.com/go-echarts/go-echarts/v2/types" ) // ThemeRiver represents a theme river chart. type ThemeRiver struct { BaseConfiguration BaseActions } // Type returns the chart type. func (*ThemeRiver) ...
package main func P2(param int) int { f1, f2 := 0, 1 f3 := f1 + f2 sum := 0 for f3 <= param { if f3%2 == 0 { sum += f3 } f1, f2, f3 = f2, f3, f2+f3 } return sum }
package main import "fmt" /** https://leetcode-cn.com/problems/liang-ge-lian-biao-de-di-yi-ge-gong-gong-jie-dian-lcof/ */ type myInt int type myI = int func main() { var a int = 2 var b myI = a var c myInt = myInt(a) fmt.Println(a,b,c) } type ListNode struct { Val int Next *ListNode } func GetIntersectio...
package db import ( "fmt" "github.com/jmoiron/sqlx" "github.com/reddaemon/calendargrpcsql/config" ) func GetDb(c *config.Config) (*sqlx.DB, error) { psqlInfo := fmt.Sprintf("host=%s port=%s user=%s "+ "password=%s dbname=%s sslmode=disable", c.Db.Host, c.Db.Port, c.Db.User, c.Db.Pass, c.Db.Name) return sqlx...
package PV import "DataApi.Go/lib/common" type PVPageIdSum struct { ID uint `gorm:"primary_key"` PageId string `gorm:"type:varchar(128);column:page_id;"` Pv int `gorm:"type:int(11);column:pv;"` PvValid int `gorm:"type:int(11);column:pv_valid;"` PvInvalid int `gorm:"type:int(11);column:pv_invalid;"` } fun...
package catm import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00200102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:catm.002.001.02 Document"` Message *ManagementPlanReplacementV02 `xml:"MgmtPlanRplcmnt"` } func (d *Document002...
package struct2elasticMapping type AnalyzerType string const ( AnalyzerStandard AnalyzerType = "standard" AnalyzerWhitespace = "whitespace" AnalyzerSimple = "simple" AnalyzerArabic = "arabic" AnalyzerArmenian = "armenian" AnalyzerBasque ...
/* *by wayyoung * 题目描述 写出一个程序,接受一个由字母和数字组成的字符串,和一个字符,然后输出输入字符串中含有该字符的个数。不区分大小写。 输入描述: 第一行输入一个有字母和数字以及空格组成的字符串,第二行输入一个字符。 输出描述: 输出输入字符串中含有该字符的个数。 示例1 输入: ABCDEF A 输出: 1 */ package main import ( "bufio" "fmt" "os" ) func main() { for { var ( s string b string err error ) /*由于字符串中存在空格,因此无...
package metric // func GetTcpTable() (tt *TcpTable, err error) { return }
package router import ( "github.com/gin-gonic/gin" "github.com/little-go/little-gin/router/api" "net/http" ) func InitRouter() *gin.Engine { r := gin.New() r.Use(gin.Logger()) r.Use(gin.Recovery()) r.StaticFS("/upload/images", http.Dir("upload/")) r.POST("/auth", api.GetAuth) return r }
package resources import ( "errors" "net/http" "github.com/manyminds/api2go" "gopkg.in/mgo.v2/bson" "themis/utils" "themis/models" "themis/database" ) // IterationResource for api2go routes. type IterationResource struct { IterationStorage database.IIterationStorage WorkItemStorage database.IWorkItemStorag...
package routers import ( "github.com/gin-gonic/gin" "net/http" ) func CORSMiddleware() gin.HandlerFunc { return func(c *gin.Context) { c.Writer.Header().Set("Access-Control-Allow-Origin", "*") c.Writer.Header().Set("Access-Control-Allow-Credentials", "true") c.Writer.Header().Set("Access-Control-Allow-Header...
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-08-03 11:36 * Description: *****************************************************************/ package netstream type StreamCmdType int8 const ( // 未...
package mt // A Dir represents a direction parallel to an axis. type Dir uint8 const ( East Dir = iota // +X Above // +Y North // +Z South // -Z Below // -Y West // -X NoDir ) //go:generate stringer -type Dir // Opposite returns the Dir's opposite. // ...
package main import ( "fmt" "sort" "jblee.net/adventofcode2018/utils" ) type turnDir byte const ( straightTurn turnDir = iota leftTurn turnDir = iota rightTurn turnDir = iota ) var leftTurns = map[byte]byte{ '^': '<', '>': '^', 'v': '>', '<': 'v', } var rightTurns = map[byte]byte{ '^': '>', '>'...
package main import ( "fmt" "net/http" "os/exec" "os" "hash/fnv" "strings" "io" "io/ioutil" "bytes" "time" ) type file struct { hash string content string la time.Time } var ( files map[string]file ) func main() { files = make(map[string]file) writeindices() go watchdelete() htt...
package util import ( "fmt" "github.com/astaxie/beego/logs" "github.com/hpcloud/tail" "time" ) type TailObj struct { Tail *tail.Tail Conf CollectConf } type TextMsg struct { Msg string Topic string } type TailObjMgr struct { Tails []*TailObj MsgChan chan *TextMsg } var ( tailObjMgr *TailObjMgr ) func Ini...
package main import ( "encoding/json" "fmt" "io/ioutil" "log" "net/http" "strings" ) // SearchData struct type SearchData struct { Search string `json:"search"` Sites []string `json:"sites"` } func searchWeb(pattern string, urls []string) []string { result := make([]string, 0, len(urls)) for _, url := r...
/* 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...
package disgo type ClientOptions struct { Intents []Intent } func (o ClientOptions) GetIntentInt() int { intentInt := 0 for _, i := range o.Intents { intentInt |= i.BitCode } return intentInt }
package main import ( "fmt" "flag" "log" "os" "strconv" "godb2struc/Shelnutt2/db2struct" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" ) //Program to reverse engineer your mysql database into gorm models func main() { packagename := "datamodels" user := flag.String("user", "username...
package test import ( "context" "errors" "github.com/skos-ninja/truelayer-tech/svc/pokemon/app" "github.com/skos-ninja/truelayer-tech/svc/pokemon/services/pokeapi" ) const ( Text = "translated description" ) var ( ErrInternal = errors.New("internal error") ) type testApp struct { internal, notFound bool } ...
// Package genesis provides generic functions for collections. package genesis // required for being discovered by pkg.go.dev import ( _ "github.com/life4/genesis/channels" _ "github.com/life4/genesis/lambdas" _ "github.com/life4/genesis/maps" _ "github.com/life4/genesis/slices" )
package model import ( "time" "github.com/google/uuid" ) type Goal struct { User string `json:"user"` ID uuid.UUID `json:"id"` Description string `json:"description"` Title string `json:"title"` Achieved bool `json:"achieved"` Created time.Time `json:"created"` Hab...
package criteria import ( "testing" ) func TestZeroMatch(t *testing.T) { c1 := Criteria{} c2 := Criteria{} if !c1.Match(c2) || !c2.Match(c1) { t.Fail() } } func TestIdentifyMatch(t *testing.T) { c1 := Criteria{ Set: BitDLType, DlType: 0x0800, } if !c1.Match(c1) { t.Fail() } } func TestLessThan...
// Package oci provides a light wrapper over the OCI native methdods. All methods check for errors and return an error object if necessary. // The returned structures provide type safety for the unsafe pointers required for native OCI calls. package native /* #include <oci.h> #include <stdlib.h> #include <string.h> ...
package controller import ( "net/http" "feeyashop/models" "github.com/gin-gonic/gin" "gorm.io/gorm" ) type likeInput struct { UserID uint `json:"user_id"` ProductID uint `json:"product_id"` } // GetAllLike godoc // @Summary Get all Like. // @Description Get a list of Like. // @Tags Like // @Produce json /...
package vugu // ModChecker interface is implemented by types that want to implement their own modification tracking. // The ModCheck method is passed a ModTracker (for use in checking child values for modification if needed), // and the prior data value stored corresponding to this value (will be nil on the first call...
package cmd_test import ( "encoding/json" "fmt" "path" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" boshlog "github.com/cloudfoundry/bosh-agent/logger" bmconfig "github.com/cloudfoundry/bosh-micro-cli/config" fakesys "github.com/cloudfoundry/bosh-agent/system/fakes" fakeuuid "github.com/cloudfoun...
package main import ( "fmt" "math" ) // https://leetcode-cn.com/problems/freedom-trail/ //------------------------------------------------------------------------------ func findRotateSteps(ring string, key string) int { N, M := len(ring), len(key) min := func(e ...int) int { ret := math.MaxInt32 for i := 0...
package Problem0210 func findOrder(numCourses int, prerequisites [][]int) []int { n, p := build(numCourses, prerequisites) return search(n, p) } func build(num int, requires [][]int) (next [][]int, pre []int) { // next[i][j] : i -> next[i]... ,i 是 next[i] 的先修课 next = make([][]int, num) // pres[i] : i 的先修课程的**个数*...
package game import ( "bufio" "fmt" "os" ) // EventHandler object // FIX:This struct is now useless, because the handler is not ignite. type EventHandler struct { eventChs map[string]chan bool isHandle bool } // NewEventHandler is constructor of EventHandler // @Param channels イベントハンドラ用チャネル // return EventHandl...
//go:generate reform package front //reform:cc_member_address type Address struct { ID uint `reform:"id,pk"` UserID uint `reform:"uid" json:"-"` Contact string `reform:"contactor"` Phone string `reform:"tel_num"` Province string `reform:"province"` City string `reform:"city"` District string...
package rest import ( "net/http" "todo-lists/pkg/common" "todo-lists/pkg/logger" "todo-lists/pkg/login" "github.com/gin-gonic/gin" ) type loginCtrl struct { log logger.LogInfoFormat svc login.Service } func NewLoginCtrl(log logger.LogInfoFormat, svc login.Service) *loginCtrl { return &loginCtrl{log, svc} }...
// Copyright 2016 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 ...