text
stringlengths
11
4.05M
package main import ( "fmt" "time" "github.com/rmadamanchi/go-terminal/terminal" ) func main() { for i := 0; i < 100; i++ { fmt.Print(i) fmt.Println("%") fmt.Print(i + 1) fmt.Print("%") time.Sleep(100 * time.Millisecond) if i != 99 { terminal.CursorUp(1) terminal.CursorLeft(100) } } }
package queries import ( "log" "github.com/jmoiron/sqlx" "gitlab.com/semestr-6/projekt-grupowy/backend/obsluga-formularzy/categories/models" "gitlab.com/semestr-6/projekt-grupowy/backend/obsluga-formularzy/configuration" ) const GET_CATEGORY_ID_SQL = ` SELECT q."CategoryId"; ,q."CategoryNamePl" FROM catego...
package scale import ( "strings" ) var sharps = []string{"A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"} var flats = []string{"A", "Bb", "B", "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab"} var tonicSharps = []string{"C", "G", "f#", "a", "A"} var tonicFlats = []string{"F", "bb", "Eb", "g", "d", "D...
package main import ( "encoding/json" "fmt" "log" "os" "runtime" "strings" "sync" nats "github.com/nats-io/nats.go" ) type Item struct { ItemID string `json:"ID"` Name string `json:"name"` Qty float32 `json:"qty"` Status string `json:"status"` Location string `json:"location"` } type J...
package montecarlo import ( "fmt" "testing" log "github.com/Sirupsen/logrus" assert "github.com/stretchr/testify/assert" ) /*-------- TEST INPUTS & SETUP --------*/ var tree1, tree2, tree3 Tree var possibleActions map[Key]Action type treeTestBoolVector struct { A bool B bool RESULT bool } //examp...
package tests import ( "github.com/unio-framework/go" "testing" ) func TestStringArrayContainsIsValid(t *testing.T) { group := []string{"one", "two"} got := unio.Utils.ArrayContains(group, "one") result(t, true, got) } func TestStringArrayContainsIsInvalid(t *testing.T) { group := []string{"one", "two"} got :...
package lxdpkg import ( "fmt" "github.com/lxc/lxd/client" "github.com/lxc/lxd/shared/api" ) func Connect() (container lxd.ContainerServer) { container, err := lxd.ConnectLXDUnix("", nil) if err != nil { fmt.Println(err) } return container } func Status(name string, container lxd.ContainerServer) *api.Conta...
package operation import "strconv" var multiplyBenchmarkThreshold = 2500 // Multiply takes a matrix of string elements and return the multiplication of all elements as a string. func Multiply(intMatrix [][]int) string { // analyses the matrix size to choose the algorithm with most performance based on a benchmark t...
package crypto import "github.com/sinoz/gokira/buffer" const ( GoldenRatio int = -1640531527 Rounds int = 32 ) func EncipherXTEA(buf *buffer.HeapByteBuffer, keySet [4]int) error { quadCount := buf.Capacity() / 8 for quad := 0; quad < quadCount; quad++ { var sum = 0 v0, readV0Err := buf.ReadUInt32At(qua...
package lua import ( "sort" lua "github.com/yuin/gopher-lua" ) func preloadSort(state *lua.LState) int { mod := state.NewTable() state.SetFuncs(mod, map[string]lua.LGFunction{ "strings": sortStrings, }) state.Push(mod) return 1 } func sortStrings(state *lua.LState) int { strs := []string{} unsorted := st...
package main import ( "fmt" "log" "github.com/dghubble/go-twitter/twitter" "github.com/dghubble/oauth1" "github.com/think-divergent/twitter-fish-cannon/server" "github.com/urfave/cli" ) func main() { app := cli.NewApp() app.Flags = []cli.Flag{ cli.IntFlag{Name: "port, p", Usage: "port to listen on", Value:...
package main import ( "fmt" "log" "net/http" "github.com/julienschmidt/httprouter" "github.com/lycam-dev/lycamplus-go-sdk/lycamplus" ) // // constant // const ( // AppKey . AppKey = "488ITUGN1G" // AppSecret . AppSecret = "z1oyx55jNQEXeRUu1iltfINZegWuGx" // MasterSecret . MasterSecret = "9O1MZJ5UJwnuZky...
package main import ( "fmt" "math" ) func myAtoi(str string) int { sgn := 1 num := 0 numBegun := false numDigs := 0 for i := 0; i < len(str); i++ { if numBegun && (str[i] < '0' || str[i] > '9') { break } if str[i] == ' ' { continue } if str[i] == '-' { sgn = -1 numBegun = true cont...
package informartionAllSum import ( "fmt" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" )
package unet import ( "fmt" "sync/atomic" "testing" "defs" "fdops" . "inet" "log" ) const NBYTES = 1024 const VAL = 1 const VAL1 = 2 func doClnt(clnt fdops.Fdops_i, sa []uint8, t *testing.T) { p, ip := unSaddr(sa) log.Printf("accepted clnt (%s,%d)\n", Ip2str(ip), p) data := make([]uint8, NBYTES) ub := mk...
package store type StoreDriver interface { Get(key string) interface{} Set(key string, value interface{}) Delete(key string) Exist(key string) bool Range(callback func(string, interface{}) bool) }
package objs import ( "sync" ) const ( User = 1 << iota UnknownLeve2 UnknownLeve3 UnknownLeve4 UnknownLeve5 UnknownLeve6 UnknownLeve7 UnknownLeve8 Observer // 256 Administrator // 512 Superman // 1024 ) type ByteSize float64 const ( _ = iota // ignore first value by assi...
package main import "fmt" func main() { // Assing strings with "" // stringd are unicode book := "Book name" fmt.Println(book) fmt.Println(len(book)) fmt.Printf("book[0] = %v (type %T)\n", book[0], book[0]) // uint8 is a byte in go // Strings in go ar immutable // book[0] = 116 // Slice (start, end), 0 ...
/* 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 ( "flag" "fmt" "os" "time" "github.com/andywow/golang-lessons/lesson1/ntpclient" ) const ( timeFormat = "2006-01-02T15:04:05-0700" ) var ( serverAddress = flag.String("server.address", "ru.pool.ntp.org", "Address of NTP server") queryTimeout = flag.Int("query.timeout", 30, "Query timeou...
package user import ( "context" "encoding/json" "net/http" ) type ( service interface { Register(ctx context.Context, user *User) error } Handler struct { srv service } ) func NewHandler(srv service) *Handler { return &Handler{ srv: srv, } } func (h *Handler) Register(w http.ResponseWriter, r *http....
package v1 import ( "github.com/gin-gonic/gin" "gin-vue-admin/model/response" ) // @Tags Base // @Summary 用户登录 // @Produce application/json // @Param data body request.Login true "用户名, 密码, 验证码" // @Success 200 {string} string "{"success":true,"data":{},"msg":"登陆成功"}" // @Router /test/testT [post] func TestT...
// Package validate contains validation utilities for installer types. package validate import ( "crypto/x509" "encoding/json" "encoding/pem" "errors" "fmt" "net" "net/url" "regexp" "strings" uuid "github.com/google/uuid" "golang.org/x/crypto/ssh" k8serrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/a...
/* Copyright 2022. 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 writ...
package cmd import ( "fmt" "io/ioutil" "os" "path/filepath" "time" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/config" "github.com/go-git/go-git/v5/plumbing/object" "github.com/spf13/cobra" "kpas/tpl" ) // repoCmd represents the repo command var repoCmd = &cobra.Command{ Use: "repo", Sh...
package gfuns import ( "cloud.google.com/go/storage" "context" "fmt" "google.golang.org/api/iterator" "io" "log" "os" "time" ) func GenerateUrl(bucket, key string) (string, error) { return storage.SignedURL(bucket, key, &storage.SignedURLOptions{ GoogleAccessID: os.Getenv("GoogleAccessID"), PrivateKey: ...
/***************************************************************** * Copyright©,2020-2022, email: 279197148@qq.com * Version: 1.0.0 * @Author: yangtxiang * @Date: 2020-08-20 11:45 * Description: *****************************************************************/ package pdl type TFileNodeType int8 const ( // 数据类型节点 ...
package endpoints import ( "context" "net/http" "github.com/go-kit/kit/endpoint" kithttp "github.com/go-kit/kit/transport/http" "github.com/sumelms/microservice-course/internal/course/domain" ) type listCourseResponse struct { Courses []findCourseResponse `json:"courses"` } func NewListCourseHandler(s domain...
package auto_updater import ( "texas_real_foods/pkg/connectors" ) type ListBusinessResponse struct { HTTPCode int `json:"http_code"` Data []connectors.BusinessMetadata `json:"data"` }
// 当前程序的包名 package main // 导入其它的包 import "fmt" // 常量的定义 const PI = 3.14 // 全局变量的声明与赋值 var name = "xiangqian" // 一般类型声明 type newType int // 结构的声明 type gopher struct{} // 接口的声明 type golang interface{} // 由 main 函数作为程序入口点启动 func main() { fmt.Println("Hello world!你好,世界!") }
package utils import ( "GO-DUC/helpers" "encoding/json" "io/ioutil" "log" "net/http" "os" ) //UpdateIP Sends GET request to NO-IP based on intrgration requirements. https://www.noip.com/integrate/request func UpdateIP(newip string) { client := &http.Client{} jsonFile, _ := os.Open(helpers.GetExePath() + "\\DU...
package main // Graph is a struct type Graph struct { nodes []*Node friend map[Node][]*Node enemy map[Node][]*Node } // Node is a struct type Node struct { value string } // NewNode Add a node to graph func (g *Graph) NewNode(name string) *Node { if g.NodeExists(name) { return g.GetNode(name) } n := Node{...
package hex import ( "encoding/hex" "errors" "fmt" "math" "math/bits" "strconv" "strings" "sync/atomic" "unicode" ) const hextable_l = "0123456789abcdef" const hextable_u = "0123456789ABCDEF" var ( lowercase = uint32(1) empty = errors.New("Empty string") ) func OutputLowerCase(enabled bool) { if enable...
package fourchan import ( "encoding/json" "fmt" "io/ioutil" "net/http" "time" ) type Thread struct { Board *Board Id int Topic *Post Replies []*Post OmittedPosts int OmittedImages int WantUpdate bool LastModified time.Time LastReplyId int Expired bool } //...
package response type Stats struct { Statistic []Stat `json:"statistic"` } type Stat struct { TotalIn float32 `json:"total_in,string,omitempty"` TotalOut float32 `json:"total_out,string,omitempty"` Currency string `json:"currency,omitempty"` }
package merge import ( "testing" "gotest.tools/assert" ) func TestMerge(t *testing.T) { set1 := make(Values) set2 := make(Values) //Test data with strings set1["set1Exclusive"] = "set1Exclusive" set2["set2Exclusive"] = "set2Exclusive" set1["sameKeyDifferentVal"] = "set1Val" set2["sameKeyDifferentVal"] = ...
package lib import ( "github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcutil" "github.com/tyler-smith/go-bip32" ) type Key struct { path string bip32Key *bip32.Key } func (k *Key) Encode(compress bool) (wif, address, segwitBech3...
package runner // import "fmt" import "model" import "network" type NetworkRunner struct { networkAccessor network.NetworkAccessor messageReceiver <-chan model.SendMessageRequest chFromLink <-chan model.LinkReceiveResult chToLink chan<- model.SendPacketRequest } func (runner *NetworkRunner) Run() { ...
// Copyright 2023 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...
/* A number/string is a palindrome if the digits/characters are the same when read both forward and backward. Examples include "racecar" and 12321. Given a positive number n, check if n or the binary representation of n is palindromic. Return the following: "Decimal only." if only n is a palindrome. "Binary o...
package main import ( "fmt" prompt "github.com/c-bata/go-prompt" ) func completer(in prompt.Document) []prompt.Suggest { s := []prompt.Suggest{ {Text: "users", Description: "Store the username and age"}, {Text: "articles", Description: "Store the article text posted by user"}, {Text: "comments", Description...
package operation import ( "log" "strings" "github.com/google/go-github/github" ) const ( STATUS_LABEL_PREFIX string = "S-" LABEL_AWAITING_REVIEW string = "S-awaiting-review" LABEL_AWAITING_MERGE string = "S-awaiting-merge" LABEL_NEEDS_REBASE string = "S-needs-reb...
package main func main() { //标识符命名规则 /* 1、允许使用字母 数字 下划线 2、不允许使用go系统关键 3、不允许使用数字开头 4、区分大小写 5、见名知义 */ //大驼峰命名 //RoleLv //小驼峰命名 //roleLv //linux命名 //role_lv }
package clock import "fmt" const minutesInDay int = 24 * 60 type clock struct { minutes int } func (c clock) String() string { h, m := hourAndMin(c) return fmt.Sprintf("%02d:%02d", h, m) } func (c clock) Add(m int) clock { m = (c.minutes + m) % minutesInDay if m < 0 { m += minutesInDay } return clock{m} }...
package osutil import ( "io/ioutil" "os" "testing" "github.com/stretchr/testify/assert" ) func TestCopyFile(t *testing.T) { src := "copy.go" dst := "copy.go.tmp" assert.NoError(t, CopyFile(src, dst)) s, err := ioutil.ReadFile(src) assert.NoError(t, err) d, err := ioutil.ReadFile(dst) assert.NoError(t, ...
package LeetCode func TwoSum(nums []int, target int) []int { mapping := make(map[int]int) for i := 0; i< len(nums); i++ { v,ok := mapping[ target-nums[i] ] if ok { return []int{v,i} } mapping[ nums[i] ] = i } return []int{0,0} }
package main import ( "fmt" "unicode/utf8" ) // 字符串 /* 使用 range for 遍历字符串。 range 返回一个 rune (在 byte 数组中)的位置,以及 rune 本身。上面的程序输出为: */ //func printCharsAndBytes(s string) { // for index, rune := range s { // fmt.Printf("%c starts at byte %d\n", rune, index) // } //} // // //func main() { // name := "Señor" // pri...
package mqtt import ( "context" "fmt" "github.com/pkg/errors" "github.com/batchcorp/plumber-schemas/build/go/protos/opts" "github.com/batchcorp/plumber-schemas/build/go/protos/records" "github.com/batchcorp/plumber/util" "github.com/batchcorp/plumber/validate" ) func (m *MQTT) Write(ctx context.Context, wri...
package watcher import ( "strconv" "strings" ) type FileData struct { Values [][2]float64 `json:"values"` } func parseFile(b []byte) *FileData { stringifiedFile := string(b) res := &FileData{Values: make([][2]float64, 0)} rows := strings.Split(stringifiedFile, "\r\n") for i, row := range rows { if i == 0 |...
package main import ( "log" "sync" "gosearch/pkg/crawler" "gosearch/pkg/crawler/spider" "gosearch/pkg/engine" "gosearch/pkg/index/inverted" "gosearch/pkg/netsrv" ) type Gosearch struct { crawler crawler.Interface engine *engine.Service } func (g *Gosearch) ScanAsync(urls []string, depth int) { dataCh, er...
package main import ( "fmt" "math/rand" "time" ) type CellularAutomata struct { Effect currentGeneration []bool nextGeneration []bool ledVs []float64 secsPerGenPar float64 delta float64 generationChange time.Time } func NewCellularAutomata(newDisp Display, cg ColorGenerator)...
package drivers import ( "fmt" "net/http" "github.com/mitchdennett/flameframework/encrypt" ) type SessionCookieDriver struct { w http.ResponseWriter r *http.Request } func (s *SessionCookieDriver) SetRequest(req *http.Request) { s.r = req } func (s *SessionCookieDriver) SetResponse(w http.ResponseWriter) { ...
package mcproto const ( MC_BYTE = iota MC_UBYTE MC_SHORT MC_USHORT MC_INT MC_LONG MC_FLOAT MC_DOUBLE MC_ABSINT MC_STRING MC_BOOL MC_METADATA MC_BYTEARRAY MC_UBYTEARRAY MC_INTARRAY MC_MBCARRAY MC_OBJECTDATA MC_SLOT MC_SLOTARRAY MC_ZIPCHUNK ...
package consensus import ( "net/http" "time" ) // Handler grabs the get param ?next= and tries // to transition to the state contained there func Handler(w http.ResponseWriter, r *http.Request) { r.ParseForm() state := r.FormValue("next") for address, raft := range rafts { if address != raft.Leader() { cont...
package day5 import ( "strconv" "strings" ) type Stack[T any] []T func Push[T any](slice []T, item T) []T { return append(slice, item) } func Pop[T any](slice []T) (T, []T) { return slice[len(slice)-1], slice[:len(slice)-1] } func Reverse[S ~[]E, E any](s S) { for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {...
package main import ( "bytes" "encoding/json" "errors" "io/ioutil" "net/http" "net/url" "os" "strings" "time" "github.com/sirupsen/logrus" ) func main() { logger := logrus.New() clientID := os.Getenv("OATHKEEPER_GH_DEMO_CLIENT_ID") if clientID == "" { logger.Fatal("OATHKEEPER_GH_DEMO_CLIENT_ID is req...
package generate const CACHE_SERVICE_TEMPLATE = `package no.fint.consumer.models.{{ modelPkg .Package }}{{ ToLower .Name }}; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import lombok.extern.sl...
package main import ( "bytes" "fmt" "io" "github.com/gocarina/gocsv" ) type Book struct { Name string `csv:"name"` Isbn string `csv:"isbn"` } type User struct { Name string `csv:"name"` Age int `csv:"age"` } type Counter interface { // this function should return a function that takes struct as argume...
package lycamplus import ( "testing" "github.com/lycam-dev/lycamplus-go-sdk/lycamplus/lib" ) func init() { lib.InitKey("488ITUGN1G", "z1oyx55jNQEXeRUu1iltfINZegWuGx", "9O1MZJ5UJwnuZky3tUBiZFPAlDJNs2") } func TestCreateUser(t *testing.T) { userInstance := NewUser() userRequestModel := UserRequestModel{UserName:...
package migrations import ( "database/sql" "encoding/json" "fmt" "io/ioutil" "os" "path" "testing" "time" "github.com/textileio/go-textile/keypair" ) const testPeerID = "QmQA7swSsZKoayPHaTPgzZ1u3SCQjLvLyKcN6RRMmTbLau" func initAt005(db *sql.DB, pin string) error { // Only need the Identity stub... config...
package wif import ( // Vendor "crypto/ecdsa" "crypto/rand" "github.com/btcsuite/btcd/btcec" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcutil" base58 "github.com/btcsuite/btcutil/base58" "github.com/pkg/errors" ) // Decode can be used to turn WIF into a raw private key (32 bytes). func Decod...
package providers import ( "github.com/bbcloudGroup/gothic/di" "gothic-app/boot/console" ) func RegisterConsole(container di.Container) { container.Register(console.NewPrinter) }
package db import bolt "go.etcd.io/bbolt" // Tx represents a BoltDB transaction type Tx struct { *bolt.Tx } // Vacation retrieves a Vacation from the database with the given userId. func (tx *Tx) Vacation(userId []byte) (*Vacation, error) { vacation := &Vacation{ Tx: tx, UserId: userId, } return vacation, v...
package utils import ( "Open_IM/pkg/utils" "path/filepath" "runtime" "testing" "github.com/stretchr/testify/assert" ) var ( _, b, _, _ = runtime.Caller(0) // Root folder of this project Root = filepath.Join(filepath.Dir(b), "../..") ) func Test_GenSmallImage(t *testing.T) { println(Root) err := utils.GenS...
package auth import ( "encoding/xml" "github.com/thought-machine/finance-messaging/iso20022" ) type Document00200101 struct { XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:auth.002.001.01 Document"` Message *InformationRequestResponseV01 `xml:"InfReqRspn"` } func (d *Document002001...
/* You are to write a program which generates random integers between 0 and 99 inclusive, outputting each integer in turn, until 0 is generated. You may choose which single-order random distribution (uniform, binomial, Poisson etc.) you use so long as each integer has a non-zero chance of being generated and is chosen...
package fileview import ( "fmt" "github.com/scjalliance/drivestream/commit" "github.com/scjalliance/drivestream/resource" ) // NotFound reports that a view of a file could not be found within the // repository for the requested drive and commit. type NotFound struct { File resource.ID Drive resource.ID Comm...
package main import ( "bytes" "crypto/md5" "encoding/hex" "io" "io/ioutil" "mime/multipart" "net/http" "net/http/httptest" "os" "testing" "github.com/boltdb/bolt" ) func TestUploadHandlerBasic(t *testing.T) { pwd, err := os.Getwd() if err != nil { t.Errorf("Unable to get current working directory: %s"...
// +build darwin package direct /* #cgo LDFLAGS: -framework CoreFoundation -framework CoreGraphics -framework CoreServices -framework IOKit -framework IOSurface -framework Carbon #define XK_BackSpace 0xFF08 // back space, back char #define XK_Tab 0xFF09 #define XK_Return 0xFF0D // Return, enter #define XK_Pause ...
package frida_go import ( "context" "errors" "fmt" jsoniter "github.com/json-iterator/go" "runtime" "testing" "time" ) func TestGC(t *testing.T) { go func() { dm := DeviceManager_Create() d, err := dm.FindDeviceByType(DeviceType_USB, 1000) if err != nil { t.Fatal(err) } if d==nil{ t.Fatal(erro...
package sort import "fmt" func QuickSortCode() { s := []int{23, 42, 35, 10, 33} QuickSort(s, 0, len(s)-1) fmt.Println(s) } func QuickSort(s []int, start int, end int) { if start < end { p := pivot(s, start, end) QuickSort(s, start, p-1) QuickSort(s, p+1, end) } } func pivot(s []int, start int, end in...
package user import ( "strings" ) // Session is the CLI profile session type Session struct { AccessToken string RefreshToken string } // Credentials are the user credentials type Credentials struct { PublicAPIKey string PrivateAPIKey string } // RedactedPrivateAPIKey returns the user's private API key with ...
package adapters import ( "os/exec" "github.com/vmware-tanzu-labs/git-story/usecases" ) type Browser struct{} func (browser Browser) OpenURL(url string) (*exec.Cmd, error) { cmd := exec.Command("open", url) error := cmd.Start() return cmd, error } func NewBrowser() usecases.Browser { return &Browser{} }
package mysql import ( "fmt" "github.com/jinzhu/gorm" "github.com/jmoiron/sqlx" "github.com/smilga/analyzer/api" ) type ServiceStore struct { DB *gorm.DB } func (s *ServiceStore) Save(p *api.Service) error { err := s.DB.Create(p).Error if err != nil { return err } err = s.updateServiceFeatures(p.ID, p.F...
package _530_Minimum_Absolute_Difference_in_BST import "testing" func TestGetMinimumDifference(t *testing.T) { var ( root *TreeNode ret int ) root = &TreeNode{Val: 1, Left: &TreeNode{Val: 0}, Right: &TreeNode{Val: 48, Left: &TreeNode{Val: 12}, Right: &TreeNode{Val: 49}}} if ret = getMinimumDifference(root); ...
package main import ( "net/http" "github.com/gorilla/mux" gomail "gopkg.in/gomail.v2" ) func mainPage(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, "static/index.html") } func setRoutes(r *mux.Router) { r.HandleFunc("/", mainPage) r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", ...
/* Copyright (c) 2017-2019 Jason Ish * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of condi...
package models import ( "strings" "testing" ) func TestDependencyDeclarationValidateNames(t *testing.T) { cases := []struct { name string input DependencyDeclaration isOK, isError bool errContains string }{ { "valid", DependencyDeclaration{ Direct: []RepoConfigDependency{ ...
/* 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 distributed under the License ...
package aws import ( "encoding/json" "fmt" "io/ioutil" "os" "github.com/adhocteam/soapbox/proto" "github.com/pkg/errors" ) type s3ConfigurationStore struct { s3 *s3storage bucket string kms *kmsClient } func newS3ConfigurationStore(s3 *s3storage, bucket string, kms *kmsClient) *s3ConfigurationStore...
package main import ( "fmt" "log" "net/http" "os" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/playground" "github.com/jinzhu/gorm" Config "github.com/renancrc99/1sti.challenge.backend/config" _ "github.com/go-sql-driver/mysql" "github.com/renancrc99/1sti.challenge.bac...
// This file exists just so `go install ./...` does not complain that this // directory contains "no buildable Go source files". package functional_tests
package main import ( // "crypto/tls" "encoding/json" "github.com/robfig/cron" "net/url" // "gopkg.in/gomail.v2" "io/ioutil" "log" "math" "net/http" "os" "strconv" ) // Oil 油价 type Oil struct { Prov string `json:"prov"` P90 string `json:"p90"` P0 string `json:"p0"` P95 string `json:"p95"` P97 str...
package user import ( "time" "wx-gin-master/models" "wx-gin-master/models/product" "wx-gin-master/pkg/logging" ) type Cart struct { ID int `gorm:"primary_key" json:"id"` UserId int `json:"user_id"` // 用户id PId int `json:"p_id"` // 商品主键 OId int `json:"o_id"` // 订单主键 Number int `json:"number"` ...
package admin import ( "managIncident/models" "strconv" "github.com/astaxie/beego" "github.com/astaxie/beego/orm" ) func (this *AdminController) RegisterDemand() { flash := beego.ReadFromRequest(&this.Controller) if _, ok := flash.Data["notice"]; ok { } badgeCount(this) o := orm.NewOrm() o.Using("defaul...
package main import ( "bufio" "context" "flag" "fmt" "io" "log" "net" "os/exec" "strconv" "sync" "time" "github.com/golang/protobuf/ptypes" "github.com/slugalisk/shell/proto/go" "google.golang.org/grpc" "google.golang.org/grpc/credentials" ) var certPath string var host string var port int var reconn...
package fuse import ( "bytes" "encoding/binary" "fmt" "log" "os" "strings" "sync" "syscall" "time" ) // TODO make generic option setting. const ( // bufSize should be a power of two to minimize lossage in // BufferPool. bufSize = (1 << 16) maxRead = bufSize - PAGESIZE ) type Empty interface{} /////////...
package webhandlers import ( "log" "net/http" "github.com/json-iterator/go" "github.com/gosom/context-spell-correct/pkg/spellcorrect" ) type Result struct { Query string Suggestions []spellcorrect.Suggestion } func GetSuggestions(sc *spellcorrect.SpellCorrector) http.HandlerFunc { return func(w http.R...
package wrappers import ( "net/http" "strconv" "time" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" ) const ( labelStatusCode = "code" labelMethod = "method" labelHost = "host" labelRoute = "route" ) type Metrics struct { ReqTotal...
/* Boolean logic is something all programmers have to deal with, whether we like it or not. Why not automate the task to make it easier? Your objective, if you choose to accept it, is to make a boolean logic calculator that can parse boolean logic statements. Given: | = or * = and ^ = xor ! = not Take input of 1s a...
// Catrina Lafleur // CMPT 315 Assignment 1 // Student response system (back end) // Due: Tuesday Feb 6, 2018 // // Connects to the database and handles the HTTP requests package main import ( "bufio" "bytes" "fmt" "math/rand" "net/http" "os" "strconv" "strings" "time" "github.com/jmoiron/sqlx" "github...
package db import ( "context" "log" "github.com/doniacld/outdoorsight/internal/db/core" "github.com/doniacld/outdoorsight/internal/spot" "github.com/pkg/errors" ) // DB is the database interface // All the accesses to the database are hidden here type DB interface { // Manage spot AddSpot(ctx context.Context...
package main import ( "encoding/json" "fmt" "io/ioutil" "log" "math/rand" "net/http" "os" "text/template" "time" ) var path = "data.json" type RAW struct { Status struct { Water int `json:"water"` Wind int `json:"wind"` } `json:"status"` } func write() { for { var file, err = os.OpenFile(path, os...
package launchpad import ( "gitlab.com/gomidi/midi" "gitlab.com/gomidi/midi/midimessage/channel" "gitlab.com/gomidi/midi/reader" ) func (l *LaunchpadMK2) listen() error { rd := reader.New( reader.NoLogger(), // write every message to the out port reader.Each(l.handleMidiMessage), ) if !l.inputStream.IsOp...
/* Task Write a program/function that when given a positive integer n and a digit d which is not 0 outputs a way to represent n using only addition, subtraction, multiplication, exponentiation, division, concatenation, parenthesis and the digit d. Examples n = 6, d = 1 => (1 + 1) * (1 + 1 + 1) n = 6, d = 1 => 1...
package goxtremio import ( "fmt" "testing" ) func TestGetSnapshotByID(*testing.T) { snapshot, err := c.GetSnapshot("25", "") if err != nil { panic(err) } fmt.Println(fmt.Sprintf("%+v", snapshot)) } func TestGetSnapshotByName(*testing.T) { snapshot, err := c.GetSnapshot("", "ubuntu-vol4.snap.06022015-09:58"...
package unio type( Config struct {} Middleware struct {} Search struct {} Util struct {} ) //noinspection GoUnusedGlobalVariable var Configs = Config{} //noinspection GoUnusedGlobalVariable var Middlewares = Middleware{} //noinspection GoUnusedGlobalVariable var Utils = Util{} //noinspec...
// Copyright 2020 PingCAP, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
package main import ( "crypto/rand" "crypto/rsa" "crypto/x509" "encoding/base64" "encoding/pem" "errors" "fmt" "os" ) func mmain() { //rsa 密钥文件产生 GenRsaKey(1024) } //RSA公钥私钥产生 func GenRsaKey(bits int) error { // 生成私钥文件 privateKey, err := rsa.GenerateKey(rand.Reader, bits) if err != nil { return err }...
package osbuild2 type AnacondaStageOptions struct { // Kickstart modules to enable KickstartModules []string `json:"kickstart-modules"` } func (AnacondaStageOptions) isStageOptions() {} // Configure basic aspects of the Anaconda installer func NewAnacondaStage(options *AnacondaStageOptions) *Stage { return &Stage...