text
stringlengths
11
4.05M
// Copyright 2022 Saferwall. All rights reserved. // Use of this source code is governed by Apache v2 license // license that can be found in the LICENSE file. // Package gib heuristic.go implements heuristic pattern matching on strings. package gib import ( "regexp" "strings" ) var simplePatterns = []string{ `\A...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package netconfig // A simplified version of the types in cros_network_config.mojom and // network_types.mojom to be used in tests. The JSON marshalling comments are // requ...
package imgio import ( "archive/tar" "encoding/json" "fmt" "io" "os" "path" om "github.com/box-builder/overmount" "github.com/box-builder/overmount/configmap" "github.com/docker/docker/image" dl "github.com/docker/docker/layer" digest "github.com/opencontainers/go-digest" "github.com/opencontainers/image-...
package graphs import "../core" func (d *DirectedNode) DepthFirstSearch() []int { s := new(core.Stack) s.Push(d) var visited []*DirectedNode for n, _ := s.Pop(); s.Size() != 0; n, _ = s.Pop() { curr := n.(*DirectedNode) for _, neighbor := range curr.neighbors { if !(slic...
package main import ( "html/template" "net/http" "github.com/gin-gonic/gin" ) func main() { r := gin.Default() //添加自定义函数 r.SetFuncMap(template.FuncMap{ "safe": func(str string) template.HTML { return template.HTML(str) }, }) r.LoadHTMLFiles("./xss.tmpl") r.GET("/safepage", func(c *gin.Context) { ...
// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php package blkverify import ( "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/M...
package model import ( "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/mysql" ) type Employee struct { gorm.Model Name string `gorm:"unique" json:"name"` City string `json:"city"` Age int `json:"age"` Status bool `json:"status"` } func (e *Employee) Disable() { e.Status = false ...
package main import ( "database/sql" "fmt" "html/template" "net/http" "time" "github.com/go-martini/martini" _ "github.com/go-sql-driver/mysql" "github.com/martini-contrib/sessions" ) var wehackerDB *sql.DB func runMysql(host string, user string, passwd string) { loginInfo := user + ":" + passwd + "@tcp(" ...
package models import ( "context" "database/sql" "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/tristate" "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" "yunion.io/x/onecloud/pkg/apis/monitor" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/o...
package errors import ( "fmt" "runtime" "strings" ) type Stacktrace []*StacktraceFrame func (f Stacktrace) Caller() *StacktraceFrame { return f[len(f)-1:][0] } func (f Stacktrace) String() string { sb := &strings.Builder{} for _, frame := range f { sb.WriteString(fmt.Sprintf("%s\t%s:...
package main import ( "fmt" "os" "github.com/golang/glog" ) type targetDirectory string func (t targetDirectory) String() string { return string(t) } func (t targetDirectory) IsValid() error { if _, err := os.Stat(t.String()); err != nil { glog.V(2).Infof("target %s invalid: %v", t, err) return fmt.Errorf...
package factory import ( "fmt" "go_simpleweibo/app/models" userModel "go_simpleweibo/app/models/user" "go_simpleweibo/pkg/utils" "time" "github.com/Pallinder/go-randomdata" "github.com/bluele/factory-go/factory" ) var ( // 头像假数据 avatars = []string{ "https://cdn.learnku.com/uploads/avatars/7850_1481780622...
package models import ( "github.com/astaxie/beego/orm" "poetryAdmin/worker/app/tools" "poetryAdmin/worker/core/define" "time" ) var TableCategory = "poetry_category" type uintMaps map[uint32]Category //poetry_category 诗文分类表 type Category struct { Id int `orm:"column(id);auto"` CatName st...
package hy import ( "fmt" "html/template" "strings" "sync" "github.com/bokwoon95/erro" "github.com/microcosm-cc/bluemonday" ) // https://developer.mozilla.org/en-US/docs/Glossary/Empty_element var singletonElements = map[string]struct{}{ "AREA": {}, "BASE": {}, "BR": {}, "COL": {}, "EMBED": {}, "HR": {}, "IMG...
package main import ( "fmt" "os" "sync" "time" ) type secret struct { RWM sync.RWMutex M sync.Mutex password string } var Password = secret{password: "root"} // 通过rwmutex写 func Change(s *secret, pass string) { s.RWM.Lock() fmt.Println("Change with rwmutex lock") time.Sleep(3 * time.Second) s.password ...
package utils import ( "fmt" "os" ) func ShowErrorMessage() { fmt.Println("Please, select a valid option: 1, 2 or 0") os.Exit(-1) }
// Copyright 2019 The Berglas 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 agre...
package controllers import ( "github.com/gin-gonic/gin" "github.com/google/wire" "PMSApp/app/models" "PMSApp/app/utils" "go.uber.org/zap" ) // LoginSet Login DI var LoginSet = wire.NewSet(wire.Struct(new(Login), "*")) // Login 登录结构体 type Login struct { Logger *zap.Logger Util utils.Ginx UserModel mod...
package node import ( "bytes" "encoding/hex" "errors" "github.com/frankh/rai" "github.com/frankh/rai/address" "github.com/frankh/rai/blocks" "github.com/frankh/rai/uint128" ) type MessageBlockOpen struct { Source [32]byte Representative [32]byte Account [32]byte MessageCommon } type Message...
// Copyright 2016 Apcera Inc. All rights reserved. package gcp import ( "encoding/json" "errors" "fmt" "io/ioutil" "net" "net/http" "os" "strings" "time" "context" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "golang.org/x/oauth2/jwt" googlecloud "google.golang.org/api/compute/v1" googleresourc...
// This is part of the library that is being used directly inside this package. // https://github.com/alexedwards/stack package webgo import "net/http" type chainHandler func(*Context) http.Handler type ChainMiddleware func(*Context, http.Handler) http.Handler type Chain struct { mws []ChainMiddleware h chainHan...
package models import( "encoding/json" ) /** * Type definition for VmwareTypeEnum enum */ type VmwareTypeEnum int /** * Value collection for VmwareTypeEnum enum */ const ( VmwareType_KVCENTER VmwareTypeEnum = 1 + iota VmwareType_KFOLDER VmwareType_KDATACENTER VmwareType_KCOM...
package main import ( "fmt" "os" "sort" "strconv" "time" "github.com/dustin/go-humanize" "github.com/olekukonko/tablewriter" ) type listCompactionSummaryCmd struct { TenantID string `arg:"" help:"tenant-id within the bucket"` backendOptions } func (l *listCompactionSummaryCmd) Run(ctx *globalOptions) error...
package handler import ( "fmt" "net/http" ) type HelloHandler struct{} func (*HelloHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { //ints := []int{0, 1, 2} //fmt.Fprintf(w, "%v", ints[0:5]) fmt.Fprintf(w, "Hello World1") }
package main import ( "io/ioutil" "os" "testing" "time" ) // TestConfigReloadNotifications tests the notification of files changing with // limiting on output duration. // x = file write // y = expected notification time // x x y // | | | // 0s 1s 2s fun...
package account import ( "crypto/md5" "crypto/rand" "errors" "fmt" "log" "strconv" "time" "unicode" "github.com/jinzhu/gorm" "github.com/kiwih/nullables" "golang.org/x/crypto/bcrypt" "gopkg.in/validator.v2" ) type Account struct { Id int64 Email string...
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package adb import ( "context" "regexp" "strconv" "strings" "chromiumos/tast/common/testexec" "chromiumos/tast/errors" "chromiumos/tast/shutil" ) // ShellCommand re...
package main import "fmt" func main() { c := make(chan int, 2) // go func() { // c <- 13 // }() c <- 13 c <- 99 fmt.Println(<-c) fmt.Println(<-c) }
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package k8s import ( "context" corev1 "k8s.io/api/core/v1" k8sErrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // CreateOrUpdateSecret creates or update a...
//go:generate mockgen -package mock -destination=mock/port_domain.go github.com/johnnywidth/9ty/api PortDomainClient package service import ( "context" "fmt" "github.com/johnnywidth/9ty/api" "github.com/johnnywidth/9ty/client/entity" ) // PortDomain port domain service with grpc client type PortDomain struct {...
package forgotpassword func UserForgotPassword(email string) error { return nil }
// Copyright 2018 The gVisor 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 agree...
package main import ( "fmt" "os" "os/signal" "syscall" "time" ) func main() { notifyKill() fmt.Printf(">> env addr:%v,port:%v,topic:%v \n", os.Getenv("KAFKA_HOST"), os.Getenv("PORT"), os.Getenv("TOPIC")) config := Config{ Brokers: []string{os.Getenv("KAFKA_HOST") + ":" + os.Getenv("PORT")}, Topic: os.G...
package service import ( "errors" . "worker/common" "worker/model/task" ) type TaskServicer interface { Check() error Run() } func GetService(task *task.TaskModel) (TaskServicer, error) { name := task.Name switch name { case VIDEO_DOWNLOAD: return &VideoService{task: task}, nil default: return nil, er...
package main import ( "fmt" "unsafe" ) type S struct { A struct{} B struct{} } func main() { null := struct{}{} fmt.Println(unsafe.Sizeof(null)) // 0 fmt.Printf("%p\n", &null) // 定义多个空结构体都指向同一个内存地址(全局区) null2 := struct{}{} fmt.Printf("%p\n", &null2) s := S{} fmt.Println(s.A) // {} fmt.Println(s.B) // ...
package main import "fmt" func main() { err1, err2 := 1, 2 fmt.Println(&err1, &err2) // 左边存在两个变量的情况,会一起重新进行声明time // 这里的地址没有变,不要混淆 作用域 以及 life err2, err3 := 3, 4 fmt.Println(&err1, &err2, &err3) }
package persist import ( "github.com/jinzhu/gorm" "github.com/Eric-GreenComb/one-account-info/bean" "github.com/Eric-GreenComb/one-account-info/config" ) // ConnectDb connect Db func ConnectDb() (*gorm.DB, error) { db, err := gorm.Open(config.MariaDB.Dialect, config.MariaDB.URL) if config.Server.GormLogMode ==...
package Pool import ( "context" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/readpref" "log" "time" ) type MongoPool struct { pool chan *mongo.Client //存放连接的管道, 缓存控制最大闲置连接数 timeout time.Duration //超时 uri string ...
package service import ( "testing" m "../model" ) func TestVerifyTime(t *testing.T) { email := m.Email{From: "abc@gmail.com", ScheduledTime: "09 Dec 18 4:36 UTC"} if email.ScheduledTime != "09 Dec 18 4:36 UTC" { t.Error("Expected ScheduledTime equal 09 Dec 18 4:36 UTC") } if email.From != "abc@gmail.com" {...
// Copyright 2014 Dirk Jablonowski. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ambientlight import ( "github.com/dirkjabl/bricker" "github.com/dirkjabl/bricker/device" ) // SetIlluminanceCallbackThreshold creates the subscrib...
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "Models" "net/http" "math/rand" ) const Rooms = map[string]Models.Room const KEY_LENGTH = 10 const letterRunes = []string("abcdefgh...
package main import ( "blockchain/certdemo/certdb" "encoding/json" "fmt" "log" "net/http" "strings" ) func main() { //启动消息推送服务 web() } type NoBC struct{ Status string Key string Cert string } func web() { http.HandleFunc("/queryByNoBC", queryByNoBc) log.Println("starting service!") //log.Fatal输出后,会退出程序,执...
//常數 下了之後無法再更改 除非同樣常數指令更改 package main import "fmt" const a int = 42 var b int = 11 func main() { fmt.Println(a) fmt.Printf("%T\n", a) const a int = 55 fmt.Println(a) fmt.Println(b) b = 22 fmt.Println(b) }
// Copyright (c) 2014 Eric Robert. All rights reserved. package shard import ( "fmt" "github.com/EricRobert/goreports" "path" ) type URLSharder struct { Table Table } func (h *URLSharder) Shard(req *report.Request) (url string, k int, err error) { p := req.Request.URL.Path key := path.Base(p) if p == "." ||...
package v2 import ( "bytes" "context" "errors" "fmt" "io" "net/url" "strings" "testing" "time" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" "github.com/traPtitech/trap-collection-server/src/domain" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPt...
package divisiblesumpairs // https://www.hackerrank.com/challenges/divisible-sum-pairs func nChooseK(N, K uint32) uint64 { result := uint64(1) for k := uint64(0); k < uint64(K); k++ { result = result * (uint64(N) - k) / (k + 1) } return result } // DivisibleSumPairs - implements the solution to the problem fun...
package boxxy func newBlock(offset int) *block { return &block{offset: offset} } type block struct { buf [32]interface{} tail int // This actually could be a uint8.. hmm offset int } func (b *block) get(idx int) interface{} { return b.buf[idx] } func (b *block) append(val interface{}) (ok bool) { if b.ta...
package model //Content ... type Content struct { Type string `json:"type"` Value string `json:"value"` } // Email Model Structure type Email struct { From string To []string Cc []string Bcc []string Subject string Content []Content Status string ...
package ssdb //ssdb连接池 import ( // "encoding/json" "errors" "strconv" "time" "github.com/astaxie/beego" "github.com/ssdb/gossdb/ssdb" ) //ssdb连接信息 type SsdbProvider struct { conn *ssdb.Client Host string Port int // MaxLifetime int64 } //ssdb初始化连接 func (p *SsdbProvider) connectInit() error { var err erro...
package model import "errors" var ( ErrParam = errors.New("Param Error.") )
package command import ( "os" "path/filepath" "github.com/codegangsta/cli" "github.com/dnaeon/gru/catalog" "github.com/dnaeon/gru/module" "github.com/dnaeon/gru/resource" ) // NewApplyCommand creates a new sub-command for // applying configurations on the local system func NewApplyCommand() cli.Command { cmd ...
package delete import ( "encoding/json" "net/http" "github.com/ocoscope/face/db" "github.com/ocoscope/face/utils" "github.com/ocoscope/face/utils/answer" ) func Department(w http.ResponseWriter, r *http.Request) { type tbody struct { CompanyID, UserID, DepartmentID int64 AccessToken st...
package request import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestNewRequestBuilderWithDefaults(t *testing.T) { builder := NewRequestBuilder() builder.WithUrl(POSTMAN_ECHO_ROOT) r1 := builder.Build() assert.NotNil(t, r1, "Should not be nil") r2 := r1.getUnderlyingRequest() c := r1...
package main import "fmt" /* - Utilizando o exercício anterior, remova uma entrada do map e demonstre o map inteiro utilizando range. */ func main() { mepezin := map[string][]string{"cores": []string{"verde", "azul", "preto"}} mepezin["tools"] = []string{"gobuster", "dirbuster", "set"} fmt.Println(mepezin) de...
package main import ( "bytes" "flag" "fmt" "gopkg.in/russross/blackfriday.v2" "io/ioutil" "log" "os" "os/exec" "path/filepath" "strings" ) func runCommand(command string) { args := strings.Fields(command) var cmd *exec.Cmd if len(args) < 2 { cmd = exec.Command(args[0]) } else { cmd = exec.Command(...
package main import ( "github.com/hexoul/metric-collector/collector" "github.com/hexoul/metric-collector/imon" ) func init() { } func main() { collector.New(10, imon.MakeRequestContext) }
package users import ( "database/sql" "fmt" "time" _ "github.com/go-sql-driver/mysql" ) //MysqlStore represents a user store backed by mySQL type MysqlStore struct { db *sql.DB } //NewMysqlStore constructs a new MysqlStore func NewMysqlStore(db *sql.DB) *MysqlStore { //initialize and return a new MysqlStore s...
package main import ( "fmt" "math" ) func maximumGap(nums []int) int { if len(nums) <= 1 { return 0 } min, max := nums[0], nums[0] for _, v := range nums { if v < min { min = v } if v > max { max = v } } bSize := (max - min + len(nums)) / len(nums) bNum := (max - min + bSize) / bSize valueTo...
// Copyright (c) Red Hat, Inc. // Copyright Contributors to the Open Cluster Management project package managedcluster import ( "context" "fmt" "reflect" "strconv" "strings" "time" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachiner...
package clusterconf_test import ( "encoding/json" "fmt" "net/url" "path/filepath" "testing" "time" "github.com/cerana/cerana/acomm" "github.com/cerana/cerana/pkg/test" "github.com/cerana/cerana/provider" "github.com/cerana/cerana/providers/clusterconf" "github.com/cerana/cerana/providers/kv" "github.com/s...
package gohaystack import ( "encoding/json" "reflect" "sort" "testing" ) func TestGrid_UnmarshalJSON(t *testing.T) { blabla := "blabla" myID := NewHaystackID("myid") myID2 := NewHaystackID("myid2") type fields struct { Meta map[string]string entities []*Entity } type args struct { b []byte } tes...
package trackerapi import ( "os" "bufio" "bytes" "encoding/base64" "io/ioutil" "net/http" "testing" "github.com/stretchr/testify/assert" ) // RoundTripFunc . type RoundTripFunc func(req *http.Request) *http.Response // RoundTrip . func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) {...
package Jump_Game_II import "testing" func Test_jump(t *testing.T) { type args struct { nums []int } tests := []struct { name string args args want int }{ // TODO: Add test cases. { "case", args{ []int{1, 2}, }, 1, }, { "case1", args{ []int{7, 0, 9, 6, 9, 6, 1, 7, 9, 0, 1...
package V01 import ( "fmt" "github.com/wangyide/golearn/huawei/base" ) type Vlan struct { base.Vlan FieldC bool } func (c *Vlan) ShowA() { c.FieldB = "v01" c.Vlan.FieldA = 10 fmt.Printf("%v\n", c) }
//go:build !e2e_testing // +build !e2e_testing package overlay import ( "fmt" "net" "os" "path/filepath" "runtime" "syscall" "github.com/sirupsen/logrus" ) func newTunFromFd(_ *logrus.Logger, _ int, _ *net.IPNet, _ int, _ []Route, _ int, _ bool) (Device, error) { return nil, fmt.Errorf("newTunFromFd not sup...
package message import ( "github.com/bitmaelum/bitmaelum-server/core" ) type Message struct { Header Header Catalog Catalog } func LoadMessage(addr core.Address, id string) { }
package glog import ( "testing" ) func TestColorLog(t *testing.T) { VerboseF("TestColorLog F", "go get -u %s", "gooim.me/dewdrop/glog") TraceF("TestColorLog F", "go get -u %s", "gooim.me/dewdrop/glog") ErrorF("TestColorLog F", "go get -u %s", "gooim.me/dewdrop/glog") WarnF("TestColorLog F", "go get -u %s", "gooi...
package company import ( "encoding/json" "github.com/xiaotian/stock/pkg/enums" "github.com/xiaotian/stock/pkg/model" "io/ioutil" "math/rand" "net/http" "strconv" "time" ) //上海交易所上市公司信息收集器 type SHCompanyCollector struct { } const ( COOKIE string = "yfx_c_g_u_id_10000042=_ck18012900250116338392357618947...
// Copyright © 2020. All rights reserved. // Author: Ilya Stroy. // Contacts: qioalice@gmail.com, https://github.com/qioalice // License: https://opensource.org/licenses/MIT package ekalog import ( "github.com/qioalice/ekago/v2/internal/ekaletter" ) func init() { // Init log levels. initLevels() // Create firs...
package main import ( "fmt" "net" "os" //"runtime" ) func errFunc(err error, info string) { if err != nil { fmt.Println(info, err) //return // 返回函数 //runtime.Goexit() // 结束当前go程 os.Exit(1) // 结束当前进程 } } func main() { listener, err := net.Listen("tcp", "127.0.0.1:8900") errFunc(err, "net.Listener err:...
package set import ( "fmt" "sort" ) // Set - type Set interface { Have(...interface{}) bool Subset(Set) bool Superset(Set) bool Add(...interface{}) Remove(...interface{}) Clear() Or(Set) Set And(Set) Set Xor(Set) Set Copy() Set Keys() []string } type set struct { Values map[interface{}]struct{} } func...
package sound import ( "fmt" "testing" ) func Test_NewSong(t *testing.T) { type testData struct { bpm int title string duration float64 pattern map[string][8]int errResponse error songResponse *Song } tests := map[string]testData{ "HappyPath": { bpm: 128, title:...
package main import ( "net/http" "github.com/patrickoliveros/bookings/api" "github.com/patrickoliveros/bookings/internal/config" "github.com/patrickoliveros/bookings/internal/pages" "github.com/go-chi/chi" "github.com/go-chi/chi/v5/middleware" ) func routes(app *config.AppConfig) http.Handler { mux := chi.Ne...
package persist import ( "database/sql" "github.com/Miniand/venditio/model" "os" ) func DatabaseDriver() string { driver := os.Getenv("DATABASE_DRIVER") if driver == "" { driver = "sqlite3" } return driver } func DatabaseOptions() string { options := os.Getenv("DATABASE_OPTIONS") if options == "" { opti...
// Copyright (C) 2017 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed t...
package routes import ( "QRcodeBillApi/helper" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/monitor" ) func Setup(app *fiber.App) { app.Get("/dashboard", monitor.New()) app.Get("/api/register/:value/:key", helper.Login) app.Get("/api/table/:number", helper.BringTable) app.Get("api/...
package models import ( "encoding/json" "log" ) type OfferAllContent struct { Id int64 `json:"id"` Offer_uid string `json:"offer_uid"` Merchant_uid string `json:"merchant_uid"` Offer_point float64 `json:"offer_point"` Offer_cat_id int64 `json:"offer_cat_id"` O...
package main import ( "net/http" "database/sql" "encoding/json" "gopkg.in/validator.v2" ) type credRequest struct { Username string `json:"username" validate:"min=3,max=64,nonzero"` Password string `json:"password" validate:"min=8,max=128,nonzero"` } type tokenResponse struct { AccessToke...
// Copyright (C) 2020 Storj Labs, Inc. // See LICENSE for copying information package processgroup_test import ( "io" "os" "os/exec" "testing" "time" "github.com/stretchr/testify/require" "storj.io/common/processgroup" "storj.io/common/testcontext" ) func TestProcessGroup(t *testing.T) { ctx := testcontex...
package grpcx import ( "context" "log" "net" "google.golang.org/grpc" "github.com/socialpoint-labs/bsk/contextx" ) // Daemon represents a runnable gRPC daemon. // // A gRPC Daemon will manage the lifecycle of the given gRPC server, gracefully shutting it down // once the runner context is done. // // Typically...
package migration import ( "encoding/base32" "fmt" "net/url" ) var ( typeString = map[Payload_OtpType]string{ Payload_OTP_TYPE_HOTP: "hotp", Payload_OTP_TYPE_TOTP: "totp", } algString = map[Payload_Algorithm]string{ Payload_ALGORITHM_SHA1: "SHA1", Payload_ALGORITHM_SHA256: "SHA256", Payload_ALGORITH...
package examples import ( "io" "math/rand" "os" "github.com/go-echarts/go-echarts/v2/charts" "github.com/go-echarts/go-echarts/v2/components" "github.com/go-echarts/go-echarts/v2/opts" ) var dimensions = []string{"Visit", "Add", "Order", "Payment", "Deal"} func genFunnelKvItems() []opts.FunnelData { items :=...
// Copyright 2019 Yunion // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writi...
// Copyright 2019 - 2022 The Samply Community // // 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 ...
// Copyright © 2020 Weald Technology Trading // 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 a...
package goroutines import "fmt" import "time" func gofun(name string) { for i := 0; i < 3; i++ { fmt.Println(name, ":", i) } time.Sleep(2000 * time.Millisecond) fmt.Println("Done", name) } func testGoRoutines() { gofun("Direct call") go gofun("goroutine") go func(msg string) { time.Sleep(4000 * time.Mil...
package server // all functions under this package func Insert(a configor) (num int64, err error) { num, err = a.GetTabler().Insert() if err != nil { return } return a.GetCacher().Insert() } func Delete(a configor) (num int64, err error) { num, err = a.GetTabler().Delete() if err != nil { return } retu...
package odoo import ( "fmt" ) // ResLang represents res.lang model. type ResLang struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` Active *Bool `xmlrpc:"active,omptempty"` Code *String `xmlrpc:"code,omptempty"` CreateDate *Time `xmlrpc:"create_date,omptempty"` Crea...
package main import ( "log" "net/http" "github.com/goinaction/code/chapter9/listing17/handlers" ) func main() { handlers.Routes() log.Println("listener: started: listening on :4000") http.ListenAndServe(":4000", nil) }
package odoo import ( "fmt" ) // AccountFiscalPositionTax represents account.fiscal.position.tax model. type AccountFiscalPositionTax struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` CreateDate *Time `xmlrpc:"create_date,omptempty"` CreateUid *Many2One `xmlrpc:"create_uid,omptempty"` Disp...
// Copyright (C) 2019 rameshvk. All rights reserved. // Use of this source code is governed by a MIT-style license // that can be found in the LICENSE file. package partition import ( "context" "fmt" "hash/crc32" "sort" "strconv" "sync" ) // NewHashRing returns a picker which uses a consistent hashing scheme /...
// SPDX-License-Identifier: ISC // Copyright (c) 2014-2020 Bitmark Inc. // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. // Package avl - an AVL balanced tree with the addition of parent // pointers to allow iteration through the nodes // // Note: an individual tree is...
package models import ( "bytes" "crypto/md5" "encoding/hex" "html/template" "net/smtp" "os" "strconv" "strings" "time" ) /* * user : example@example.com login smtp server user * password: xxxxx login smtp server password * host: smtp.example.com:port smtp.163.com:25 * to: example@example.co...
package repository import ( "context" "github.com/caos/zitadel/internal/iam/model" ) type IamRepository interface { Health(ctx context.Context) error IamByID(ctx context.Context, id string) (*model.Iam, error) }
package slog import ( "fmt" "log" "os" "strings" "sync" "go.uber.org/zap" "go.uber.org/zap/zapcore" "gopkg.in/natefinch/lumberjack.v2" ) var rootLogger = NewDebugLogger(``, zapcore.DebugLevel) //必须先初始化rootLogger,否则调用此方法将抛出空指针错误 func NewLogger(cfg *Conf, tags ...string) *zap.Logger { if cfg == nil { log.P...
package main import ( "database/sql" _ "github.com/lib/pq" "log" "fmt" ) func main () { db, err := sql.Open("postgres", "password=password host=localhost dbname=mit_workshop sslmode=disable") if err != nil { log.Fatal(err) } var insert_users string = "Insert into Users(id, email) values($1, $2)" insert_us...
package main import "fmt" func main() { a := 43 fmt.Println(a) fmt.Println(&a) var b *int = &a fmt.Println(b) fmt.Println(*b) *b = 42 //o valor nesse endereco de memoria vai para 42 fmt.Println(a) } // isso é importante // nos podemos passar o endereco de memoria ao invez de um monte de valores // (nos ...
package main import "fmt" func Min(x, y int) int { if x < y { return x } return y } func minDistance(word1 string, word2 string) int { if len(word1) == 0 { return len(word2) } if len(word2) == 0 { return len(word1) } mat := make([][]int, len(word1)+1) for i := 0; i <= len(word1); i = i + 1 { mat[i] ...
package com //内容||文章 import ( "JsGo/JsBench/JsContent" "JsGo/JsHttp" "JsGo/JsLogger" "JsGo/JsStore/JsRedis" "JunSie/constant" "JunSie/util" "encoding/json" "fmt" ) type XM_Contents struct { JsContent.Contents } func Init_content() { JsHttp.WhiteHttps("/newcontent", NewContent) //创建内...
package commands import ( "context" "fmt" "github.com/TRON-US/go-btfs/core/commands/cmdenv" cmds "github.com/TRON-US/go-btfs-cmds" coreiface "github.com/TRON-US/interface-go-btfs-core" "github.com/TRON-US/interface-go-btfs-core/options" "github.com/TRON-US/interface-go-btfs-core/path" ipld "github.com/ipfs/g...