text
stringlengths
11
4.05M
/* 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 kitchen import ( "fmt" "github.com/ProfessorMc/Recipe/spoilers/appliance" ) type Kitchen struct { name string appliances []appliance.Appliance } func NewKitchen(name string, appliances ...appliance.Appliance) *Kitchen{ return &Kitchen{ name:name, appliances:appliances, } } func (k *Kitchen) PrintA...
package main import ( "bitbucket.org/cicadaDev/utils" "bytes" "encoding/json" log "github.com/Sirupsen/logrus" "net/smtp" "text/template" "time" ) type emailer struct { Server *emailServer Template smtpTemplate Auth smtp.Auth EmailDoc bytes.Buffer } type emailServer struct { Username string Passwo...
package main import ( "bytes" "encoding/base64" "fmt" "go-bca/server" "io/ioutil" "log" "os" "path/filepath" "runtime" "strings" "github.com/gomodule/redigo/redis" uuid "github.com/satori/go.uuid" flag "github.com/spf13/pflag" "github.com/spf13/viper" "golang.org/x/crypto/bcrypt" "golang.org/x/crypto/...
package models import "time" type Model struct { CreateTime *time.Time `orm:"column(create_time);type(datetime);auto_now_add;" json:"create_time"` UpdateTime *time.Time `orm:"column(update_time);type(datetime);auto_now;" json:"update_time"` DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null;" js...
//go:generate mockery --name=KeyValue package storage import "github.com/mateeullahmalik/goa-demo/internal/errors" var ( // ErrKeyValueNotFound is returned when key isn't found. ErrKeyValueNotFound = errors.New("key not found") ) // KeyValue represents database that uses a simple key-value method to store data. t...
package nut import ( "bytes" "encoding/gob" "github.com/kapmahc/axe/web" log "github.com/sirupsen/logrus" "github.com/spf13/viper" gomail "gopkg.in/gomail.v2" ) // Mount register func (p *UsersPlugin) Mount() error { htm := p.Router.Group("/users") htm.GET("/confirm/:token", p.Layout.Redirect("/", p.getConfi...
/* Copyright 2017 The Kubernetes Authors. Copyright 2018 Intel Coporation. SPDX-License-Identifier: Apache-2.0 */ package main import ( "context" "flag" "github.com/intel/oim/pkg/log" "github.com/intel/oim/pkg/oim-common" "github.com/intel/oim/pkg/oim-registry" ) var ( version = "unknown" // set at buil...
package main import ( "stfl" "strings" "fmt" "strconv" ) type View struct { f *stfl.Form quit bool lines uint linequeue chan LineMsg info ServerInfo } func CreateView(linequeue chan LineMsg, info ServerInfo) (v *View) { v = new(View) v.f = stfl.Create("<screen.stfl>") v.quit = false v.lines = 0 v.lineq...
package main import "fmt" func main() { var happy rune = 128515 var sad rune = 128546 var bang byte = 33 fmt.Println(happy, sad, bang) fmt.Println(string(happy), string(sad), string(bang)) fmt.Printf("%c %c %c\n", happy, sad, bang) }
package main import ( "sync" "gitgud.io/softashell/comfy-translator/translator" ) type Queue struct { items []queueObject lock *sync.Mutex } type queueObject struct { req translator.Request lock *sync.Mutex count int outChan chan string } func NewQueue() *Queue { q := new(Queue) q.lock = &sync.Mu...
package controllers func Register(c *fiber.Ctx) error {} func Login(c *fiber.Ctx) error {}
package model import ( "fmt" "github.com/jinzhu/gorm" "log" "proxy_download/common" "strings" ) type TestCase struct { BaseModel Name string `gorm:"column:name;not null" binding:"required" json:"name"` Url string `gorm:"column:url;not null" binding:"required" json:"url"`...
package client import ( "context" "errors" "net/http" "github.com/uid4oe/microservices-go-grpc/user/userpb" "google.golang.org/grpc" "google.golang.org/grpc/status" ) type User struct { Id string `json:"id"` Name string `json:"name"` Age int32 `json:"age"` Greeting string `json:"greeting"` ...
package graph import ( "fmt" "log" "math" "projja_exec/model" "sort" "time" ) const ( timeLowCoefficient float32 = 1.05 timeMediumCoefficient float32 = 1.15 timeHighCoefficient float32 = 1.25 timeCriticalCoefficient float32 = 1.35 skillsCoefficient float32 = 0.8 ) type Project struct { I...
package request //客户端服务器信息 type Stat struct { HostName string `json:"hostName"` //Host名称 IpAddr string `json:"ipAddr"` //ip地址 TimeStamp int64 `json:"timeStamp"` //同步时间 PlatformVersion string `json:"platformVersion"` //平台版本 CPUName string `json:"cpuName"` ...
package main import ( "fmt" "math" "testing" ) // TestSumOfFirstNIntegers() tests the SumOfFirstNIntegers function on several // different integer inputs. func TestSumOfFirstNIntegers(t *testing.T) { r := SumOfFirstNIntegers(100) t.Logf("SumOfFirstIntegers(100) = %d", r) if r != 5050 { t.Errorf("SumOfFirstNIn...
// 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...
// 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...
//nolint // this is test package options type Simple struct { //options:skip StringVal string IntVal int }
package prediction import ( "fmt" "math/big" "github.com/streamingfast/sparkle/entity" pbcodec "github.com/streamingfast/sparkle/pb/dfuse/ethereum/codec/v1" ) func (s *Subgraph) HandlePredictionEndRoundEvent(trace *pbcodec.TransactionTrace, ev *PredictionEndRoundEvent) error { if s.StepBelow(3) { // round.Loc...
package trello type Card struct { Id string `json:"id"` Badges struct { Votes int `json:"votes"` ViewingMemberVoted bool `json:"viewingMemberVoted"` Subscribed bool `json:"subscribed"` Fogbugz string `json:"fogbugz"` CheckItems int `json:"checkItems"` ...
package graphstore import ( "context" "time" "github.com/deps-cloud/api" "github.com/deps-cloud/api/v1alpha/store" "github.com/jmoiron/sqlx" "github.com/sirupsen/logrus" ) // NewSQLGraphStore constructs a new GraphStore with a sql driven backend. Current // queries support sqlite3 but should be able to work ...
package main import "fmt" func main() { greet("Max") greet("John") } func greet(name string) { fmt.Println(name) } /* greet is declared with a parameter when calling greet, pass in an argument */ // Max // John
// 自动生成模板SysDict package model import ( "github.com/jinzhu/gorm" ) type SysDict struct { gorm.Model ParentId int `json:"parentId" form:"parentId" ` PropertyName string `json:"text" form:"propertyName" ` PropertyValue int `json:"propertyValue" form:"propertyValue" ` SeqNumber int `json:"seqNum...
package test import "go.uber.org/zap" type S struct { logger *zap.Logger } func Main() { s := S{} s.FooBar() } func (s *S) FooBar() { s.logger.Warn("warning") }
package e2e_test import ( "flag" "path/filepath" "testing" "time" "github.com/appscode/go/log" logs "github.com/appscode/go/log/golog" api "github.com/kubedb/apimachinery/apis/kubedb/v1alpha1" cs "github.com/kubedb/apimachinery/client/clientset/versioned/typed/kubedb/v1alpha1" snapc "github.com/kubedb/apimac...
/* * @lc app=leetcode.cn id=113 lang=golang * * [113] 路径总和 II */ package main import "fmt" type TreeNode struct { Val int Left *TreeNode Right *TreeNode } // @lc code=start func pathSumHelper(root *TreeNode, targetSum int, ans [][]int, stack []int) [][]int { if root == nil { return ans } targetSum -= ...
package logging import ( "os" "github.com/square/p2/Godeps/_workspace/src/github.com/Sirupsen/logrus" ) type ProcessCounter struct { counter int } func (p *ProcessCounter) Fields() logrus.Fields { fields := logrus.Fields{ "Counter": p.counter, "PID": os.Getpid(), } p.counter++ return fields }
// Space Rocks Bot is a bot watching // asteroids coming too close to earth for the incoming days/week. package main // TODO: change twitter banner periodically import ( "flag" "fmt" "log" "path/filepath" "time" "github.com/dns-gh/betterlog" conf "github.com/dns-gh/flagsconfig" "github.com/dns-gh/twbot" ) /...
package handler import ( "context" "errors" "path/filepath" "testing" proto "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/user/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" ) // UserResetPasswordViaSecureQuestionTestSuite 通过密保问题重置密码测试 type UserResetPasswordViaSecureQ...
package routes import "github.com/gin-gonic/gin" func registerWeb(router *gin.Engine) { router.GET("/", func(c *gin.Context) { c.JSON(200, gin.H{ "message": "web home", }) }) }
package main import ( "iota/dtusimulator" "log" "net" "strconv" "sync" ) var ( maxConnNum = 10 address = "127.0.0.1:9012" ) type MyDtu struct { } func (md *MyDtu) OnReceive(ibuf []byte) (obuf []byte) { ilen := len(ibuf) if ilen > 0 { buf := make([]byte, ilen) buf[0] = 'a' re...
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0. package spans_test import ( "fmt" "testing" "github.com/pingcap/tidb/br/pkg/streamhelper/spans" "github.com/stretchr/testify/require" ) func s(a, b string) spans.Span { return spans.Span{ StartKey: []byte(a), EndKey: []byte(b), } } func kv(s sp...
// 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 main import "fmt" func main() { // Loop 5 times for i := 1; i<=5; i++ { fmt.Printf("Welcome %d times\n",i) } // Loop forever for { fmt.Println("I am in love with the Terminal (hit Ctrl+C to stop)") } }
package app import ( "time" "github.com/gin-gonic/gin" validation "github.com/go-ozzo/ozzo-validation" ) type PasswordReset struct { ID int UserID int Token string Status int CreatedAt time.Time UpdatedAt time.Time beforeJSON gin.H errors error } func (x PasswordReset) User() U...
package main type Segmentable interface { Split() (Segmentable, error) Merge(Segmentable) error ByteSize() uint32 } type Slab interface { Storable Segmentable } type SlabStorage interface { Store(Slab) Retrieve(StorageID) (Slab, bool, error) Remove(StorageID) } // think of it as ledger type BasicSlabStorage...
package test import ( "eaciit/sebard/modules" "testing" "time" "github.com/eaciit/toolkit" ) const ( host1 = "localhost:8888" host2 = "localhost:8889" host1config = "../config/node0.json" host2config = "../config/node1.json" host3config = "../config/node2.json" ) var ( s1, s2, s3 *modules.SebarNode ) fu...
package plant import ( "github.com/kataras/iris" "github.com/kataras/iris/mvc" ) type PlantsCtrl struct { } func (m *PlantsCtrl) BeforeActivation(b mvc.BeforeActivation) { b.Handle("GET", "/plants", "Get") b.Handle("POST", "/plants", "Post") } func (c *PlantsCtrl) Post() { } func (c *PlantsCtrl) Get() { } ty...
package main import ( "bytes" "os" "os/exec" "testing" ) func isExist(path string) bool { _, err := os.Stat(path) return err == nil || os.IsExist(err) } func TestGen(t *testing.T) { cmd := exec.Command("./generate", "-i", "test/input", "-o", "test/output", "-s", "test/main") cmd.Run() isExist("test/output") ...
package main import ( "bytes" "encoding/json" "io" "net/http" ) // Headers is a map of string to string where the key is the key for the header // And the value is the value for the header type Headers map[string]string // Response is a generic response object for our handlers type Response struct { // StatusCo...
package main /** 415. 字符串相加 你这个学期必须选修 numCourse 门课程,记为 `0` 到 `numCourse-1` 。 在选修某些课程之前需要一些先修课程。 例如,想要学习课程 `0` ,你需要先完成课程 `1` ,我们用一个匹配来表示他们:`[0,1]` 给定课程总量以及它们的先决条件,请你判断是否可能完成所有课程的学习? 示例 1: ``` 输入: 2, [[1,0]] 输出: true 解释: 总共有 2 门课程。学习课程 1 之前,你需要完成课程 0。所以这是可能的。 ``` 示例 2: ``` 输入: 2, [[1,0],[0,1]] 输出: false 解释: 总共有 2 门课程...
package structSiradig import ( "time" "github.com/xubiosueldos/conexionBD/Legajo/structLegajo" "github.com/xubiosueldos/conexionBD/structGormModel" ) type Siradig struct { structGormModel.GormModel Legajo *structLegajo.Legajo `json:"legajo" gorm:"ForeignKey:Legajoid;ass...
/* Copyright © 2021 Denis Belyatsky <denis.bel@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, modify, merge, ...
// ------------------------------------------------------------------- // // salter: Tool for bootstrap salt clusters in EC2 // // Copyright (c) 2013-2014 Orchestrate, Inc. All Rights Reserved. // // This file is provided to you under the Apache License, // Version 2.0 (the "License"); you may not use this file // exce...
package goodgame import "fmt" type GamesPaginate struct { Links LinksPaginate `json:"_links,omitempty"` Embedded Games `json:"_embedded,omitempty"` PageCount int `json:"page_count,omitempty"` PageSize int `json:"page_size,omitempty"` TotalItems int `json:"total_ite...
// Copyright (C) 2019 Cisco Systems 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 agr...
package util import ( "fmt" "gim/public/logger" "runtime" ) // RecoverPanic 恢复panic func RecoverPanic() { err := recover() if err != nil { logger.Sugar.Error(err) logger.Sugar.Error(GetPanicInfo()) } } // PrintStaStack 打印Panic堆栈信息 func GetPanicInfo() string { buf := make([]byte, 2048) n := runtime.Stack(...
package main import "fmt" // Square : Is a square ? type Square struct { // we create a struct, a user defined type side float64 } func (z Square) area() float64 { // then we attach a method to that type return z.side * z.side } // Triangle : #my test type Triangle struct { base float64 height float64 } // #...
package main import ( "fmt" "net" "github.com/containerd/containerd" networking "github.com/containerd/go-cni" ) type cni struct { network networking.CNI } func (n *cni) Create(task containerd.Task) (string, error) { result, err := n.network.Setup(task.ID(), fmt.Sprintf("/proc/%d/ns/net", task.Pid())) if err...
package main import ( "fmt" "testing" ) func TestSimple(t *testing.T) { fmt.Println(restoreString("abc", []int{0, 1, 2})) fmt.Println(restoreString("aaiougrt", []int{4, 0, 2, 6, 7, 3, 1, 5})) } func restoreString(s string, indices []int) string { ans := make([]uint8, len(indices)) for i := 0; i < len(indic...
// This file was generated for SObject AggregateResult, API Version v43.0 at 2018-07-30 03:47:30.51652835 -0400 EDT m=+16.859767412 package sobjects import ( "fmt" "strings" ) type AggregateResult struct { BaseSObject Id string `force:",omitempty"` } func (t *AggregateResult) ApiName() string { return "Aggrega...
package saturn import "fmt" type PageContent struct { IsFile bool Path string Siblings []*PathComponent Children []*PathComponent } func NewFileContent(path string, siblings []*PathComponent) *PageContent { return &PageContent{ Path: path, IsFile: true, Siblings: siblings, } } func NewDirect...
package Routes import ( "fmt" "github.com/appleboy/gin-jwt" "github.com/gin-gonic/gin" "github.com/kylesliu/gin-demo/App/Controllers/v1" "github.com/kylesliu/gin-demo/App/Controllers/v3" "github.com/kylesliu/gin-demo/App/Repositories/MySQL" "github.com/kylesliu/gin-demo/App/Repositories/Services" "github.com/k...
package service import ( "context" "go-gcs/src/config" "go-gcs/src/logger" "go-gcs/src/service/googlecloud/pubsubprovider" "go-gcs/src/service/googlecloud/storageprovider" "gopkg.in/go-playground/validator.v9" ) // Container is the structure for container type Container struct { Config config.Conf...
package todo type Repository interface { Delete(id string, userId string) error GetAll(userId string) ([]*Todo, error) GetByID(id string, userId string) (*Todo, error) Store(u *Todo, userId string) error Update(u *Todo, userId string) error }
package bot import ( "log" "regexp" msg "github.com/xsami/TgBotGo/bot/messages" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" ) var regularMsgs = map[string]interface{}{ "hi": msg.Greet} func messageHandler(update tgbotapi.Update, bot *tgbotapi.BotAPI) error { message := update.Message.Text v...
package flagen import ( "container/list" "fmt" ) type flagSet struct { argList []string flagSet *orderedFlagSet } func (fs *flagSet) parse(args []string) error { fs.argList = args fs.flagSet = newOrderedFlagSet() for { seen, err := fs.parseOne() if seen { continue } return err } } func (fs *flagS...
package certs import "fmt" func PathForCert(baseName string) string { return fmt.Sprintf("%s.crt", baseName) } func PathForKey(baseName string) string { return fmt.Sprintf("%s.key", baseName) } func PathForPub(baseName string) string { return fmt.Sprintf("%s.pub", baseName) }
package main import ( "context" "fmt" "io" "math" "os" "os/exec" ) var ( executeCmd = initExecuteCmd() ) func initExecuteCmd() func(context.Context, string) *exec.Cmd { shellPath := os.Getenv("SHELL") // If we can't find the current shell, we'll try to lookup the shell paths supportedShells := []string{"ba...
package json import ( "fmt" //"gopkg.in/mgo.v2" //"gopkg.in/mgo.v2/bson" "encoding/json" "io/ioutil" "net/http" //"strings" "testing" "time" ) /* func Test(t *testing.T) { session, _ := mgo.Dial("test:test@localhost") db = session.DB("test") search := bson.M{"_id": bson.ObjectIdHex("52f4...
package filesystem import ( "context" "encoding/json" "fmt" "io" "io/ioutil" "os" "path/filepath" "strings" "sync" "time" "github.com/bwmarrin/snowflake" "github.com/projecteru2/phistage/common" "github.com/projecteru2/phistage/helpers" "github.com/projecteru2/phistage/store" "gopkg.in/yaml.v3" ) type...
package models import ( "crypto/sha256" "fmt" "reflect" "testing" ) func TestUnmarshalJSON(t *testing.T) { tests := []struct{ name string input string expected Film err bool }{ { name: "Valid film json format", input: "{\"Name\": \"TestFilm\", \"AudioFile\": \"TestAudioFile\", \"Year\": \"2000\"...
package tpl import ( "bytes" "text/template" ) func GitIgnoreTemplate() []byte { return []byte(` **/kubeconfs/*.yml `) } type GenericClusterInfo struct { ClusterName string ClusterProvider string ClusterVariant string CloudFlareDnsEnabled bool CloudFlareDnsApiT...
package subscription // CreateResponse is a wrapper for create subscription response type CreateResponse struct { ID string Status Status LastCreatedInvoiceURL string }
package main import ( "fmt" "sync" ) func main() { m := sync.Mutex{} m.Lock() count := 0 for i := 0; i < 10; i++ { go func() { count++ }() } m.Unlock() fmt.Println(count) }
package pangram import ( "fmt" "strings" ) func IsPangram(s string) bool { s = strings.ToLower(s) var i rune var letters []rune for i = 'a'; i <= 'z'; i++ { letters = append(letters, (i)) } // fmt.Println(letters) c:=0 for i='a';i <='z';i++ { if strings.Contains(s,string(i)) == true { c++ } }...
package main import ( "bufio" "fmt" "os" ) func main() { fmt.Println("hello world") } func run(filename string) int { input, _ := os.Open(filename) defer input.Close() sc := bufio.NewScanner(input) for sc.Scan() { fmt.Println(sc.Text()) } return 0 }
package main import ( "fmt" "time" ) const ( SpeedFood = 2 SpeedHappy = 1 SpeedHealth = 2 SpeedNormalWeight = 1 SpeedOverWeight = 2 NormalWeight = 42 ) var ( moveDuration = 60 * time.Second sleepCheckDuration = 5 * time.Second ) func (app *application) mainLoop() { tick ...
package article import ( "github.com/go-chi/chi" "github.com/go-playground/validator/v10" "github.com/hardstylez72/bblog/internal/api/controller" "github.com/hardstylez72/bblog/internal/storage/article" ) type articleController struct { articleStorage article.Storage validator *validator.Validate } func E...
package main import ( "fmt" "os" "github.com/iamtraining/go-github-issue-tool/requests" "github.com/joho/godotenv" ) func init() { if err := godotenv.Load(); err != nil { panic("couldnt load .env") } } func usage() { fmt.Println(` this tool is needed to interract with github issues available commands to ...
// 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 watcher import ( "context" "fmt" "log" "sync" "time" "github.com/radovskyb/watcher" ) type Handler interface { Handle(ctx context.Context, event watcher.Event, wg *sync.WaitGroup) } type Watcher struct { root string watch *watcher.Watcher pollingInterval time.Duration eventHa...
package graphql import ( "context" "fmt" "net/http" "os" "strings" "boiler/pkg/errors" "boiler/pkg/service" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/apollotracing" "github.com/99designs/gqlgen/graphql/handler/extension...
package controller import ( "github.com/gin-gonic/gin" "github.com/makishi00/go-vue-bbs/model" "github.com/makishi00/go-vue-bbs/service" ) var User = userimpl{} type userimpl struct { } func (u *userimpl) Create(c *gin.Context) { var user model.User err := c.BindJSON(&user) if err != nil { BatRequest(err.Er...
// Copyright 2015 - António Meireles <antonio.meireles@reformi.st> // // 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 requi...
package main import ( "fmt" "log" "net/http" "os" "runtime" "time" "golang.org/x/net/websocket" ) func main() { runtime.GOMAXPROCS(runtime.NumCPU()) http.Handle("/ws", websocket.Handler(chat)) if err := http.ListenAndServe(":9999", nil); err != nil { fmt.Println(err) os.Exit(1) } } func chat(ws *web...
package main import ( "context" "fmt" "golang.org/x/sync/errgroup" "io" "net/http" "os" "os/signal" ) func helloServer(w http.ResponseWriter, req *http.Request) { io.WriteString(w, "hello") } func StartHttp(ser *http.Server) error { http.HandleFunc("/hello", helloServer) fmt.Println("start server") err :=...
package main import ( "github.com/oojob/service-profile/src/cmd" "github.com/oojob/service-profile/src/config" ) func main() { config.Init() cmd.Execute() }
package main import ( "github.com/armr-dev/idea/internal/pkg/utils" ) func main() { }
package server import ( "net/http" "github.com/Sirupsen/logrus" "github.com/bryanl/dolb/service" "github.com/gorilla/sessions" ) var ( sessionStore = sessions.NewCookieStore([]byte("secret")) ) func UserRetrieveHandler(c interface{}, r *http.Request) service.Response { config := c.(*Config) session, err := ...
package main import "fmt" /** 数组定义格式:var arrayName [n]arraryType ,n为多少时就一定不能大于n个value,否则报错invalid array index 2 (out of bounds for 2-element array) 不确定有多少个key时,可以用...表示 */ var a =[...]int{1,2,3} var b [2]int func main() { b[0] = 0 b[1]=1 c:=[3]int{1,2,3} //b[2]=2 fmt.Println(a,b,c) }
package ptp import ( "net" "time" ) // Handlers for P2P packets received from other network peers or TURN servers // HandleP2PMessage is a handler for new messages received from P2P network func (p *PeerToPeer) HandleP2PMessage(count int, srcAddr *net.UDPAddr, err error, rcvBytes []byte) { if err != nil { Log(E...
package storage import ( "context" "database/sql" discoveryv1 "github.com/syncromatics/kafmesh/internal/protos/kafmesh/discovery/v1" "github.com/pkg/errors" ) // Retriever retrieves data from storage type Retriever struct { db *sql.DB } // NewRetriever creates a new retriever func NewRetriever(db *sql.DB) *Re...
package preflight import ( "fmt" ) // SetupHost performs the prerequisite checks and setups the host to run the cluster var hyperkitPreflightChecks = [...]PreflightCheck{ { configKeySuffix: "check-hyperkit-installed", checkDescription: "Checking if HyperKit is installed", check: checkHyperKitInsta...
package controllers import ( "context" "encoding/json" "errors" "github.com/anshap1719/authentication/controllers/gen/google" "github.com/anshap1719/authentication/database" "github.com/anshap1719/authentication/models" "github.com/anshap1719/authentication/utils/auth" . "github.com/anshap1719/authentication/u...
// Copyright (c) 2015, Ben Morgan. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. package dist import "math/rand" // Binomial distribution with parameter n and p. // // TODO. type Binomial struct { r *rand.Rand }
package handler import ( "os" db "github.com/jinmukeji/jiujiantang-services/sms/mysqldb" sms "github.com/jinmukeji/jiujiantang-services/sms/sms_client" "github.com/joho/godotenv" ) const ( enableLog = true maxConns = 1 ) // NewClientOptionsFromEnvFile 读取环境变脸配置文件,返回算法服务器连接配置 func newClientOptionsFromEnvFile(f...
package authdDevice import ( md "github.com/ebikode/eLearning-core/model" tr "github.com/ebikode/eLearning-core/translation" ) // Service provides authdDevice operations type AuthdDeviceService interface { GetAuthdDevice(string) *md.AuthdDevice CreateAuthdDevice(md.AuthdDevice) (md.AuthdDevice, tr.TParam, error) ...
package auth import ( "net/http" "github.com/gin-gonic/gin" "github.com/dgrijalva/jwt-go" "time" "log" ) var ( privateToken []byte ) type LoginFormType struct { Username string `json:"username"` Password string `json:"password"` } func Register(router *gin.Engine, PrivateToken string) { privateToken = []b...
package siemens import ( "time" "github.com/timescale/tsbs/cmd/tsbs_generate_queries/uses/common" "github.com/timescale/tsbs/cmd/tsbs_generate_queries/utils" "github.com/timescale/tsbs/query" ) //SampledData produces a filler for queries in the siemens sampled-data case. type SampledData struct { core uti...
package main import ( "log" "github.com/tzr2020/gin_demo/dao" "github.com/tzr2020/gin_demo/model" "github.com/tzr2020/gin_demo/router" ) func main() { // 连接数据库 err := dao.InitDB() if err != nil { log.Panicf("connect database failure, err: %v", err) } defer dao.CloseDB() // GORM使用迁移模式 // Todo Model与数据库表关...
/* 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 not use this fi...
package ptp import ( "fmt" "net" "strconv" ) func (dht *DHTClient) setupTCPCallbacks() { dht.TCPCallbacks = make(map[DHTPacketType]dhtCallback) dht.TCPCallbacks[DHTPacketType_BadProxy] = dht.packetBadProxy dht.TCPCallbacks[DHTPacketType_Connect] = dht.packetConnect dht.TCPCallbacks[DHTPacketType_DHCP] = dht.pa...
// 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 html import ( "github.com/elliotchance/gedcom" "strings" ) type place struct { PrettyName string country string nodes gedcom.Nodes } func prettyPlaceName(s string) string { s = strings.Replace(s, ",,", ",", -1) s = strings.Replace(s, ",,", ",", -1) s = strings.Replace(s, ",", ", ", -1) s = s...
// Copyright 2014 Alexander Neumann. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* Package chunker implements Content Defined Chunking (CDC) based on a rolling Rabin Checksum. Choosing a Random Irreducible Polynomial The function Rando...
/* * Copyright 2017 - 2019 KB Kontrakt 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 require...
// Apps page package main import ( //"fmt" "github.com/captaingit/dynhtml" "net/http" ) func PageApps(w http.ResponseWriter, r *http.Request) { boiler := dynhtml.NewPlate(w, r) a := boiler.GetElement() user := boiler.GetMData("user").(string) // check if logged in if len(user) > 0 { a.Add("{{.banner}}\n") ...