text
stringlengths
11
4.05M
/* This riddle was inspired by that thread. Consider that you are super-hacker and try to break MD5 hashing algorithm by looking for a hash collisions for a given hash string which your friend gave to you. But this is a non-trivial task and you have a migraine disorder so you try to break the problem into smaller part...
/* Create a function to check whether a given number is Cuban Prime. A cuban prime is a prime number that is a solution to one of two different specific equations involving third powers of x and y. For this challenge we are only concerned with the cuban numbers from the first equation. We ignore the cuban numbers from...
// Go support for leveled logs, analogous to https://code.google.com/p/google-glog/ // // Modifications copyright 2013 Ernest Micklei. 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 o...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //377. Combination Sum IV //Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to...
package godork import ( "bytes" "go/ast" "go/doc" "go/parser" "go/printer" "go/token" "io/ioutil" "os" "path/filepath" "sort" "strings" ) func ReadPackageFile(fset *token.FileSet, sourceFile string) (*ast.File, error) { f, err := os.Open(sourceFile) if err != nil { return nil, err } defer f.Close() ...
package asset import ( "fmt" "os" "golang.org/x/tools/godoc/vfs" ) type failFS struct { err error } func failfs(err error) vfs.FileSystem { return &failFS{fmt.Errorf("asset: %s", err.Error())} } func (fs *failFS) Open(name string) (vfs.ReadSeekCloser, error) { return nil, fs.err } func (fs *failFS) Lstat(pat...
package ot import ( "database/sql" "fmt" _ "github.com/go-sql-driver/mysql" "strings" ) const ( driverName = "mysql" user = "" pass = "" protocol = "" ip = "" port = "" dbName = "" ) func QryServe(info *AppInfo) (se *ServeInfo) { if info.hostIp == "" { fmt.Println("登录获取...
package sort import ( "testing" ) func TestQuickSort(t *testing.T) { quickSort(arr, 0, len(arr)-1) if !equals(arr, result) { t.Fail() } }
// CookieJar - A contestant's algorithm toolbox // Copyright (c) 2013 Peter Szilagyi. All rights reserved. // // CookieJar is dual licensed: use of this source code is governed by a BSD // license that can be found in the LICENSE file. Alternatively, the CookieJar // toolbox may be used in accordance with the terms and...
package main import "fmt" func main(){ // define map }
package cointop // Size returns window width and height func (ct *Cointop) Size() (int, int) { return ct.g.Size() } // Width returns window width func (ct *Cointop) Width() int { w, _ := ct.Size() return w } // Height returns window height func (ct *Cointop) Height() int { _, h := ct.Size() return h }
package loader import ( "io/ioutil" "os" "reflect" "strconv" "strings" "testing" "github.com/devspace-cloud/devspace/pkg/devspace/config/generated" "github.com/devspace-cloud/devspace/pkg/devspace/config/versions/latest" "github.com/devspace-cloud/devspace/pkg/util/fsutil" fakekubeconfig "github.com/devspac...
// Copyright (c) 2020 Xiaozhe Yao & AICAMP.CO.,LTD // // This software is released under the MIT License. // https://opensource.org/licenses/MIT package entities import ( "path/filepath" "time" "github.com/autoai-org/aid/components/cmd/pkg/storage" "github.com/autoai-org/aid/components/cmd/pkg/utilities" ) // L...
package stack import ( "github.com/stretchr/testify/assert" "testing" ) func TestNew(t *testing.T) { stack := New() assert.True(t, stack.IsEmpty()) } func TestStack_IsEmpty(t *testing.T) { stack := New() stack.Push(1) assert.False(t, stack.IsEmpty()) } func TestStack_Peek(t *testing.T) { stack := New() ...
package signals import ( "fmt" "os" "syscall" ) func CatchSig(ch chan os.Signal, done chan bool){ sig := <- ch fmt.Println("sig recieved:", sig) switch sig{ case syscall.SIGINT: fmt.Println("handling a SIGINT now!") case syscall.SIGTERM: fmt.Println("handling a SIGTERM in an entirely different way!") d...
package socket import ( "KServer/library/kiface/isocket" ) type Request struct { conn isocket.IConnection //已经和客户端建立好的 链接 msg isocket.IMessage //客户端请求的数据 } //获取请求连接信息 func (r *Request) GetConnection() isocket.IConnection { return r.conn } //获取请求消息的数据 func (r *Request) GetMessage() isocket.IMessage { return...
package server import ( "fmt" "log" "net/http" "time" ) type Client struct { startTime time.Time requestCount int } type Clients map[string]*Client var clientMap Clients func Server() { clientMap = make(Clients) log.Println("HTTP Denial-of-Service protection system listening on port 8080") http.Handle...
package files import ( "fmt" "os" "github.com/saromanov/cronview/pkg/models" ) // Write write crontab content to file func Write(s *models.Crontab) error { f, err := os.OpenFile("tmpdata", os.O_APPEND|os.O_WRONLY, 0600) if err != nil { return err } defer f.Close() for _, r := range s.Records { if _, err...
package gedcom import ( "fmt" "github.com/elliotchance/gedcom/util" "sort" "strings" "time" ) // DefaultMinimumSimilarity is a sensible value to provide to the // minimumSimilarity parameter of IndividualNodes.Similarity. // // It is quite possible that this value will change in the future if a more // accurate ...
package output type OutputConfig struct { // Addresses of stations, by callsign addresses map[int]string // Messages, by number messages map[int]string }
package main import ( "github.com/dgrijalva/jwt-go" "time" ) var ( SecretKey = "xuheng" ) type UserDetails struct { // 用户标识 UserId int64 // 用户名 唯一 Username string // 用户密码 Password string // 用户具有的权限 Authorities []string // 具备的权限 } type jwtCustomClaims struct { jwt.StandardClaims UserDetails } type Toke...
package utils import ( "context" "github.com/go-redis/redis/v8" "go.uber.org/zap" "shop-web/user-api/global" "time" ) var ( ctx = context.Background() min = time.Minute ) const CAPTCHA = "captcha:" type RedisStore struct { } func InitRedis() *redis.Client { config := global.ServerConfig.RedisInfo Redis :=...
package connection import ( "context" "crypto/rand" "crypto/rsa" "database/sql/driver" "encoding/base64" "encoding/hex" "fmt" "math/big" "os/user" "runtime" "strconv" "github.com/exasol/exasol-driver-go/internal/config" "github.com/exasol/exasol-driver-go/internal/utils" "github.com/exasol/exasol-driver...
package proxy import ( "errors" "sync" "github.com/networkservicemesh/api/pkg/api/networkservice" "github.com/nordix/meridio/pkg/ipam" "github.com/nordix/meridio/pkg/networking" "github.com/sirupsen/logrus" ) // Proxy - type Proxy struct { bridge networking.Bridge sourceBasedRoute networking.Source...
package leetcode /*Consider all the leaves of a binary tree.  From left to right order, the values of those leaves form a leaf value sequence. 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/leaf-similar-trees 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。*/ /** * Definition for a binary tree node. * type TreeNode struct ...
package main /* #cgo CFLAGS: -I ${SRCDIR}/darwin/Contents/Frameworks/Sparkle.framework #cgo LDFLAGS: -F ${SRCDIR}/darwin/Contents/Frameworks -framework Sparkle void sparkle_checkUpdates(); */ import "C" func sparkle_checkUpdates() { C.sparkle_checkUpdates() }
package maptest import ( "fmt" "testing" ) func TestMapNil(t *testing.T) { var ma map[string]string ma = nil fmt.Println(len(ma)) var u uint32 fmt.Println(u) } func TestMaGet(t *testing.T) { ma := map[string]int64{} ma["t1"] = 123 var a int64 a, _ = ma["foo"] fmt.Println(a) a, _ = ma["t1"] fmt.Printl...
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package main import ( "log" "net/http" "github.com/polzka90/jwt/authentication" ) func main() { mux := http.NewServeMux() mux.HandleFunc("/login", authentication.Login) mux.HandleFunc("/validate", authentication.ValidateToken) log.Println("Listen on http://localhost:8080") http.ListenAndServe(":8080", mux) ...
package router import ( "github.com/colinrs/ffly-plus/controller" apiV1 "github.com/colinrs/ffly-plus/controller/api/v1" "github.com/colinrs/ffly-plus/router/api" "github.com/colinrs/ffly-plus/router/middleware" //nolint: golint _ "github.com/colinrs/ffly-plus/docs" "github.com/colinrs/pkgx/server/gin" swagg...
package crawl import ( "sync" "sync/atomic" "time" . "./base" "./robot" "./robot/sina" "./store" "github.com/golang/glog" ) func LoadCategoryItem(p *CategoryItem, store store.Store) { data, err := store.LoadCategories() if err != nil { glog.Warningln("load categories err", err) } if len(data) < 1 { ...
// Copyright 2020 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 package coretypes import ( "bytes" "encoding/json" "fmt" valuetransaction "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction" "github.com/iotaledger/wasp/packages/util" "github.com/mr-tron/base58" "io" ) // RequestI...
package logs import ( "fmt" "sort" "time" "github.com/10gen/realm-cli/internal/cli" "github.com/10gen/realm-cli/internal/cli/user" "github.com/10gen/realm-cli/internal/cloud/realm" "github.com/10gen/realm-cli/internal/terminal" "github.com/10gen/realm-cli/internal/utils/flags" ) const ( dateFormat = "2006-0...
package main import ( "context" "fmt" "log" "os" "github.com/brigadecore/brigade/sdk/v3" "github.com/brigadecore/brigade/sdk/v3/restmachinery" ) func main() { ctx := context.Background() // Get the Brigade API server address and token from the environment apiServerAddress := os.Getenv("APISERVER_ADDRESS") ...
package db import ( "strings" "testing" s "github.com/thedevelopnik/netplan/pkg/models" ) func TestCreateVPC(t *testing.T) { vpc := s.VPC{ Name: "create-test-vpc", Access: "public", Location: "us-east4", Provider: "GCP", Env: "dev", CidrBlock: "192.168.0.0/16", Typ...
package resolve import ( "errors" "github.com/bitmaelum/bitmaelum-suite/pkg/address" "github.com/bitmaelum/bitmaelum-suite/pkg/bmcrypto" "github.com/bitmaelum/bitmaelum-suite/pkg/proofofwork" ) var errKeyNotFound = errors.New("hash not found") // Repository is the interface to manage address resolving type Repos...
package firewall import "github.com/stretchr/testify/mock" type MockIptablesCommand struct { mock.Mock } func (_m *MockIptablesCommand) PrependRule(port int) error { ret := _m.Called(port) var r0 error if rf, ok := ret.Get(0).(func(int) error); ok { r0 = rf(port) } else { r0 = ret.Error(0) } return r0 }...
package zbar // #cgo LDFLAGS: -lzbar // #include <stdlib.h> // #include <stdio.h> // #include <zbar.h> // #include "simplifier.h" import "C" import ( "errors" "unsafe" ) // Recognize single code from webcam func ScanSingleSymbol(device string) (result, symbol_type string, err error) { dev := C.CString(device) de...
package main import ( "fmt" "io" "log" "net/http" "sync" ) type Incrementer struct { mx sync.Mutex counter uint64 } func (i *Incrementer) String() string { i.mx.Lock() defer i.mx.Unlock() i.counter++ return fmt.Sprintf("%d", i.counter) } func main() { var inc Incrementer http.HandleFunc("/", fu...
// Copyright 2020 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
package middleware import ( "log" "net/http" ) func RecoveryHandler() func(http.Handler) http.Handler { return func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { defer func() { if err := recover(); err != nil { log.Printf("PANIC: %s", err)...
package main import ( "encoding/json" ) // Transaction type A struct type transactionA struct { Amount int `json:"amount"` Currency string `json:"currency"` StatusCode int `json:"statusCode"` OrderReference string `json:"orderReference"` TransactionID string `json:"transactionId"` } //...
package totp import ( "testing" "github.com/pquerna/otp" "github.com/stretchr/testify/assert" ) func TestOTPStringToAlgo(t *testing.T) { assert.Equal(t, otp.AlgorithmSHA1, otpStringToAlgo("SHA1")) assert.Equal(t, otp.AlgorithmSHA256, otpStringToAlgo("SHA256")) assert.Equal(t, otp.AlgorithmSHA512, otpStringToAl...
/* Copyright 2021 The KubeVela 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, softw...
package main import ( "net/http" "fmt" ) func main() { //HandleFunc 設定訪問的路由"/"並註冊 http.HandleFunc("/",func (w http.ResponseWriter, r *http.Request) { //以匿名函數func(w http.ResponseWriter, r *http.Request{}建立接收/回傳方法) fmt.Fprintf(w, "Hello World") //輸出到客戶端的訊息 }) http.ListenAndServe(":8080", nil)//設置監聽的埠 //L...
package meduza import ( "fmt" "os" "testing" "time" "github.com/EverythingMe/disposable-redis" "github.com/EverythingMe/meduza/client/resp" "github.com/EverythingMe/meduza/driver/redis" "github.com/EverythingMe/meduza/errors" "github.com/EverythingMe/meduza/protocol/bson" "github.com/EverythingMe/meduza/que...
package utils import ( "crypto/md5" "fmt" "strings" ) func Md5(txt string) string { return fmt.Sprintf("%x", md5.Sum([]byte(txt))) } func Md5Salt(txt, salt string) string { if salt == "" { salt = RandString(8) } return fmt.Sprintf("%s:%s", salt, Md5(fmt.Sprintf("%s:%s", salt, txt))) } func SplitMd5Salt(txt...
package main_test import ( "encoding/json" "fmt" "io/ioutil" "testing" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" newsfetch "github.com/michigan-com/gannett-newsfetch" c "github.com/michigan-com/gannett-newsfetch/commands" "github.com/michigan-com/gannett-newsfetch/lib" m "github.com/michigan-com/gannett-new...
// 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...
package piscine import "github.com/01-edu/z01" import "fmt" func PointOne(n *int) { *n = 1 } func UltimatePointOne(n ***int){ ***n = 1 } func DivMod(a int, b int, div *int, mod *int) { var c int var d int c = a/b d = a%b *div = c *mod = d } func UltimateDivMod(a *int, b *int) { // d := *a % *b // c :=...
// DRUNKWATER TEMPLATE(add description and prototypes) // Question Title and Description on leetcode.com // Function Declaration and Function Prototypes on leetcode.com //5. Longest Palindromic Substring //Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000...
package main import ( "encoding/json" "gopkg.in/mgo.v2" "io/ioutil" "net/http" ) // iOS Specific for now. type Device struct { Id string APNToken string SysVersion string SysName string Name string Model string } // Registers an application with the server and/or updates the necessa...
package main import ( "fmt" "time" ) func main() { //1 quit := make(chan struct{}) //2 go func() { for { //2.1 select { case <-quit: //2.1.1 fmt.Println("sub goroutine is over") return default: //2.1.2 //do something time.Sleep(time.Second) fmt.Println("sub goroutine do some...
package service // 获取所有基金当日净值情况,并写入db func Run() error { return nil }
package main import "fmt" // 343. 整数拆分 // 给定一个正整数 n,将其拆分为至少两个正整数的和,并使这些整数的乘积最大化。 返回你可以获得的最大乘积。 // 说明: 你可以假设 n 不小于 2 且不大于 58。 // https://leetcode-cn.com/problems/integer-break/ func main() { fmt.Println(integerBreak(10)) // 36=3*3*4 } // 动态规划 // dp[i]表示 i 的最大乘积 // 动态转移方程:dp[i] = getMax(j *(i-j), j*dp[j-1]) (1<=j<i) ...
package server import ( "context" "github.com/pkg/errors" "github.com/sourcegraph/ctxvfs" "github.com/sourcegraph/go-langserver/pkg/lsp" "github.com/sourcegraph/jsonrpc2" "github.com/sourcegraph/sourcegraph/pkg/api" "github.com/sourcegraph/sourcegraph/pkg/gituri" "github.com/sourcegraph/sourcegraph/xlang/vfsu...
package easyws import ( "code.google.com/p/go.net/websocket" "net/http" ) type Connection struct { ws *websocket.Conn send chan string h *Hub } type Hub struct { connections map[*Connection]bool receiver chan msginfo register chan *Connection unregister chan *Connection onjoin func(*http.R...
package xdominion /* The XOrderBy is an array of field names */ const ( ASC = "asc" DESC = "desc" ) type XOrder []XOrderBy func (o *XOrder) CreateOrder(table *XTable, DB string) string { order := "" item := 0 for _, xo := range *o { // , entre cada uno if item > 0 { order += ", " } order += xo.G...
package main import ( "testing" "github.com/arschles/sweet" ) func TestSimpleStrings(t *testing.T) { ste := sweet.New("simple tests", t) ste.AddTest(SimpleStringTest) ste.Run() }
package main import ( "flag" "log" "net/http" "net/url" ) func main() { verbose := flag.Bool("v", false, "Verbose mode true/false") flag.Parse() u, _ := url.Parse(flag.Args()[0]) if u.Scheme == "https" || u.Scheme == "http" { response, err := http.Head(u.String()) if err != nil { log.Println("Error wh...
package tsmt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00200103 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:tsmt.002.001.03 Document"` Message *ActivityReportV03 `xml:"ActvtyRpt"` } func (d *Document00200103) AddMessage() *Activit...
package db import ( "github.com/hashicorp/golang-lru" ) type LruKV struct { kv *lru.Cache } func NewLruKV(lru_size int) *LruKV { kv, _ := lru.New(lru_size) return &LruKV{kv: kv} } func NewLruPartitioning(bits, tolerance uint, lru_size int) Partitioning { return NewPartitioning(bits, tolerance, func(shift, ...
package vugudev import ( "errors" "fmt" "log" "os" "github.com/purpleidea/mgmt/recwatch" ) type event = recwatch.Event // Just to avoid dependency on recwatch in the rest of code. var errNotADir = errors.New("not a directory") func watch(dir string) (<-chan event, error) { if fi, err := os.Stat(dir); err != ...
package models import ( "github.com/gophergala2016/source/core/foundation" ) type ItemImpressionRepository struct { RootRepository } func NewItemImpressionRepository(ctx foundation.Context) *ItemImpressionRepository { return &ItemImpressionRepository{ RootRepository: NewRootRepository(ctx), } } func (r *ItemI...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2021/11/23 9:34 下午 # @File : lt_202_判断是否是快乐数_test.go.go # @Description : # @Attention : */ package v2 import ( "fmt" "testing" ) func Test_isHappyStep(t *testing.T) { f := func(v int) int { ret := 0 for v > 0 { ret += (v % 10) * (v % 10) v /= 10 } ...
package main import ( "github.com/volatiletech/sqlboiler/v4/drivers" "github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-mysql/driver" ) func main() { drivers.DriverMain(&driver.MySQLDriver{}) }
package main import ( "flag" "os" "bufio" "strings" "fmt" "log" ) func readLines(filePath, quoteS, quoteD, stringOld, stringNew, stringHost, stringAlt string) ([]string, error) { filePtr, err := os.Open(filePath) if err != nil { return nil, fmt.Errorf("failed to open a file for...
package main import "fmt" func main() { for i := 33; i < 127; i++ { s := string([]byte{byte(i)}) if s == "$" { s = "$dollar" } if s == "\"" { fmt.Printf("sub_filter '%s' \"0x%02x\";\n", s, i) } else { fmt.Printf("sub_filter \"%s\" \"0x%02x\";\n", s, i) } } }
package config import ( "os" "path/filepath" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestDownstreamMTLSSettingsGetCA(t *testing.T) { t.Parallel() fakeCACert := []byte("--- FAKE CA CERT ---") caFile := filepath.Join(t.TempDir(), "CA.pem") os.WriteFile(caFi...
package timeout import ( "bytes" "fmt" "net/http" "sync" "github.com/gin-gonic/gin" ) // Writer is a writer with memory buffer type Writer struct { gin.ResponseWriter body *bytes.Buffer headers http.Header mu sync.Mutex timeout bool wroteHeaders bool code int } // New...
package tracker import ( "github.com/sirupsen/logrus" "github.com/tc-teams/fakefinder-crawler/api" "github.com/tc-teams/fakefinder-crawler/tracker/crawler" ) func WebCrawlerNews(log *api.Logging) error { g1 := crawler.NewG1() log.WithFields(logrus.Fields{"page": crawler.StartG1,}).Debug("starting synchronizati...
package ims_api_connector import ( "encoding/json" "net/http" "strings" "time" "errors" "fmt" "io/ioutil" "net/url" "log" ) // // main object // type IMSAPIConnector struct { Username, Password, BaseURL, Key string JSONDecoder json.Decoder Authenticated bool clien...
// Copyright 2015 by caixw, All rights reserved. // Use of this source code is governed by a MIT // license that can be found in the LICENSE file. package output import ( "encoding/json" "io/ioutil" "os" "path" "path/filepath" "sort" "strings" "time" "github.com/tanxiaolong/apidoc/types" "github.com/tanxia...
package main import ( "context" "github.com/container-storage-interface/spec/lib/go/csi" ) type identityServer struct{} func newIdentityServer() *identityServer { return &identityServer{} } func (ids *identityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, ...
package rest import ( providerRestApi "code.huawei.com/cse/api/provider/rest" "code.huawei.com/cse/common" "code.huawei.com/cse/config" "code.huawei.com/cse/pkg" "code.huawei.com/cse/util" "fmt" "github.com/golang/glog" "github.com/gorilla/mux" "io/ioutil" "net/http" ) var ( Router *mux.Router ) func prox...
package response import ( "net/http" "plmg/models" u "plmg/utils" ) var DefaultHandler = func(w http.ResponseWriter, r *http.Request, itemName string) map[string]interface{} { resp := u.Message(u.SUCCESS, itemName+" has been gotten") resp["item"] = itemName return resp } var SearchHandler = func(w http.Respons...
// // Copyright 2020 The AVFS 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 ag...
/* Tencent is pleased to support the open source community by making Basic Service Configuration Platform available. Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain...
package orm import ( "errors" "fmt" "reflect" ) // t is the reflect.Type (eg. reflect.TypeOf(User{})) // or // t is the pointer's reflect.Type's element type (eg. reflect.TypeOf(&User{}).Elem()) // // type User struct { // Id int `db:"id"` // Name string `db:"name"` // } // // t := reflect.TypeOf(User{}) ...
package jq import ( "github.com/stretchr/testify/assert" "testing" ) func TestRunJqProgram(t *testing.T) { jqInst := New() defer jqInst.Close() jqInst.CompileProgram(".[] | select(.foo % 2 == 0) | .bar") results, err := jqInst.ProcessInput( `[ {"foo": 7, "bar": "helloooo"}, {"foo": 8, "bar": "world"},...
package main import ( "fmt" "io/ioutil" "log" "net/http" "os" "github.com/buger/jsonparser" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" ) func usage(program string) { fmt.Println("Usage: ", program, " [Telegram BOT token]") } func main() { if len(os.Args) != 2 { usage(...
package quacktors import ( "sync" ) var remoteMonitorQuitAbortables = make(map[string]Abortable) var remoteMonitorQuitAbortablesMu = &sync.RWMutex{} var machineId = uuidString() var pidMap = make(map[string]*Pid) var pidMapMu = &sync.RWMutex{} var systemWg = &sync.WaitGroup{} var machines = map[string]*Machine{} v...
package main import ( "fmt" "net/url" "time" "github.com/kavenegar/kavenegar-go" ) func main() { api := kavenegar.New(" your apikey ") var postalcode int64 = 141 var sender = "" var message = "" var mcistartindex = 1 var mcicount = 1 var mtnstartindex = 1 var mtncount = 1 var date = time.Now().Add(time...
package main import ( "fmt" "os" "time" "github.com/dgrijalva/jwt-go" ) func CreateToken(userid uint64, username string) (string, error) { var err error //this should be in an env file os.Setenv("ACCESS_SECRET", "jdnfksdmfksd") atClaims := jwt.MapClaims{} atClaims["authorized"] = true atClaims["user_id"] =...
package xtp_wrapper /* #cgo CFLAGS: -Wno-error=implicit-function-declaration -I../../C_porting_XTP/include/XTP -I../../C_porting_XTP/include/CXTPApi #cgo LDFLAGS: -L../../C_porting_XTP/lib/CXTPApi -lCXTPApi -lxtpquoteapi -lxtptraderapi #include <string.h> #include "xtp_cmessage.h" #include "LCxtp_quote_api.h" */ impor...
package onepage_test import ( "github.com/maprost/application/generator/genmodel" ) const ( SkillSleeping = genmodel.SkillID(iota) SkillDrinkingCoffee SkillWatchingYoutube SkillChat SkillLookingOutOfTheWindow SkillGoingInTheBathroom ) //func TestConvert(t *testing.T) { // assert := assertion.New(t) // // prof...
package paperswithcode_go import ( "fmt" "github.com/codingpot/paperswithcode-go/v2/models" "net/url" ) // PaperRepositoryList returns repositories related to the given paper. func (c *Client) PaperRepositoryList(paperID string) (*models.RepositoryList, error) { paperURL := fmt.Sprintf("%s/papers/%s/repositories"...
package populate import "github.com/knative/pkg/apis/istio/v1alpha3" type Protocol string const ( ProtocolTCP Protocol = "TCP" ProtocolUDP Protocol = "UDP" ProtocolSCTP Protocol = "SCTP" ProtocolHTTP Protocol = "HTTP" ProtocolHTTP2 Protocol = "HTTP2" ProtocolGRPC Protocol = "GRPC" ) var ( supportedPr...
package rp_kit import ( "testing" "time" ) func Test_GetTimeNow(t *testing.T) { type args struct { time2 []time.Time } time2, _ := time.Parse(DATETIME_LAYOUT, "2020-11-25 00:00:00") tests := []struct { name string args args want string }{ { name: "获取当前格式化时间", args: args{}, want: time.Now().F...
package acmt import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document02400101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:acmt.024.001.01 Document"` Message *IdentificationVerificationReportV01 `xml:"IdVrfctnRpt"` } func (d *D...
package main import ( "net/http" ) func sayHelloWorld(w http.ResponseWriter, r *http.Request) { message := "Hello world" w.Write([]byte(message)) } func main() { http.HandleFunc("/", sayHelloWorld) if err := http.ListenAndServe(":80", nil); err != nil { panic(err) } }
package auth import ( "encoding/json" "fmt" "github.com/valyala/fasthttp" "github.com/thavel/goban/models" "github.com/thavel/goban/pkg/api" "github.com/thavel/goban/pkg/crypto" "github.com/thavel/goban/pkg/database" "github.com/thavel/goban/pkg/jwt" ) func Auth(ctx *fasthttp.RequestCtx) { // Unmarshal pay...
package main import ( "fmt" "sync" "time" ) func Producer() <-chan int { out := make(chan int) go func() { defer close(out) for i := 0; i < 10; i++ { out <- i time.Sleep(200 * time.Millisecond) } }() return out } // START OMIT func Consumer(in <-chan int, wg *sync.WaitGroup) { wg.Add(1) go func...
// 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...
package action import ( "regexp" "github.com/chitoku-k/ejaculation-counter/supplier/infrastructure/client" "github.com/chitoku-k/ejaculation-counter/supplier/service" "github.com/pkg/errors" ) var ( BattleChimpoRegex = regexp.MustCompile(`お?ちん(ちん|ぽ|こ)(なん[かぞ])?に([勝か][たちつてと]|[負ま][かきくけこ])`) ) type battleChimpoShi...
package global import ( "github.com/go-redis/redis" "github.com/spf13/viper" "go.uber.org/zap" "gorm.io/gorm" "music-saas/config" ) var ( CONFIG config.Server LOG *zap.Logger DB *gorm.DB VIPER *viper.Viper REDIS *redis.Client )
package uaa import ( "fmt" "golang.org/x/oauth2" ) func Config(url, clientID, clientSecret string, scopes []string, callbackURL string) *oauth2.Config { return &oauth2.Config{ ClientID: clientID, ClientSecret: clientSecret, Scopes: scopes, Endpoint: oauth2.Endpoint{ AuthURL: fmt.Sprintf("%s/...
package checks import ( "fmt" "os" "plugins" "testing" ) var the_check = plugins.PluginConfig{ Type: "check", Command: "", Handlers: []string{}, Standalone: true, Interval: 15, } func TestExcludeProcs(t *testing.T) { var list, testList []process var testLen int list = append(list, getProc()...
package tkapi //淘宝客-公用-淘口令生成 //提供淘客生成淘口令接口,淘客提交口令内容、logo、url等参数,生成淘口令关键key如:¥SADadW¥,后续进行文案包装组装用于传播 import ( "bytes" "encoding/json" "errors" "github.com/mrxiaojie/taobaoke" ) type TpwdCreate struct { ReqParam TpwdCreateParam } //请求参数 type TpwdCreateParam struct { UserId string Text string Url string Logo ...
package main import ( "fmt" ) func main() { grading := map[string]int{"a": 90, "b": 80, "c": 70} fgrading, condition := grading["f"] if condition { fmt.Println(fgrading) } else { fmt.Println("It doesn't have this grade.") } delete(grading, "a") _, value := grading["a"] fmt.Println(value) ...