text
stringlengths
11
4.05M
package main import ( "os" "github.com/ExploratoryEngineering/reto/pkg/commands" "github.com/ExploratoryEngineering/reto/pkg/toolbox" "github.com/alecthomas/kong" ) func main() { /*defer func() { // The Kong parser panics when there's a sole dash in the argument list // I'm not sure if this is a bug or a fe...
package contract // SenderChecker is an interface representing the ability to perform two main functions: sending sms and tracking them. // Tracking here means the ability to poll SMSC gateway periodically. // // Both gosmsc.HttpSenderChecker and gosmsc/rpcservice/client.Client implement it, so it is easy to // use th...
package main import ( "github.com/gorilla/mux" "net/http" ) func panicIfError(err error) { if err != nil { panic(err) } } func main() { db := getDb() defer db.Close() r := mux.NewRouter() // r.HandleFunc("/", IndexHandler) r.HandleFunc("/signup", dbHandler(SignupHandler, db)).Methods("POST") r.HandleFun...
package network import ( "bytes" "crypto/sha256" "encoding/hex" "encoding/json" "eos-network/crypto" "errors" "fmt" "math" "strconv" "strings" "time" ) var TypeParseSize = struct { BoolSize int ByteSize int Int8Size int UInt16Size int Int16Size int UInt3...
package imagga type response struct { Results []*resultEntry `json:"results"` } type resultEntry struct { Image string `json:"image"` Tags []*resultEntryTag `json:"tags"` } type resultEntryTag struct { Confidence float64 `json:"confidence"` Tag string `json:"tag"` } type resultFile struct {...
package processAvaatechSpe type LinePair struct { Name string Energy float64 } // Source for Energies: Kaye and Laby, Table of Physical and Chemical Constants // var primary_lineList = []LinePair{ LinePair{Name: "Al_Ka", Energy: 1.487}, LinePair{Name: "Si_Ka", Energy: 1.740}, LinePair{Name: "Rh_La", Energy: 2....
package main import ( "errors" "fmt" ) // our choice of 2 presidents const ( PresidentBush = iota PresidentClinton ) type President interface { GetType() int Speech() string } type Bush struct{} type Clinton struct{} func (president Bush) GetType() int { return PresidentBush } func...
package tokenize import ( "unicode" "unicode/utf8" "github.com/AlasdairF/Deaccent" "github.com/AlasdairF/Custom" ) // AllInOne normalizes UTF8, remove accents, converts special chars, lowercases, split hypens, removes contractions, and delivers only a-z0-9 tokens to a function parameter. func AllInOne(b []byte, ...
package main import ( "fmt" ) const ( _MAX_COUNT = 'A' b = iota c = 'B' d = iota ) const ( e = iota ) func main() { fmt.Println(_MAX_COUNT) fmt.Println(b) fmt.Println(c) fmt.Println(d) fmt.Println(e) fmt.Println("=====================") fmt.Println(1 ^ 2) fmt.Println(1 << 10...
/* * Licensed to the OpenSkywalking under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The OpenSkywalking licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use...
package main import ( "github.com/gorilla/mux" sdk "github.com/identityOrg/oidcsdk" config2 "github.com/identityOrg/oidcsdk/example/config" "github.com/identityOrg/oidcsdk/example/demosession" "github.com/identityOrg/oidcsdk/example/memdbstore" "github.com/identityOrg/oidcsdk/example/pages" "github.com/identity...
package bitraq import "fmt" func ExampleBIT() { type arg struct { com, s, t, x int } args := []arg{ {0, 1, 2, 1}, {0, 2, 3, 2}, {0, 3, 3, 3}, {com: 1, s: 1, t: 2}, {com: 1, s: 2, t: 3}, } n, q := 3, 5 bit := NewBIT(n) for i := 0; i < q; i++ { com := args[i].com switch com { case 0: s, t, ...
/** @description:go-sidecar @author: Angels lose their hair @date: 2021/5/16 @version:v1 **/ package registercenter type Instance struct { InstanceId string `json:"instanceId"` HostName string `json:"hostName"` App string ...
package log_test import ( "bufio" "fmt" "io/ioutil" "net/http" "os" "testing" "time" log "." ) func TestLogger(t *testing.T) { fmt.Println("Running TestLogger...") // Create a logger that logs to Stdout logger := log.New(os.Stdout, log.LOG_LEVEL_DEBUG) // Print some log messages and they should appear ...
package main import ( "encoding/json" "fmt" "io" "log" "net/http" "os" "github.com/SebastiaanKlippert/go-wkhtmltopdf" ) func Index(w http.ResponseWriter, r *http.Request) { data := map[string]interface{}{ "greetings": "Hi, Welcome to PDF generator", } w.Header().Set("Content-Type", "application/json") w...
package mergefields import ( "fmt" "strconv" "strings" mailchimp "github.com/beeker1121/mailchimp-go" "github.com/beeker1121/mailchimp-go/query" ) // FieldType defines the type of field asked for type FieldType string // String implements the string interface for FieldType func (ft *FieldType) String() string ...
package google import ( "fmt" "strings" "unicode" "github.com/Jeffail/gabs/v2" "github.com/pkg/errors" log "github.com/sirupsen/logrus" ) type responsePair struct { input string output string } func cleanResponseText(s string) string { // Remove trailing whitespace s = strings.TrimRightFunc(s, unicode.Is...
package main import "fmt" // 72. 编辑距离 // 给你两个单词 word1 和 word2,请你计算出将 word1 转换成 word2 所使用的最少操作数 。 // 你可以对一个单词进行如下三种操作: // 插入一个字符 // 删除一个字符 // 替换一个字符 // https://leetcode-cn.com/problems/edit-distance/ func main() { fmt.Println(minDistance2("horse", "ros")) // 3 } // 法一:动态规划 // 莱文斯坦距离(Levenshtein distance)...
package access import ( "github.com/kumahq/kuma/pkg/core/user" ) type GenerateDataplaneTokenAccess interface { ValidateGenerate(name string, mesh string, tags map[string][]string, tokenType string, user user.User) error }
package sonarcloud import ( "encoding/json" "errors" "fmt" "io/ioutil" "log" "net/http" "os" "strings" "testing" ) var testClient SonarCloudClient var fakeClient SonarCloudClient var badServer http.Server func TestMain(t *testing.T) { var token string // Get token so we can run tests envVar := os.Getenv(...
/* # -*- coding: utf-8 -*- # @Author : joker # @Time : 2020-08-18 15:14 # @File : of_剑指_Offer_24_反转链表.go # @Description : # @Attention : */ package offer func reverseList(head *ListNode) *ListNode { var prev *ListNode cur := head for nil != cur { next := cur.Next cur.Next = prev prev = cur cur = next } ...
// Copyright 2018 Andrew Bates // // 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 wri...
package lib import "flag" type ParamSet struct { Operator *string Count *int Range *int Operand *int } func ParseParameter() ParamSet { var params ParamSet params.Operator = flag.String("o", "+", "Operator") params.Count = flag.Int("c", 20, "Count") params.Range = flag.Int("r", 20, "Range") params.Op...
package util const ( //HeaderSize size of the header of the file layout HeaderSize = 157 //CPFEnd latest index of CPF column in the file CPFEnd = 19 //PrivateEnd latest index of Private column in the file PrivateEnd = CPFEnd + 12 //IncompletoEnd latest index of Incompleto column in the file IncompletoEnd = ...
package sse import ( "net/http" "sync" ) type Server struct { connections []Connection lock sync.Mutex } func (s *Server) subscribe(c Connection) { s.lock.Lock() s.connections = append(s.connections, c) s.lock.Unlock() } func (s *Server) unsubscribe(c Connection) { s.lock.Lock() for i, cur_conn := r...
package utils import ( "testing" "fmt" "strings" ) func TestCaptchaUtil_Generate(t *testing.T) { c:=new(CaptchaUtil) fmt.Println(c.Generate(4)) } func TestCaptcha_equal(t *testing.T){ fmt.Println(strings.EqualFold("AQ2w","aq2w")) fmt.Println(strings.EqualFold("AQ2w","Cq2w")) }
// Copyright 2020 Red Hat, Inc. and/or its affiliates // // 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 applic...
package docsonnet import ( "encoding/json" "fmt" "io/ioutil" "log" "github.com/google/go-jsonnet" "github.com/markbates/pkger" ) type Opts struct { JPath []string } // Load extracts and transforms the docsonnet data in `filename`, returning the // top level docsonnet package. func Load(filename string, opts ...
package boom import ( "context" "fmt" "strconv" "strings" "testing" "go.mercari.io/datastore/v2" "go.mercari.io/datastore/v2/internal/testutils" ) var _ datastore.PropertyTranslator = UserID(0) var _ datastore.PropertyTranslator = DataID(0) var _ datastore.PropertyTranslator = WithAncestorID("") var _ datasto...
package 整数问题 import ( "fmt" "sort" ) /* 如果一个整数上的每一位数字与其相邻位上的数字的绝对差都是 1,那么这个数就是一个「步进数」。 给你两个整数,low 和 high,请你找出在 [low, high] 范围内的所有步进数,并返回 排序后 的结果。 */ // 外部变量 + 回溯解法 var sequence []int func countSteppingNumbers(low int, high int) []int { sequence = make([]int, 0) // 枚举,从第一位为 1 开始枚举到第一位为 9 for i := 1; i <= 9; i+...
package handler import ( "html/template" "net/http" "github.com/Surafeljava/Court-Case-Management-System/reportUse" ) type ReportHandler struct { tmpl *template.Template repServ reportUse.ReportService } func NewReportHandler(T *template.Template, rs reportUse.ReportService) *ReportHandler { return &Report...
package calcsal import "fmt" //SalaryCalculator interface to implement salary operations type SalaryCalculator interface { CalculatorSalary() int getEmpID() int } //Permanent employees salary struct type Permanent struct { EmpID int BasicPayment int Pf int } //Contract employees salary struct ...
package minedive import ( "context" crand "crypto/rand" b64 "encoding/base64" "encoding/hex" "encoding/json" "fmt" "log" "sync" "time" "github.com/pion/webrtc/v3" "golang.org/x/crypto/nacl/box" "golang.org/x/crypto/nacl/secretbox" "nhooyr.io/websocket" "nhooyr.io/websocket/wsjson" ) type Client struct ...
// Package controllerrpc is the gRPC server and endpoints that act // as an interface between external callers and the main peridot controller. // It relies on calling the functions exported by the Controller in its // rpcaccess file. // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later package controllerrpc imp...
package atomic import ( "reflect" "sync" "testing" ) func TestNewOrdinal(t *testing.T) { tests := []struct { name string want *Ordinal }{ {"base-case", &Ordinal{once: &sync.Once{}}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := NewOrdinal(); !reflect.DeepEqual(got, tt.w...
package main import ( "fmt" "net/http" "os" "strconv" "time" "github.com/gin-gonic/gin" ) func main() { gin.SetMode(gin.ReleaseMode) router := gin.New() router.GET("/ping", func(c *gin.Context) { c.JSON(200, gin.H{ "message": "pong", }) }) type Login struct { User string `form:"user" json:...
package user import ( "time" "yj-app/app/yjgframe/db" ) type Entity struct { UserId int64 `json:"user_id" xorm:"not null pk autoincr comment('用户ID') BIGINT(20)"` DeptId int64 `json:"dept_id" xorm:"comment('部门ID') BIGINT(20)"` LoginName string `json:"login_name" xorm:"not null comment('登录账号...
package gobot import ( "fmt" "golang.org/x/net/html" "net/http" ) func outline(stack []string, n *html.Node) { if n.Type == html.ElementNode { stack = append(stack, n.Data) fmt.Println(stack) } for c := n.FirstChild; c != nil; c = c.NextSibling { outline(stack, c) } } func visit(links []string, n *html....
package omise type SearchScope string const UnspecifiedScope SearchScope = "" // other scopes are generated by gen_search_job
package washoe import ( "encoding/csv" "encoding/json" "os" "testing" ) var exampleAddress = &Address{ Full: "12 S PATTERSON PL", Number: 12, Street: "PATTERSON", Zip: 89436, Latitude: 39.632746, Longitude: -119.717986, } func TestAutoAddressId(t *testing.T) { // The variable testFile is...
package main import "fmt" import "math/rand" import "time" func main() { s := make([]int, 10) InitData(s) fmt.Printf("排序前:cap(s) = %d,len(s)=%d,s = %d\n", cap(s), len(s), s) bubbleSort(s) fmt.Printf("\n 排序后:cap(s) = %d,len(s)=%d,s = %d\n", cap(s), len(s), s) // oldcap := cap(s) // for i := 0; i < 20; i...
// 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 views import ( "bytes" "crypto/sha512" "crypto/subtle" "encoding/hex" "fmt" "io" "io/ioutil" "log" "net/http" "os" "path/filepath" "regexp" "strings" "github.com/rafaelmartins/distfiles/internal/settings" "github.com/rafaelmartins/distfiles/internal/tarfile" ) var ( reSha512 = regexp.MustComp...
package main import ( "fmt" //"strconv" ) func main() { l := 10 r := 12 addedI := 0 addedJ := 0 count := 0 //temp := "" //testMap := make(map[string]int) //var test []int for i := l; i <= r; i++ { addedI = adddigits(i) //fmt.Println(added) for j := i + 1; j <= r; j++ { addedJ = adddigits(j) ...
package http import ( "time" "github.com/b2wdigital/goignite/pkg/config" ) type Options struct { MaxIdleConnPerHost int `config:"maxidleconnperhost"` MaxIdleConn int `config:"maxidleconn"` MaxConnsPerHost int `config:"maxconnsperhost"` IdleConnTimeout time...
package telemetry import ( "errors" "fmt" "testing" "github.com/10gen/realm-cli/internal/utils/test/assert" ) func TestMode(t *testing.T) { for _, tc := range []Mode{ // add all modes here ModeOn, ModeEmpty, ModeStdout, ModeOff, } { t.Run(fmt.Sprintf("%s should be valid", tc), func(t *testing.T) { ...
package main import ( "KServer/library/utils" proto2 "KServer/proto" "KServer/server/utils/msg" pd3 "KServer/server/utils/pd" "fmt" "log" "net/url" "os" "os/signal" // "strconv" "time" "github.com/gorilla/websocket" ) var proto utils.Protobuf var max = 10 func main() { interrupt := make(chan os.Sign...
package riakpbc type Client struct { cluster []string pool *Pool Coder *Coder // Coder for (un)marshalling data logging bool closed chan struct{} } // NewClient accepts a slice of node address strings and returns a Client object. // // Illegally addressed nodes will be rejected in the NewPool call. func Ne...
package proto import ( "github.com/odpf/stencil/models" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protodesc" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" "google.golang.org/protobuf/types/descriptorpb" ) // Snapshot represents ...
/* * Copyright © 2018-2022 Software AG, Darmstadt, Germany and/or its licensors * * SPDX-License-Identifier: Apache-2.0 * * 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://...
package logging import ( "sync" "go.uber.org/zap/zapcore" ) // MemoryLogger integrates as a zap Logger hook which retains the last set of // logs. // // MemoryLogger's fields may not be adjusted after it has been installed as a // hook. // // Internally, MemoryLogger uses a ring buffer. type MemoryLogger struct { ...
package util import ( "../worker" "fmt" "os" "os/exec" "path/filepath" "strings" ) type Config struct { Rootdir string Workers []*worker.Worker } func NormalizePath(path string) (string, string) { clean_path := filepath.Clean(path) full_path, _ := filepath.Abs(clean_path) return filepath.Base(full_path), ...
// Copyright 2019 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...
/* In mathematics, matrix multiplication or the matrix product is a binary operation that produces a matrix from two matrices. The definition is motivated by linear equations and linear transformations on vectors, which have numerous applications in applied mathematics, physics, and engineering. In more detail, if A i...
// TODO: move to different package package app import ( "fmt" ) type ErrorType string type ErrorHandler interface { Handle(err error) } type TypedError struct { Message string Type ErrorType } const ( UndefinedError ErrorType = "undefined_error" RequiredParamNotFound ErrorType = "required_par...
// Copyright 2018 Amazon.com, Inc. or its affiliates. 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. A copy of the // License is located at // // http://aws.amazon.com/apache2.0/ // // or in the "license"...
package log import ( "io" "strings" ) var registeredFileSystems = map[string]FileSystem{} type FileSystem interface { Open(path string, args map[string]string) (writer io.Writer, err error) } func RegisterFileSystem(name string, fs FileSystem) { if fs != nil { registeredFileSystems[strings.ToLower(name)] = fs...
package open_im_sdk import ( "encoding/json" "fmt" X "log" "os" "runtime" "time" ) var loggerf *X.Logger func init() { loggerf = X.New(os.Stdout, "", X.Llongfile|X.Ltime|X.Ldate) } type TestSendImg struct { } func (TestSendImg) OnSuccess(data string) { fmt.Println("testSendImg, OnSuccess, output: ", data) ...
package util import "testing" func TestIsNil(t *testing.T) { var c Cat var a Animal = c t.Log(IsNil(a)) } func TestIsNilFixed(t *testing.T) { t.Log(IsNilFixed(1)) } func TestIsNilBetter(t *testing.T) { var d *Dog //var a Animal = c t.Log(IsNilBetter(d)) }
package rest import ( "boiler/pkg/errors" "encoding/json" "fmt" "net/http" "github.com/rs/zerolog/log" ) type ErrResponse struct { Error struct { Codes []string `json:"codes"` Msg string `json:"msg"` } `json:"error"` } type DefaultResp struct{} // Fail writes the JSON error message // if ?debug is s...
package venom import ( "context" "fmt" "testing" "github.com/stretchr/testify/assert" "gopkg.in/yaml.v2" ) func TestProcessVariableAssignments(t *testing.T) { InitTestLogger(t) assign := AssignStep{} assign.Assignments = make(map[string]Assignment) assign.Assignments["assignVar"] = Assignment{ From: "here...
/* When you convert a fraction to a decimal number and you want to store that number, you often have to round it, because you only want to use a certain amount of memory. Let's say you can only store 5 decimal digits, then 5/3 becomes 1.6667. If you can store only 2 decimal digits it will be 1.7 (now assuming that it ...
package command const ( ProjectConfigGetterPath = "project.config_getter" ProjectConfigGlobalPath = "project.config_global" ProjectConfigMakePath = "project.config_make" ProjectConfigInitPath = "project.config_init" ProjectConfigMergePath = "project.config_merge" ProjectConfigSubsetPath = ...
package main import "net/http" import "strings" import "fmt" type handler http.HandlerFunc func hello70(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") fmt.Fprintln(w, "Hello canonical world") } // 包裹主域名 func wrapCanonicalHost(f handler, chost string) handler { ret...
// Copyright 2019 The OpenSDS Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); you may // not use this file except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agre...
package users import ( "encoding/json" "github.com/gin-gonic/gin" log "github.com/golang/glog" "go-restapi/models" "go-restapi/repository" "go-restapi/repository/commons" "go-restapi/services" "io/ioutil" ) func serializeParam(ctx *gin.Context) (models.RegisterUserInput, error) { body := ctx.Request.Body va...
package rest import ( "net/http" "github.com/brigadecore/brigade/v2/apiserver/internal/api" "github.com/brigadecore/brigade/v2/apiserver/internal/lib/restmachinery" "github.com/gorilla/mux" ) type AuthnEndpoints struct { AuthFilter restmachinery.Filter Service api.PrincipalsService } func (a *AuthnEndpoint...
package signup import ( "net/http" "time" "github.com/gin-gonic/gin" "github.com/jinzhu/gorm" "github.com/lcsphantom/savenote-server/api" "github.com/lcsphantom/savenote-server/db" ) // Register is responsable for the user signup process func Register(context *gin.Context) { // Get database data := db.GetDb...
package converter import ( "os" "os/exec" "strings" "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/johnwyles/vrddt-reboot/pkg/config" ) // ffmpeg holds the information relating to the FFmpeg executable type ffmpeg struct { Path string log *zerolog.Logger } // FFmpeg sets up an FFmpeg conv...
package main import ( "fmt" "strconv" ) //part 1 func apply_rules(value string) bool { digits := len(value) == 6 adjacent := false ascending := true prev := 0 for _, char := range value { curr := int(char - '0') if prev != 0 { if prev > curr { ascending = false break } if prev == curr { ...
package main import "fmt" type Person interface{ Name() } type T struct { name int } func (t *T) Name(){ fmt.Println("132") } func ffff() Person { var t *T return t } func defer1(n int)(t int){ t = n defer func(t int){ t += 3 }(t) return 3 } func main(){ fmt.Println(defer1(2)) var t *T t.Name()...
package cli import "context" type Client interface { Call(ctx context.Context, args []string) (string, error) }
package controllers import ( "BitcoinWeb/models/RPC" "github.com/astaxie/beego" ) type BitcoinToolController struct { beego.Controller } func (c *BitcoinToolController) Get(){ c.Data["List"] = RPC.RPC_COMMIT c.TplName = "Ahead.html" }
package base import ( "encoding/binary" "hash/fnv" "math/rand" ) type State struct { nodes map[Address]Node addresses []Address blockLists map[Address][]Address Network []Message Depth int isDropOff bool isDuplicate bool // inheritance Prev *State Event Event // auxiliary information...
package treeset import ( "github.com/hnnyzyf/go-stl/container/value" "testing" ) func Test_Iterator(t *testing.T) { a := []int{9, 2, 3, 4, 5, 1, 7, 8, 6} res := []value.Int{1, 2, 3, 4, 5, 6, 7, 8, 9} set := New() for i := range a { set.Insert(value.Int((a[i]))) } j := 0 for i := set.Begin(); i.LessEqual(...
package cerebro type NLU struct { BestIntent string Intents []Intent Entities []Entity Text string } type Intent struct { Label string Score float32 } type Entity struct { Label string Text string }
package main import "fmt" type person struct { name string age int gender string } type dove interface { gugugu() } type repeater interface { repeat(string) } type lemon interface{ sour(string) } type smellgood interface { regret() } func (p *person) repeat(word string) { fmt.Println(word) } func (p *...
package main import ( "strings" "sync" "github.com/jonas-p/go-shp" ) // BuildFeatures indexes a shape file into provided data structure func BuildFeatures(filename *string) (*FeatureCollection, error) { features := make([]*Feature, 0) shape, err := shp.OpenZip(*filename) featureChan := make(chan *Feature) don...
package main import ( "fmt" ) func main() { fmt.Println("Hello, World!") fmt.Printf("\n 0x1B[1;40;32m note 0x1B[0m\n\n") }
package core import ( "github.com/streadway/amqp" "log" "msgevent/util" ) // 初始化amqp func AmqpInit() (*amqp.Connection, *amqp.Channel, error) { url := AmqpURL("config/config.yml"); conn, err := amqp.Dial(url) if err != nil { util.LogOnError(err) return nil, nil, err } channel, err := conn.Channel() i...
package helpers import ( "context" "log" "time" "github.com/dgrijalva/jwt-go" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "github.com/AskJag07/virtuoso-server/config" "github.com/AskJag07/vir...
// The logging package is a wrapper around github.com/sirupsen/logrus that provides some // convenience methods and improved error reporting. package logging import ( "io" "os" "github.com/sirupsen/logrus" "github.com/square/p2/pkg/util" ) // processCounter is a singleton instance of the counter, so that all me...
package types import ( "strconv" ) type IntTuple struct { X, Y int } type Vector struct { From, To IntTuple } func MakeRange(min int, max int) []int { res := make([]int, max-min) for i := range res { res[i] = min + i } return res } func Permutations(a []int, b []int) []IntTuple { var permuts []IntTuple ...
package domain import ( "context" "errors" "time" ) var ( ErrCharityMrysNotFound = errors.New("CharityMrys not found") ) type CharityMrysID string func (a CharityMrysID) String() string { return string(a) } type CharityMrys struct { Id CharityMrysID `json:"id" example:"1"` Name string ...
package handlers import ( "encoding/json" "fmt" "github.com/ConsumerAffairs/mailer-log/models" "github.com/gorilla/context" "github.com/julienschmidt/httprouter" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" "log" "net/http" "net/url" "strconv" ) type ( MailController struct { session *mgo.Session } ) // R...
package main import ( "fmt" ) func main() { fmt.Println("ttime - cross-platform cli time tracker") }
package btcdcommander import ( "code.google.com/p/go.net/websocket" "crypto/tls" "crypto/x509" "encoding/base64" "encoding/json" "errors" "fmt" "github.com/conformal/btcjson" "github.com/conformal/btcwire" "github.com/conformal/btcws" "github.com/conformal/go-socks" "io/ioutil" "time" ) // ErrBtcdDisconn...
// mcsi lib helps you get info for minecraft servers for your project package mcsi_lib import ( "encoding/json" "fmt" "net/http" ) type Status struct { Online bool `json:"online,omitempty"` Ip string `json:"ip,omitempty"` Port int `json:"port,omitempty"` Debug DebugInfo `json:"...
package account import ( "testing" // goblin . "github.com/franela/goblin" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/sqlite" ) func Test_AccountService(t *testing.T) { g := Goblin(t) var acct *AccountService var db *gorm.DB g.Describe("Service: Account", func() { g.Before(func() { d...
package service import ( "fmt" "reflect" "time" grpcService "github.com/go-ocf/cloud/grpc-gateway/service" "github.com/go-ocf/kit/security/certManager" "gopkg.in/yaml.v2" ) // Config represent application configuration type Config struct { Address string `envconfig:"ADDRESS" default...
package main import ( "fmt" ) func passByValue(val int) { val++ } func passByPointer(val *int) { (*val)++ } func main() { i := 1 fmt.Println("i: ", i) passByValue(i) fmt.Println("i: ", i) passByPointer(&i) fmt.Println("i: ", i) }
package slowmath import ( "encoding/json" "fmt" "github.com/stretchr/testify/require" "os" "testing" ) func TestSqrtMany(t *testing.T) { var testCases = []struct { val float64 expected float64 shouldErr bool }{ {2.0, 1.4142, false}, {0, 0, false}, {-1, 0, true}, } for _, tc := range testC...
package main import ( "testing" ) func TestPass(t *testing.T) { tables := []struct { a string n bool }{ {"111111",true}, {"223450",false}, {"123789",false}, } for _, table := range tables { res := passOk(table.a) if res != table.n { t.Errorf("Password %s does not meet criteria.", table.a) }...
/* * Copyright 2018, CS Systemes d'Information, http://www.c-s.fr * * 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 requir...
package builder import ( "context" "github.com/MintegralTech/juno/index" "time" ) type BuildInfo struct { TotalNumber int64 `json:"total_num"` ErrorNumber int64 `json:"error_num"` AddNum int64 `json:"add_num,"` DeleteNum int64 `json:"delete_num...
package main import ( "fmt" "runtime" ) func GOMAXPROCS() int { return runtime.GOMAXPROCS(900) } func main() { fmt.Printf("GOMAXPROCS running in this process are %d", GOMAXPROCS()) }
/* Copyright 2015 Crunchy Data Solutions, 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...
// The expression is a function and it can be assigned to a variable package main import "fmt" func main() { // A func expression f := func() { fmt.Println("This is a func expression") } f() // A func expression with parameters g := func(x int) { fmt.Println("The year big brother started watching:", x) ...
// Package libvirt contains libvirt-specific structures for // installer configuration and management. package libvirt // Name is the name for the libvirt platform. const Name string = "libvirt"
package main import ( "github.com/stretchr/testify/assert" "go-mid/services" "net/http" "net/http/httptest" "testing" ) func TestClientPing(t *testing.T) { s := services.CreateService() r := services.CreateRouter(s) //r.Run() w := httptest.NewRecorder() req, _ := http.NewRequest("GET", "/ping", nil) r.Ser...