text
stringlengths
11
4.05M
package messenger // ContentType is a specific string type type ContentType string // Content types const ( ContentTypeText ContentType = "text" ContentTypeLocation ContentType = "location" // NotificationTypeRegular will emit a sound/vibration and a phone notification NotificationTypeRegular NotificationTyp...
package fcm import ( "bufio" "fmt" "net" "strings" "github.com/valyala/fasthttp" ) func FasthttpHTTPDialer(proxyAddr string) fasthttp.DialFunc { return func(addr string) (net.Conn, error) { conn, err := fasthttp.Dial(strings.Replace(strings.Replace(proxyAddr, "https://", "", 1), "http://", "", 1)) if err ...
package main import "fmt" func main() { fmt.Println("hogwarts legacy") }
// Copyright 2017 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 dumper import ( "testing" ) func TestGetDumper(t *testing.T) { GetDumper("fs", map[interface{}]interface{}{}) }
package OgameUtil import "bitbucket.org/jc01rho/ogame" func SendRess(bot *ogame.OGame) { //bot.SendFleet() }
// standalone tool to fetch a stream from Twitch and post it to Discord // run in folder with .env file package main import ( "fmt" "os" "strings" "time" . "github.com/Pyorot/streams/src/utils" "github.com/nicklaw5/helix" "github.com/bwmarrin/discordgo" ) var err error var channelID, iconURL string var disc...
package detectOldOfficeExtension import ( "bytes" "github.com/richardlehane/mscfb" "io" "os" ) func isOle(in []byte) bool { return bytes.HasPrefix(in, []byte{0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1}) } /* Работает гораздо лучше чем от vasilie mimetype, но все равно не идеально 2021/08/05 16:20:10 /home/u...
package main import "fmt" func main() { name := "Nabila" if len(name) > 9 { fmt.Println("masuk") } else { fmt.Println("gak masuk") } }
package main import ( "bufio" "encoding/json" "fmt" "io/ioutil" "math/rand" "os" "time" ) //Creating an array struct to store planets type Planets struct { Planets []PlanetDesc `json:"planets"` } //Creating a struct for planets names and descriptions type PlanetDesc struct { Name string `json:"name"`...
package main import ( "context" "log" "time" "github.com/brigadecore/brigade-foundations/retries" "github.com/brigadecore/brigade-foundations/signals" "github.com/brigadecore/brigade-foundations/version" "github.com/brigadecore/brigade/sdk/v3" "github.com/brigadecore/brigade/v2/internal/kubernetes" ) func ma...
package main type tokenType int type char uint8 const eof char = 255 const ( tokenEOF tokenType = iota tokenComment // Simple single or multi-line comment tokenIdentifier // Any identifier that is not a keyword tokenOn // The keyword 'on', indicating a trigger tokenFunc ...
package queries import ( "database/sql" "encoding/json" "net/url" "github.com/pwang347/cs304/server/common" ) // QueryAllBaseImages returns all baseImage rows func QueryAllBaseImages(db *sql.DB, params url.Values) (data []byte, err error) { var ( response = SQLResponse{} tx *sql.Tx ) ...
package avardstock import ( "errors" "fmt" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/sqlite" h "github.com/qasemt/helper" "os" "path" "strings" "sync" ) var pathdb string //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::STRUCT INIT type Nemad struct { ID uint64 `g...
package post import ( "encoding/json" "html/template" "net/http" "github.com/VolticFroogo/Animal-Pictures/captcha" "github.com/VolticFroogo/Animal-Pictures/db" "github.com/VolticFroogo/Animal-Pictures/helpers" "github.com/VolticFroogo/Animal-Pictures/models" "github.com/gorilla/context" "github.com/gorilla/m...
/** in addition to the main goroutine, launch two additional goroutines - each additional goroutine should print something out use waitgroups to make sure each goroutine finishes before your program exists */ package main import ( "fmt" "sync" ) var wg sync.WaitGroup func main() { fmt.Println("Main ...
package metric import ( "errors" "os" ) // type Query struct { obj string fp *os.File } // 打开查询器 func (p *Query) Open() error { //打开文件指针 // 与windows相比,Linux在open时需要知道具体打开哪个文件 // windows的query是通用指针,不需要提前搜集信息 var err error p.fp, err = os.OpenFile(p.obj, os.O_RDONLY, 0) return err } // 关闭查询器 func (p *Query)...
package db import ( "time" "github.com/google/uuid" "crud/chrono" ) type ProductMapping struct { Sku *string `bson:"topvalue_sku"` Barcode *string `bson:"cj_barcode"` } type APILog struct { ID *string `bson:"_id"` TransactionID *string `bson:"transaction_id"` OrderID *string ...
// Package server implements a server for artifactory monitoring. package server import ( "bytes" "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "net/url" "os" "os/signal" "sync" "time" "github.com/composer22/hello-world/logger" ) // Server is the main structure that represents a server instance. ...
package datastructures import ( "testing" ) func TestSet_UnionBasic(t *testing.T) { a := NewSet([]string{"A", "B", "C"}) b := NewSet([]string{"D", "E", "F"}) result := a.Union(b) expected := NewSet([]string{"A", "B", "C", "D", "E", "F"}) if !result.Equals(expected) { t.Errorf("result should containa all ele...
package mysql import ( . "cms/structs" ) func FindUserByName(username string) (user User, err error) { _, err = engine.Where("userName = ?", username).Get(&user) return }
/* * @lc app=leetcode.cn id=54 lang=golang * * [54] 螺旋矩阵 */ // @lc code=start package main import "fmt" func spiralOrder(matrix [][]int) []int { if len(matrix) == 0 { return []int{} } rows := len(matrix) columns := len(matrix[0]) target := rows * columns a := make([]int, target) index := 0 l, t := 0, 0...
package ginplugin import ( "sync" "time" ) type SessionData map[string][]byte type SessionStore interface { Load(id string) (SessionData, error) Save(id string, sessionData SessionData, ttlInMillis int) error TouchIfExists(id string, ttlInMillis int) error } type memSessionStore struct { sync.RWMutex data m...
package comment import ( "github.com/kataras/iris" "github.com/kataras/iris/mvc" ) type CommentsController struct { topicId int64 } func (m *CommentsController) BeforeActivation(b mvc.BeforeActivation) { b.Handle("GET", "/topics/{topicId:long}/comments", "Get") b.Handle("POST", "/topics/{topicId:long}/comments"...
package pkg var Fab func()
package tfc import ( tfcPb "github.com/stefanprisca/strategy-protobufs/tfc" ) func GetPlayerId(player tfcPb.Player) int32 { return int32(player) } func GetResourceId(r tfcPb.Resource) int32 { return int32(r) } func InitPlayerProfile() *tfcPb.PlayerProfile { startingResources := make(map[int32]int32) for _, r ...
package main import ( "fmt" "log" "time" "github.com/sanksons/tavern/common/entity" "github.com/BoutiqaatREPO/nitrous/nitrous" ) func main() { Cache, err := nitrous.GetElastiCacheAdapter(nitrous.ElastiCacheConf{ Addrs: []string{"172.17.0.2:30001"}, PoolSize: 20, }) if err != nil { log.Fatal(err) ...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //220. Contains Duplicate III //Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute...
package cmd import ( "github.com/Files-com/files-cli/lib" "github.com/spf13/cobra" files_sdk "github.com/Files-com/files-sdk-go" "fmt" "os" file_action "github.com/Files-com/files-sdk-go/fileaction" ) var ( FileActions = &cobra.Command{ Use: "file-actions [command]", Args: cobra.ExactArgs(1), Run: f...
// Copyright 2020 The Operator-SDK 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 ...
package form type Pather interface { Path() string }
package message import ( common "football-squares/server/common" db "football-squares/server/db" "log" "time" ) const insertOneSQL = `INSERT INTO messages (message_text, created_at, user_id, game_id) VALUES ($1, $2, $3, $4) RETURNING id;` const selectFromGameSQL = `SELECT * FROM messages where game_id=$1;` con...
package ginja import ( "testing" . "github.com/smartystreets/goconvey/convey" ) func TestGetType(t *testing.T) { Convey("GetType returns the reflected type of the underlying Object", t, func() { Convey("on values", func() { ro := ResourceObject{Object: testItem} So(ro.getType(), ShouldEqual, "testitem") ...
package im_mysql_model import ( "Open_IM/pkg/common/db" "time" ) func InsertIntoGroupRequest(groupId, fromUserId, toUserId, reqMsg, fromUserNickName, fromUserFaceUrl string) error { dbConn, err := db.DB.MysqlDB.DefaultGormDB() if err != nil { return err } toInsertInfo := GroupRequest{GroupID: groupId, FromUse...
package api import ( "encoding/json" "log" "net/http" "github.com/tlmiller/garage-door-controller/api" "github.com/tlmiller/garage-door-controller/door" ) type StatusResponse struct { Id door.Id `json:"id"` Current door.State `json:"current"` IsTriggered bool `json:"isTriggered"` Next ...
package main import ( "crypto/tls" "crypto/x509" "errors" "io/ioutil" "log" "code.cloudfoundry.org/go-envstruct" "google.golang.org/grpc/credentials" ) // Config is the configuration for a LogCache. type Config struct { Addr string `env:"ADDR, required, report"` AppSelector string `env:"APP_SELECTOR, requir...
package other import ( "sync/atomic" "testing" ) func TestAtomicAdd(t *testing.T) { var c int32 = 0 atomic.AddInt32(&c, 1) if c != 1 { t.Error("atomic not modify the origin value") } t.Logf("c is %d", c) } func TestChannel(t *testing.T) { }
package service import ( "context" "fmt" "github.com/colinrs/ffly-plus/internal/code" "github.com/colinrs/ffly-plus/internal/config" "github.com/colinrs/ffly-plus/models" "github.com/colinrs/ffly-plus/pkg/token" "github.com/gin-gonic/gin" "gorm.io/gorm" ) // UserRegisterService 管理用户注册服务 type UserRegisterSer...
// Package customer contains the business logic for customers. package customer
package stringtree_test import ( . "github.com/tomcully/stringtree-go" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("StringTreeNode", func() { Describe("Factory New", func() { It("should construct a node properly", func() { x := NewStringTreeNode('t', 2) Expect(x.Char).To(Eq...
package core import ( "testing" "bytes" "crypto/sha256" "github.com/stretchr/testify/assert" "golang.org/x/crypto/ripemd160" ) func TestNewWallet(t *testing.T) { private, public := newKeyPair() wallet := &Wallet{private, public} twallet := NewWallet(private, public) assert.Equal( t, wallet, twallet, ...
package midi import ( "fmt" "github.com/telyn/midi/msgs" ) type ChannelSplitHandler map[uint8]msgs.Handler func (csh ChannelSplitHandler) Handle(msg msgs.Message) error { if !msg.Kind.HasChannel() { return fmt.Errorf("%v messages don't have channels - a ChannelSplitHandler is a mistake", msg.Kind) } if h, ok...
package gomet import ( "time" ) // Event is the stat object that Meter sends to Collector each time Meter's Method is called. // Collector has representation of current meter state and changes it according to Event. type Event struct { Group string Worker int64 State string Time time.Time }
package main import ( "fmt" ) const ( float32_precision = 0.0000001 ) func square(num uint32, precision uint32) float32 { // get the intger var i float32 = 0 for i*i <= float32(num) { if i*i == float32(num) { return i } i = i + 1 } i = float32(i - 1) // calc the precision var multi float32 = 1 f...
package mr import ( "encoding/json" "fmt" "hash/fnv" "io/ioutil" "log" "net/rpc" "os" "sort" "time" ) // for sorting by key. type ByKey []KeyValue // for sorting by key. func (a ByKey) Len() int { return len(a) } func (a ByKey) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a ByKey) Less(i,...
package main import ( "bufio" "fmt" "math/big" "os" "strconv" ) func main() { scan := func() func() int { scan := bufio.NewScanner(os.Stdin) scan.Split(bufio.ScanWords) return func() int { scan.Scan() i, _ := strconv.Atoi(scan.Text()) return i } }() a := big.NewInt(int64(scan())) b := big.N...
package main // 文字列からint, floatへは直接変換できないのでstrconvパッケージを使う必要がある import "fmt" import "strconv" func main() { var s string = "14" i, err := strconv.Atoi(s) if err != nil { fmt.Println("err") } fmt.Printf("%T %v", i, i) }
package service import ( "bufio" "bytes" "errors" "os" "os/exec" "path/filepath" "strings" "k8s.io/utils/mount" "github.com/container-storage-interface/spec/lib/go/csi" "github.com/ovirt/csi-driver/internal/ovirt" ovirtsdk "github.com/ovirt/go-ovirt" "golang.org/x/net/context" "k8s.io/klog" ) type Node...
package config import ( "bufio" "fmt" "io" "os" "strings" ) func Parse(filename string) (*Parser, error) { p := NewParser(filename) err := p.Parse() return p, err } func NewParser(filename string) *Parser { p := &Parser{ filename: filename, Config: NewConfig(), } return p } type Parser struct { fi...
package main import ( "encoding/json" "html/template" "io/ioutil" "log" "net/http" "regexp" "strings" "github.com/go-redis/redis" ) var templates = template.Must(template.ParseFiles("templates/edit.html", "templates/view.html", "templates/index.html")) var validPath = regexp.MustCompile("^/(edit|save|view)/(...
//go:build go1.18 // +build go1.18 package toml import ( "bytes" "testing" ) func FuzzDecode(f *testing.F) { buf := make([]byte, 0, 2048) f.Add(` # This is an example TOML document which shows most of its features. # Simple key/value with a string. title = "TOML example \U0001F60A" desc = """ An example TOML ...
package main import ( "github.com/yjagdale/siem-data-producer/app" ) func main() { app.StartApp() }
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" ) // WordCloud represents a word cloud chart. type WordCloud struct { BaseConfiguration BaseActions } // Type returns the chart type. func (*WordCloud) Type...
package main import ( "fmt" "strings" ) type coords struct{ x, y int } func main() { rows := strings.Split(input, "\n") var changes []coords grid := map[coords]rune{} for y, row := range rows { for x, s := range row { grid[coords{x, y}] = s } } for k, v := range grid { if v == 'L' && !canSeeOccupi...
package main import "fmt" var d2 = [][]int{{-1, 0}, {0, 1}, {1, 0}, {0, -1}} func numIslands(grid [][]byte) int { var m = len(grid) res := 0 for i := 0; i < m; i++ { for j := 0; j < len(grid[0]); j++ { if grid[i][j] == '1' { res++ dfs3(grid, i, j) } } } return res } func dfs3(grid [][]byte, x...
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later package controllerrpc import ( "context" "fmt" "github.com/swinslow/peridot-core/internal/controller" pbc "github.com/swinslow/peridot-core/pkg/controller" ) // Start corresponds to the Start endpoint for pkg/controller. func (cs *CServer) Start(ctx con...
package main import "fmt" func main() { fmt.Println("Good morning!") }
// Package rbtree 实现了红黑树 package rbtree type Color int8 type Comparation = func(a, b interface{}) int const ( RED = itoa, BLACK ) type Node struct { data interface{} left, right, parent *Node color Color } func (n *Node) grandparent() *Node { return n.parent.parent } func (n *Node) uncle() { if } type RBTr...
// Copyright (c) 2013 The Gocov Authors. // // 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, pub...
package virgo // IService 服务接口 type IService interface { OnInit(*Procedure) OnRelease() } // Launch 启动服务 func Launch(s IService) { p := NewProcedure(s) p.Start() p.waitQuit() }
package database import "context" // ReadOnlyDB used to get database object from any database implementation. // For consistency reason both TransactionDB and ReadOnlyDB will seek database object under the context params type ReadOnlyDB interface { GetDatabase(ctx context.Context) (context.Context, error) }
package models type ArrayLine struct { Cells []string }
package auth import "context" type Interactor interface { Signup(context.Context, *User) (*Session, error) }
package main import ( "math" ) func divide(dividend int, divisor int) int { if dividend == math.MinInt32 && divisor == -1 { return math.MaxInt32 } flag := true if dividend^divisor < 0 { flag = false } if divisor > 0 { divisor = -divisor } if dividend > 0 { dividend = -dividend } res := 0 multiple ...
package rtrclient import ( "bytes" "net" "time" "github.com/cpusoft/goutil/belogs" "github.com/cpusoft/goutil/convert" "github.com/cpusoft/goutil/jsonutil" rtrserver "rpstir2-rtrserver" ) type RtrTcpClientProcessFunc struct { } func (rq *RtrTcpClientProcessFunc) ActiveSend(conn *net.TCPConn, tcpClientProcess...
package api import ( "github.com/gin-gonic/gin" db "github.com/minhphong306/mindX/db/sqlc" "net/http" ) type createLocationHistoryRequest struct { UserId int64 `json:"user_id" binding:"required"` Type int32 `json:"type" binding:"required"` LocationId int32 `json:"location_id"` ManualInput str...
package surisoc // Error is a custom error struct for the SuriSock package type Error struct { Message string } // Error gives back the error message func (e *Error) Error() string { return e.Message }
package status import ( "log" "testing" "time" "github.com/golang/mock/gomock" ) func init() { log.SetFlags(log.LstdFlags | log.Lshortfile) } func Test2FriendsJoining(t *testing.T) { incomingCh := make(chan workIn) startConsumer(incomingCh) defer close(incomingCh) ctrl := gomock.NewController(t) ClientA...
package sol func maxSubArray(nums []int) int { if len(nums) == 0 { return 0 } if len(nums) == 1 { return nums[0] } i := 0 maxNum := nums[0] partialTol := 0 for i < len(nums) { partialTol += nums[i] if partialTol > maxNum { maxNum = partialTol } if partialTol < 0 { partialTol = 0 } ...
package auth import ( "context" "net/http" "strings" ) type ExternalUser struct { AuthType string `json:"authType"` ExternalId string `json:"externalId"` Email NullString `json:"email"` Login NullString `json:"login"` Name NullString `json:"name"` } type NullString struct { Valid bool String string } ...
package toolkit import ( "strings" "testing" ) func TestConvertToSmallCamelCase(t *testing.T) { var ans = "helloWorldZhongGuo" if actual := ConvertToSmallCamelCase("hello world zhong guo"); actual != ans { t.Errorf("got %s, expected %s\n", actual, ans) } } func TestConvertToBigCamelCase(t *testing.T) { var a...
package repository import ( "arep/model" "context" ) type StoreRepository interface { UpdateStore(context.Context, string, bool) error GetStores(context.Context, []int64) (*[]model.Store, error) }
/* * @lc app=leetcode.cn id=32 lang=golang * * [32] 最长有效括号 */ // @lc code=start package main import "fmt" func longestValidParentheses(s string) int { // stack := []byte{} // maxCount := 0 // count := 0 // for i := 0 ; i < len(s) ; i++ { // if s[i] == '(' { // stack = append(stack , s[i]) // // fmt.Pr...
package main func subs(w win) [][]byte { if w.size()%2 == 0 { return evenSubs(w) } return oddSubs(w) } func evenSubs(w win) [][]byte { // L:=0: center between leftmost and second left char if w.size() == 2 { return [][]byte{ w.val(), } } return nil } func oddSubs(w win) [][]byte { if w.even { ret...
package controller import ( "github.com/labstack/echo" "net/http" ) func MainPage(e echo.Context) error{ return e.Redirect(http.StatusTemporaryRedirect,"http://52.78.172.184:8081/index.html") }
package coredb import ( "testing" "time" "github.com/graphql-go/graphql" "github.com/zhs007/ankadb" "github.com/zhs007/jarviscore/coredb/proto" "github.com/zhs007/jarviscore/crypto" ) func TestBaseFunc(t *testing.T) { //------------------------------------------------------------------------ // initial ankaD...
package common import ( "bytes" "database/sql" "errors" "fmt" "reflect" "strings" ) type Dao struct { DB *sql.DB } const ( TABLE = "DB_TABLE" COL = "DB_COL" PK = "DB_PK" ) func (_self *Dao) Insert(sql string, args ...interface{}) (int64, int64, error) { stmt, err := _self.DB.Prepare(sql) if err != ...
package accounting import ( "log" "tddbudget/repository" "time" ) // Budget 預算 type Budget struct { yearMonth string amount float64 first time.Time last time.Time } // getBudgets 取得預算 func getBudgets() (budgets []*Budget) { data := repository.GetBudgets() for yearMonth, amount := range data { ...
package main import ( "testing" ) func benchmark(b *testing.B, f func(int, string) string) { var str = randomString(10) for i := 0; i < b.N; i++ { f(10000, str) } } //BenchmarkPlusConcat //BenchmarkPlusConcat-8 14 75699414 ns/op //BenchmarkSprintfConcat //BenchmarkSprintfConcat-8 8 155...
package main import ( "strings" "testing" ) var input = []string{"hello", "bye", "asdf", "1234567890", "-1", "-2"} func echo1(args []string) string { var s, sep string for i := 0; i < len(args); i++ { s += sep + args[i] sep = " " } return s } func echo2(args []string) string { return strings.Join(args, "...
package core import ( "fmt" "time" "github.com/enriquebris/goconcurrentqueue" "github.com/reactivex/rxgo/v2" "gopkg.in/jeevatkm/go-model.v1" ) // Builder Object for EventBus type eventBusBuilder struct { mediator *mediator messaging messagingAdapter cbSettings CircuitBreakerSettings settings EventBusSe...
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan. // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ // See page 61. //!+ // Mandelbrot emits a PNG image of the Mandelbrot fractal. package main import ( "image" "image/color" "image/png" "math/cmplx" "os" ) func main() { const ( xmin, ...
package queue type Item interface{} type Interface interface { Peek() Item Enqueue(Item) Dequeue() Item Len() int }
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "github.com/julienschmidt/httprouter" "github.com/olugbokikisemiu/Meant4Task/calculate" ) func main() { router := httprouter.New() router.POST("/calculate", Index) m := calculate.NewRequestMiddleware(router) fmt.Println("Server started and ...
package main import ( "fmt" "math/rand" "time" "reflect" ) // simulate flipping a fair coin func FlipCoin() string { rand.Seed(time.Now().UnixNano()) if flipint := rand.Intn(2); flipint == 0 { return "tails" } return "heads" } // flip un...
package main import "fmt" func main(){ x := [6]float64{98,93,77,82,83} // var x [5]float64 = [5]float64{98,93,77,82,83} var total float64 = 0 for i,value := range x { total += value fmt.Println(x[i]) } fmt.Println(total/float64(len(x))) }
package slack import ( "encoding/json" "sync/atomic" "time" "github.com/pkg/errors" "github.com/valyala/fasthttp" ws "golang.org/x/net/websocket" ) // Slack URL consts const ( methodGET = "GET" methodPOST = "POST" contentEncoded = "application/x-www-form-urlencoded; charset=utf-8" contentJSON =...
package helpers import ( "encoding/json" "fmt" "io/ioutil" "os" ) // JSONConfig consists json object type JSONConfig struct { ConfigJSON map[string]interface{} } var instance *JSONConfig // GetConfig to get CloudConfig singelton session func GetConfig(filePath string, encrypted bool, encrytionFilePath ...stri...
package compiler import ( "github.com/davyxu/tabtoy/v3/model" "github.com/davyxu/tabtoy/v3/report" ) func loadVariantTables(globals *model.Globals, kvList, dataList *model.DataTableList) error { report.Log.Debugln("Loading tables...") // 遍历索引里的每一行配置 for _, pragma := range globals.IndexList { if pragma.Kind =...
package agent import ( "encoding/json" "fmt" "net/http" "github.com/bryanl/dolb/service" ) func ServiceCreateHandler(c interface{}, r *http.Request) service.Response { config := c.(*Config) defer r.Body.Close() var ereq service.ServiceCreateRequest err := json.NewDecoder(r.Body).Decode(&ereq) if err != nil...
package main import ( "fmt" "sync" "time" ) func main() { var mutex sync.Mutex cond :=sync.Cond{L:&mutex} condition :=false go func() { time.Sleep(1*time.Second) cond.L.Lock() fmt.Println("子goroutine更改条件") condition =true cond.Signal() fmt.Println("子goroutine解锁.....") cond.L.Unlock() }() cond...
package db import ( "dev-framework-go/conf" "fmt" "github.com/jinzhu/gorm" "github.com/wonderivan/logger" "strings" ) import _ "github.com/lib/pq" var DBPool *gorm.DB var err error func InitDatabasePool() { psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+ "password=%s dbname=%s sslmode=disable", conf.DB...
package datastore import ( "github.com/jinzhu/gorm" "github.com/taniwhy/mochi-match-rest/domain/models" "github.com/taniwhy/mochi-match-rest/domain/repository" ) type roomDatastore struct { db *gorm.DB } // NewRoomDatastore : UserPersistenseを生成. func NewRoomDatastore(db *gorm.DB) repository.RoomRepository { ret...
// cache package bookcache import ( "container/list" "fmt" "time" ) type Lru struct { mp map[string]*list.Element //book_id:pElement lst *list.List //type entry cap int //capacity } type entry struct { //list item key string value string } var cache *Lru = newCache(1000)...
package types import ( "bytes" "text/template" ) // Template wraps a text template for generating strings type Template struct { template.Template } // ParseTemplate creates a new template from the string func ParseTemplate(s string) (*Template, error) { t := &Template{} err := t.UnmarshalString(s) if err != n...
package tsmt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00400102 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsmt.004.001.02 Document"` Message *ActivityReportSetUpRequestV02 `xml:"ActvtyRptSetUpReq"` } func (d *Documen...
/** *@Author: haoxiongxiao *@Date: 2019/3/25 *@Description: CREATE GO FILE admin */ package admin import ( "bysj/models" "bysj/services" "github.com/kataras/iris" ) type DashBoardController struct { Ctx iris.Context Service *services.DashBoardService Common } func NewDashBoardController() *DashBoardContro...
package webdav import ( "encoding/xml" "strings" "time" ) // Allow parsing the last modified time type LastModifiedTime struct { time.Time } // Unmarshal the xml func (lmt *LastModifiedTime) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { value := "" err := d.DecodeElement(&value, &start) if err...
package keeper import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/fadeev/files/x/files/types" ) func (k Keeper) CreateClaim(ctx sdk.Context, claim types.Claim) { store := ctx.KVStore(k.storeKey) key := []byte(types.ClaimPrefix + claim.Proof) value := k.cdc.MustMar...
package models // github.com/growlog/things-server/internal/models import ( "database/sql" "fmt" // "github.com/growlog/things-server/internal/utils" ) type TimeSeriesDatum struct { Id int64 `db:"id"` TenantId int64 `db:"tenant_id"` SensorId ...