text
stringlengths
11
4.05M
package controllers import ( "jwt-api-gin/models" "jwt-api-gin/utils/token" "net/http" "github.com/gin-gonic/gin" ) func CurrentUser(c *gin.Context) { user_id, err := token.ExtractTokenID(c) if err != nil { c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) return } u, err := models.GetUserByI...
// Copyright 2019 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 "gorm.io/gorm" // 与另一个模型建立了一对多的连接。 不同于 has one,拥有者可以有零或多个关联模型。 // has one要求必须有一个关联关系,has many的关联关系可以为0 // User 有多张 CreditCard,UserID 是外键 type User struct { gorm.Model CreditCards []CreditCard } type CreditCard struct { gorm.Model Number string UserID uint }
/* Copyright 2019 The Skaffold 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, sof...
package common import ( "fmt" "strings" ) const ( BNBTicker = Ticker("BNB") RuneTicker = Ticker("RUNE") RuneA1FTicker = Ticker("RUNE-A1F") RuneB1ATicker = Ticker("RUNE-B1A") ) type ( Ticker string Tickers []Ticker ) var BTICKERS = [...]string{"BTTB", "BTCB", "MDAB", "NOIZB", "NPXB", "SPNDB", "TOMOB",...
package arithmetic // greater (>) operator. type greater struct{} func (o greater) String() string { return ">" } func (o greater) precedence() uint8 { return precedenceLowerGreater } func (o greater) solve(st *stack) (interface{}, error) { // Retreive right and left terms. right, ok := st.pop() if !ok { re...
package scanner import ( "fmt" "strconv" "github.com/lukeomalley/glocks/parsererror" "github.com/lukeomalley/glocks/token" ) // Scanner transforms the source into tokens type Scanner struct { source string start int current int line int tokens []token.Token } var keywords = map[string]token.Type{ "...
/* MIT License Copyright (c) 2018 IBM 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, publish, distribute...
package usersync import ( "encoding/base64" "encoding/json" ) type Decoder interface { // Decode takes an encoded string and decodes it into a cookie Decode(v string) *Cookie } type Base64Decoder struct{} func (d Base64Decoder) Decode(encodedValue string) *Cookie { jsonValue, err := base64.URLEncoding.DecodeSt...
package main import ( "github.com/damianopetrungaro/golang-bookshop/book" "github.com/gorilla/mux" "net/http" ) func main() { router := mux.NewRouter() book.LoadRoutes("/books", router) http.ListenAndServe(":80", router) }
package sharding_test import ( "math/rand" "testing" "time" "github.com/go-pg/sharding/v8" "github.com/go-pg/pg/v10" ) func benchmarkDB() *pg.DB { return pg.Connect(&pg.Options{ User: "postgres", Database: "postgres", DialTimeout: 30 * time.Second, ReadTimeout: 10 * time.Second, WriteT...
package cnc import ( "net/url" "os" "sort" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tizz98/comix/db" ) func CleanDatabaseTest(t *testing.T, test func(t *testing.T, database *db.Db)) { database, err := db.NewDb(os.Getenv("REDIS_ADDRESS"), 0) require.No...
package string import ( "fmt" "github.com/project-flogo/core/data/coerce" "strings" "github.com/project-flogo/core/data" "github.com/project-flogo/core/data/expression/function" ) func init() { function.Register(&fnToUpper{}) } type fnToUpper struct { } func (fnToUpper) Name() string { return "toUpper" } f...
package dcrlibwallet import ( "encoding/json" "sort" "github.com/decred/dcrd/chaincfg/chainhash" "github.com/raedahgroup/dcrlibwallet/txhelper" "github.com/raedahgroup/dcrlibwallet/txindex" ) const ( // Export constants for use in mobile apps // since gomobile excludes fields from sub packages. TxFilterAll ...
package main import "fmt" var c, python, java bool func variables() { var i int fmt.Println("[variables.go]", i, c, python, java) }
package csvindexing import ( "flamingo.me/dingo" categorydomain "flamingo.me/flamingo-commerce/v3/category/domain" productdomain "flamingo.me/flamingo-commerce/v3/product/domain" searchdomain "flamingo.me/flamingo-commerce/v3/search/domain" "flamingo.me/flamingo/v3/framework/web" commercesearchModule "flamingo....
package main import ( "encoding/json" "fmt" "log" "net/http" "os" "github.com/gorilla/mux" ) // User struct type User struct { ID string `json:"id"` FirstName string `json:"firstname"` LastName string `json:"lastname"` Age string `json:"age"` } var users []User func main() { router := mux....
package host import ( "github.com/shirou/gopsutil/host" ) // ServiceGetInfo gets the host information. func ServiceGetInfo() (*host.InfoStat, error) { return host.Info() } // ServiceGetTemperature gets the host temperature. func ServiceGetTemperature() ([]host.TemperatureStat, error) { return host.SensorsTemperat...
package main import "io" type writerCount struct { writer io.Writer counter int64 } func (w *writerCount) Write(bytes []byte) (int, error) { n, err := w.writer.Write(bytes) w.counter += int64(n) return n, err } func countingWirter(w io.Writer) (io.Writer, *int64) { wc := writerCount{w, 0} return &wc, &wc....
package http //HTTP头部,包含若干个键值对,键值对的数量和头部长度 type http_headers struct { //HTTP头部中使用的键值对 ptr map[string]string len int size int } func newHeaders() *http_headers { h := new(http_headers) h.ptr = make(map[string]string) h.len = 0 h.size = 0 return h } //添加新的key-value对到HTTP头部 func (h *http_headers) http_header...
// Copyright 2019 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 ( "bytes" "fmt" "os/exec" "strings" ) func runCommand(command ...string) error { cmd := exec.Command(command[0], command[1:]...) if output, err := cmd.CombinedOutput(); err != nil { return fmt.Errorf("failed to run command: %s\noutput:\n%s", err, output) } return nil } func runCommandSt...
package handler import "github.com/labstack/echo" type Excuse struct { Error string `json:"error"` Id string `json:"id"` Quote string `json:"quote"` } type Handler struct { } // Machines give all machines func (h *Handler) GetMachines(c echo.Context) (err error) { return nil } // Machine add one machine wit...
package test import ( "testing" "github.com/stretchr/testify/assert" ) func TestWorkspace(t *testing.T) { workspace := Workspace{ WorkspacePath: "./../workspace", } workspace.Put("test.json", []byte("foobar")) assert.Equal(t, []byte("foobar"), workspace.Get("test.json")) }
package main import ( "context" "net" "os" "github.com/jmartin82/compatip/test/grpc-server/rpc" "google.golang.org/grpc" ) type VersionService struct{} func (us *VersionService) Current(context.Context, *rpc.Empty) (*rpc.VersionMessage, error) { return &rpc.VersionMessage{ Version: "1.4.23", }, nil } func...
package iracing import ( "bytes" "encoding/json" "net/http" "strconv" "time" ) type ScheduleRes struct { Contents []Contents `json:"contents"` NumActiveRaces string `json:"num_active_races"` Status Status `json:"status"` } type Contents struct { Bannerhideat Time `json:"bannerhideat"...
/* * Quay Frontend * * This API allows you to perform many of the operations required to work with Quay repositories, users, and organizations. You can find out more at <a href=\"https://quay.io\">Quay</a>. * * API version: v1 * Contact: support@quay.io * Generated by: Swagger Codegen (https://github.com/swagger...
package msgpack import ( "bufio" "io" "reflect" "sync" "time" ) const MaxPositiveFixNum = byte(0x7f) const MinNegativeFixNum = byte(0xe0) // Code represents the first by in a msgpack element. It tell us // the data layout that follows it type Code byte const ( InvalidCode Code = 0 FixMap0 Code = 0x...
package p2p import ( "btcnetwork/common" "encoding/binary" "encoding/hex" "github.com/pkg/errors" ) type GetblocksPayload struct { Version uint32 HashCount common.VarInt HashStart [32]byte HashStop [32]byte } func (gp *GetblocksPayload) Serialize() []byte { var ret []byte var i2b4 [4]byte binary.Littl...
package main import ( "bufio" "fmt" "log" "os" "strconv" ) type Command struct { cmd string num int } func mungeData(dataStr string) Command { dataInt, err := strconv.Atoi(dataStr[1:]) if err != nil { log.Fatalf("Error converting %s to int: %v\n", dataStr[1:], err) } return Command{ cmd: string(dataSt...
// Copyright 2013 The Gorilla WebSocket 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 ( "encoding/json" "time" ) const ( MessageTypeText = iota MessageTypeBinary = iota ) type Message struct { channel ...
package main func p12926(s string, n int) string { ret := make([]rune, len(s)) off := rune(n) for i, v := range s { if 'A' <= v && v <= 'Z' { ret[i] = (v-'A'+off)%26 + 'A' } else if 'a' <= v && v <= 'z' { ret[i] = (v-'a'+off)%26 + 'a' } else { ret[i] = v } } return string(ret) }
package campain import ( "fmt" "strconv" "github.com/tapvanvn/go-chain-wrapper/entity" ) type CmdTransactionsOfBlock struct { id int BlockNumber uint64 Transactions []*entity.Transaction } func CreateCmdTransactionsOfBlock(blockNumber uint64) *CmdTransactionsOfBlock { return &CmdTransactionsOfBloc...
package structs // RosterStats hold performance information about a particular Roster. type RosterStats struct { Streak struct { Match struct { StreakScope // defined in stats.go } `json:"match,omitempty"` } `json:"streak,omitempty"` Winrate struct { Match struct { WinrateMatchScope // defined in stats....
package data import ( "errors" "gorm.io/gorm" ) type Role struct { CoreModel Name string `json:"name" gorm:"uniqueIndex;not null"` } type RoleModel struct { DB *gorm.DB } func (m RoleModel) Insert(r *Role) error { if err := m.DB.Create(r).Error; err != nil { switch { case IsDuplicateRecord(err): retur...
// 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...
/* Copyright 2014 Jiang Le Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distri...
package encoding import ( "testing" "github.com/Cloud-Foundations/golib/pkg/crypto/certmanager" ) const ( testTypedKeyPEM = `-----BEGIN EC PRIVATE KEY----- MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgXHeJ5aXDEz7zB7uS k+1WujTeYzAzBgvtpOhj2mgRJdKhRANCAAQKE5puaIhI6HbXfmDpdkUimOAlVrxC nS76isEgnr3vLchNIsWMN/94z5eM...
package cmd import ( "log" "github.com/spf13/cobra" "github.com/spf13/viper" "os" ) const description = "Sacred: Confluence Markdown Uploader" var cfg Configuration var cfgFile string // RootCmd represents the base command when called without any subcommands var RootCmd = &cobra.Command{ Use: "sacred", Short:...
package services import ( "net" "net/http" "frank/src/go/helpers/log" "frank/src/go/models" "github.com/DrmagicE/gmqtt" "github.com/DrmagicE/gmqtt/pkg/packets" ) type MqttServer struct { Server *gmqtt.Server config *models.HTTP } var defaultMqttPort = 8080 var Mqtt MqttServer func NewMqttServer(config *mo...
/* Copyright 2018 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, ...
package number import ( "github.com/project-flogo/core/data/coerce" "math/rand" "time" "github.com/project-flogo/core/data" "github.com/project-flogo/core/data/expression/function" ) func init() { _ = function.Register(&fnRandom{}) } type fnRandom struct { } func (fnRandom) Name() string { return "random" }...
package agent import ( "context" "github.com/rancher/fleet/internal/client" "github.com/rancher/fleet/internal/config" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) type ConfigOptions struct { Labels map[string]string ClientID string } func ...
package _7_last_ride func solution(n int) int { h := n / 60 m := n - (h * 60) return (h/10 + h%10) + (m/10 + m%10) }
package itunes type OperationStatus struct { COM } func (o *OperationStatus) GetTracks() (*TrackCollection, error) { ret, err := o.COM.getObjectProperty("Tracks") if err != nil { return nil, err } return &TrackCollection{*ret}, nil }
/* * Npcf_SMPolicyControl API * * Session Management Policy Control Service © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved. * * API version: 1.0.4 * Generated by: OpenAPI Generator (https://openapi-generator.tech) */ package openapi type PccRule struct { ...
package leetcode74 func searchMatrix(matrix [][]int, target int) bool { nRow := len(matrix) if nRow == 0 { return false } nCol := len(matrix[0]) low := 0 high := nRow * nCol - 1 for low <= high { mid := low + (high - low) / 2 elem := getValue(matrix, mid) if elem == target { return true } if ele...
// Copyright 2016 Attic Labs, Inc. All rights reserved. // Licensed under the Apache License, version 2.0: // http://www.apache.org/licenses/LICENSE-2.0 package types type sequenceItem interface{} type compareFn func(x int, y int) bool type sequence interface { getItem(idx int) sequenceItem seqLen() int numLeave...
package main import ( "bufio" "fmt" "log" "os" ) func columnNames(c int) (r string) { for c > 0 { c-- r = string('A'+c%26) + r c /= 26 } return r } func main() { var c int data, err := os.Open(os.Args[1]) if err != nil { log.Fatal(err) } defer data.Close() scanner := bufio.NewScanner(data) for ...
package main import ( "github.com/gorilla/mux" "log" "net/http" "strings" ) var symbols Symbols var currencies Currencies var filterCurrencies Currencies func Server() *mux.Router { r := mux.NewRouter() r.HandleFunc("/api/currencies", getCurrencies).Methods("GET", "OPTIONS") r.HandleFunc("/api/symbols", getSy...
package main import ( "encoding/json" "fmt" ) type person struct { Name string `json:"Name"` Occupation string `json:"Occupation"` Age int `json:"Age"` } func main() { s := `[{"Name":"Bob","Occupation":"IT guy","Age":27},{"Name":"Alice","Occupation":"Instagirl","Age":24}]` bs := []byte(s) peo...
package main import ( "fmt" ) // Profil type ( Profil struct { ID int Name string Age int Address string } ) func main() { profil := []Profil{ { ID: 1, Name: "Rachmad Kurniawan", Age: 26, Address: "Kembangan, Jakarta Barat", }, { ID: 2, Name: "Riski...
package domain import ( "time" ) type Article struct { ID int `gorm:"column:id;primary_key"` UserID int `gorm:"column:user_id"` Title string `gorm:"column:title"` Body string `gorm:"column:body;type:text"` CreatedAt time.Time UpdatedAt time.Time } type Articles []Article
// Package emvcode is the EMV Payment Code Encoder/Decoder for Go. package emvcode // import "go.mercari.io/go-emv-code"
// Package httpfailure groups a bunch of extra HTTP failures. // // These failures only matter in the context of processing the results // of specific experiments, e.g., whatsapp, telegram. package httpfailure var ( // UnexpectedStatusCode indicates that we re not getting // the expected (range of) HTTP status code(...
package main import ( "container/list" "fmt" ) type Node struct { Data int KeyPtr *list.Element } type LRUCache struct { Queue *list.List Items map[int]*Node Capacity int } func Constructor(capacity int) LRUCache { return LRUCache{Queue: list.New(), Items: make(map[int]*Node), Capacity: capacity} } ...
package support_archive import ( "bytes" "testing" "github.com/stretchr/testify/assert" ) func TestSupportArchiveLogger(t *testing.T) { logBuffer := bytes.Buffer{} logger := newSupportArchiveLogger(&logBuffer) logger.Info("info message") logger.Error(assert.AnError, "error message") logLines := logBuffer.S...
package strings import "fmt" func Permutation(str string) { permute(str, "") } func permute(str, prefix string) { if len(str) == 0 { fmt.Println(prefix) } for i, _ := range str { permute(str[:i] + str[i+1:], prefix + string(str[i])) } }
// 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 Routes import ( "github.com/victorneuret/WatcherUpload/server/Config" "github.com/victorneuret/WatcherUpload/server/Utils" "io" "log" "net/http" "os" "path/filepath" ) func upload(_ http.ResponseWriter, r *http.Request) { err := r.ParseMultipartForm(128 << 20) if err != nil { log.Println(err) ret...
package main import ( "context" "fmt" "os" "github.com/manhdaovan/myrpc" "github.com/manhdaovan/myrpc/example/service" ) func main() { ctx := context.Background() rconf, err := myrpc.ReceiverConfFromYamlFile("../../config/receiver.yaml") if err != nil { fmt.Fprintf(os.Stderr, "error on read receiver conf ...
package main import ( "strings" "fmt" "path/filepath" ) func main() { fmt.Println(len(strings.Split(",",","))) fmt.Println((strings.Split("",","))) newf := filepath.Join("http://api.dn-dns.gls.acadn.com:9116/idns/config/v2/platforms/nxnop061","xxx") fmt.Println(...
// Copyright 2020 The Cockroach Authors. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt. // // As of the Change Date specified in that file, in accordance with // the Business Source License, use of this software will be governed // by the Apache License, ...
package entities import ( "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/openrtb_ext" ) // PbsOrtbSeatBid is a SeatBid returned by an AdaptedBidder. // // This is distinct from the openrtb2.SeatBid so that the prebid-server ext can be passed back with typesafety. type PbsOrtbSeatBid struc...
package main import "fmt" type TreeNode struct { Val int Left *TreeNode Right *TreeNode } func indexOf(a []int, x int) int { for i, y := range a { if x == y { return i } } return -1 } func buildTree(inorder, postorder []int) *TreeNode { if len(inorder) == 0 { return nil } idx := indexOf(inorder...
package main import ( "bytes" "os" "os/exec" "strings" // "log" "regexp" "runtime" "path/filepath" // "reflect" ) type RsyncConfiguration struct { Path string `xml:"path,attr" json:"path"` Opt []string `xml:"opt" json:"opts"` } func (cfg RsyncConfiguration) Copy() RsyncConfigurat...
// Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. package telemetry import ( "context" "net" "syscall" "github.com/spacemonkeygo/monkit/v3" "github.com/zeebo/admission/v3" "github.com/zeebo/admission/v3/admproto" ) var ( mon = monkit.Package() ) // Handler is called every time a...
package main import ( "fmt" "syscall" "strconv" "encoding/binary" //"encoding/hex" "log" "time" "flag" "strings" "io/ioutil" "github.com/google/gopacket" "github.com/google/gopacket/layers" //"github.com/google/gopacket/pcap" "github.com/miekg/pcap" "mrte" ) // ------------------ // Version const P...
package settings type Settings struct { DebugMode bool ThreadCount int ConfigPath string ReportPath string Stage string }
// 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 ...
package services import ( "auth-control/configurations" "auth-control/database" appErrors "auth-control/errors" "context" "fmt" "log" "time" ) type Services struct{} type CreateTokenServiceResponse struct { Token string `json:"token"` ExpiresAt int64 `json:"expires_at"` } type CreateTokenInput struct ...
package enum import ( "fmt" "reflect" "strconv" "strings" "github.com/adamluzsi/frameless/pkg/errorkit" ) var ErrInvalid = errorkit.UserError{ ID: "enum-invalid-value", Message: "The value does not match the enumerator specification", } func ValidateStruct(v any) error { rv := reflect.ValueOf(v) if rv...
// 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 zmqutil import ( "time" zmq "github.com/pebbe/zmq4" "github.com/bitmark-inc/bitmarkd/util" "github.com/bitmark-inc/logger" ) // poin...
package usecase_test import ( "testing" "github.com/go-playground/validator" "github.com/pkg/errors" "github.com/utahta/momoclo-channel/event/eventtest" "github.com/utahta/momoclo-channel/log" "github.com/utahta/momoclo-channel/testutil" "github.com/utahta/momoclo-channel/twitter" "github.com/utahta/momoclo-c...
package core import ( "log" "strings" ) /* Activation is an interface for common "vectorized" operations involving the activation functions, F, of a neural network. Eval maps the vector x of inputs to the vector F(x) of outputs. DProd represents the update, y <- DF * y, where y is the target vector and and DF is ...
package server import ( "net/http" "time" ) const ( accessTokenCookieName = "access_token" ) func getAccessTokenCookie(r *http.Request) (*http.Cookie, error) { return r.Cookie(accessTokenCookieName) } func createAccessTokenCookie(accessToken string, expiry time.Time) *http.Cookie { return &http.Cookie{ Name:...
package service import ( "encoding/json" "gorm.io/gorm" "go.uber.org/zap" "github.com/nats-io/nats.go" "github.com/lenvendo/ig-absolut-fake-sms/service/model" ) type WorkerService struct { Gorm *gorm.DB Logger *zap.Logger } func NewWorkerService(gorm *gorm.DB, logger *zap.Logger) *WorkerService { return &...
package main import ( "bytes" "encoding/binary" "fmt" ) func main() { fmt.Printf("txottl\n") err := readTTLdb() if err != nil { panic(err) } } type delUnit struct { del Hash height uint32 } type sortableHashSlice []Hash func (d sortableHashSlice) Len() int { return len(d) } func (d sortableHashS...
package main import "fmt" func main() { var a int var b int fmt.Scan(&a) sum := 0 for i := 1; i <= a; i++ { fmt.Scan(&b) if (10 <= b) && (b < 100) && (b%8 == 0) { sum += b } } fmt.Print(sum) } // Напишите программу, которая в последовательности чисел находит сумму двузначных чисел, кратных 8. // Про...
package tree func kthSmallest(root *TreeNode, k int) int { var midTraverse func(root *TreeNode) var res []int midTraverse = func(root *TreeNode) { if root == nil { return } midTraverse(root.Left) res = append(res, root.Val) midTraverse(root.Right) } midTraverse(root) return res[k-1] }
//Package logger 日志系统,提供一个默认的控制台日志 package logger import ( "fmt" "io" "log" ) // Level 日志等级类型,用SetLevel设置日志等级 // 当大于此日志等级的日志将不会输出 // DEBUG>INFO>WARN>ERROR>NONE type Level int // NONE 无日志 const ( NONE Level = iota ERROR // ERROR 错误日志 WARN // WARN 警告日志 INFO // INFO 信息日志 DEBUG // DEB...
package ocr import ( "errors" "fmt" "image" "io" "github.com/BenLubar/dwarfocr" ) var cp437 = []rune(" ☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧...
package main import ( "fmt" "io/ioutil" "strconv" "strings" ) type cpu struct { pc int acc int } func (c *cpu) execLine(line string) { // op[0] is the instruction, op[1] is what is given to the instruction op := strings.Split(line, " ") // Number passed to the instruction num, _ := strconv.Atoi(op[1]) ...
package payserver //订单信息 type OrderInfo struct { OrderNum string Uid string CreateTime uint32 ItemId string PrepayId string //预支付交易会话标识 AppId string PartnerId string NonceSt string TimeStamp string Sign string OpenId string } //预付请求 type WechatPrepayReq struct { Appid ...
package main import ( "context" "github.com/aws/aws-lambda-go/lambda" "strings" ) type Person struct { Name struct { First string `json:"first"` Last string `json:"last"` } `json:"name"` Balance string `json:"balance"` Email st...
// Package stream of GOTOJS offers an interface to expose event or message streams. // Stream implementations just need to implement the Source interface and define a Message type // which is encodable as JSON. package stream import ( "container/list" "encoding/json" "fmt" . "github.com/sebkl/gotojs" "log" "math...
// 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 ...
// This example uses gzip but standard library // supports zlib, bz2, flat and lzw package main import ( "compress/gzip" "log" "os" ) func main() { // Create a .gz file to write to outputFile, err := os.OpenFile( "test.txt.gz", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666, ) if err != nil { log.Fatalln(err) ...
// Implement strStr(). // // Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. // // Clarification: // // What should we return when needle is an empty string? This is a great question to ask during an interview. // // For the purpose of this problem, we will retur...
package bitio import ( "reflect" "testing" ) func TestLeftShift(t *testing.T) { var tests = []struct { src []byte bits uint dst []byte }{ {[]byte{0x11, 0x22, 0x33}, 4, []byte{0x12, 0x23, 0x30}}, {[]byte{0x11, 0x22, 0x33}, 8, []byte{0x22, 0x33, 0x00}}, {[]byte{0x11, 0x22, 0x33}, 12, []byte{0x23, 0x30...
package main import ( "database/sql" //"strconv" "bytes" _ "github.com/nakagami/firebirdsql" include_path "path" //s "strings" "fmt" "io" "github.com/qiniu/iconv" mf "github.com/mixamarciv/gofncstd3000" ) type DBd struct { Name string ShortName string Path string DB *sql.DB NeedAu...
package ravendb // Note: IndexQueryBase is part of IndexQuery in index_query.go
package templater import ( "bytes" "strings" "text/template" "golang.org/x/exp/maps" "github.com/go-task/task/v3/taskfile" ) // Templater is a help struct that allow us to call "replaceX" funcs multiple // times, without having to check for error each time. The first error that // happen will be assigned to r....
// Get filepaths used throughout this program. package utils import "os" // Get the current working directory. func GetCWD() string { cwd, err := os.Getwd() CheckError("Could not get the current working directory", err) return cwd }
package gube import ( "fmt" ) func init() { registerIaaSHandler("gcp", &GCPHandler{}) } type GCPHandler struct { } type GCPInfo struct { *_IaaSInfo } var _ IaaSInfo = &GCPInfo{} func (this *GCPHandler) GetIaaSInfo(shoot Shoot) (IaaSInfo, error) { info := &GCPInfo{_IaaSInfo: NewStandardIaaSInfo(shoot)} //fmt...
package user import ( "net/http" ) func Logout(w http.ResponseWriter, r *http.Request) { session, _ := sessionStore.Get(r, sessionCookieName) session.Values["authenticated"] = false session.Save(r, w) }
package nodes func main() { } type ListNode struct { Val int Next *ListNode } /** * @param head: the first node of linked list. * @return: An integer */ func countNodes(head *ListNode) int { tmp := head count := 0 for tmp != nil { count++ tmp = tmp.Next } return count } func countNodesWorseEdition(h...
package crawler import "go.mongodb.org/mongo-driver/bson/primitive" /* Creation Time: 2020 - Jan - 28 Created by: (ehsan) Maintainers: 1. Ehsan N. Moosa (E2) Auditor: Ehsan N. Moosa (E2) Copyright Ronak Software Group 2018 */ // easyjson:json type SearchRequest struct { RequestID string `json...
package model type BaseOrg struct { OrgId int `json:"org_id"` OrgName string `json:"org_name"` } func (m *BaseOrg) TableName() string { return "base_org" }
package handler import ( "database/sql" "encoding/json" "fmt" "github.com/ysugimoto/husky" ) type RssCategory struct { Id int `json:"id"` Name string `json:"name"` } func AddRssCategory(d *husky.Dispatcher) { db := husky.NewDb(GetDSN()) req := d.Input.GetRequest() req.ParseForm() category := req.For...