text
stringlengths
11
4.05M
package utils import ( "bytes" "encoding/hex" "fmt" "github.com/maoxs2/go-bech32" "reflect" "testing" ) func TestSerializeNumber(t *testing.T) { if !bytes.Equal(SerializeNumber(100), []byte{0x01, 0x64}) { fmt.Println(SerializeNumber(100)) t.Fail() } if hex.EncodeToString(SerializeNumber(1<<31-1)) != "04...
package utils import ( "golang.org/x/sys/windows/registry" "log" "os" "time" ) func CheckRegister(){ duration := uint64(80*24*60*60) //90days now:=uint64(time.Now().Unix()) // 创建:指定路径的项 // 路径:HKEY_CURRENT_USER\Software\Hello Go key, exists, _ := registry.CreateKey(registry.CURRENT_USER, `SOFTWARE\GoAuthor`,...
// Copyright 2021 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package cpu import ( "context" "time" "github.com/shirou/gopsutil/v3/cpu" "chromiumos/tast/errors" "chromiumos/tast/testing" ) // timesStat returns utilization stats...
package main import ( "./lib/gonumgen" "fmt" ) func main() { // main fmt.Printf("go-numgen testapp.") }
// Copyright 2020 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package firmware import ( "context" "chromiumos/tast/common/servo" "chromiumos/tast/remote/dutfs" "chromiumos/tast/remote/firmware/fingerprint" "chromiumos/tast/remote...
package main import "magicTGArchive/internal/pkg/api" func main() { api.SetupRoutes() }
package forms import ( . "launchpad.net/gocheck" "testing" ) func Test(t *testing.T) { TestingT(t) } type FormSuite struct{} var _ = Suite(&FormSuite{}) type WidgetForm struct { *DefaultForm Foo, Bar *StringField Baz, Quux *IntField } func (form *WidgetForm) CleanQuux(f FormField) error { field := f.(*IntF...
package validators import ( "net/mail" "github.com/labstack/echo" "net/http" "fmt" "github.com/MetalRex101/auth-server/app/models" "time" ) type EmailValidator struct { Base *Validator } func (ev *EmailValidator) ValidateEmail (addr string) error { _, err := mail.ParseAddress(addr) if err != nil { return ...
package failsafe import ( "context" "errors" ) var ( ErrContextCancelled = errors.New("context cancelled") ) type Failsafe struct { retryPolicy *RetryPolicy } func New(retryPolicy *RetryPolicy) *Failsafe { return &Failsafe{ retryPolicy: retryPolicy, } } func (f *Failsafe) Run(ctx context.Context, attempt f...
package main import ( "fmt" ) func main() { fmt.Printf("String %s", "Pablo") fmt.Println() fmt.Printf("Float %.2f", 5.3555555) fmt.Println() fmt.Printf("Integer %d", 10) fmt.Println() fmt.Printf("Bool %t", true) fmt.Println() fmt.Printf("Automatico %v", 35.1212) fmt.Println() fmt.Printf("Como en el codig...
// Copyright 2022 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Package iperf implements the client and server interfaces required to use Iperf with callboxes package iperf
package ipgeolocation import ( "errors" "net/url" ) // validateParams is used to make sure required fields are present func validateParams(params *IPGeolocationRequest) error { if params == nil { return errors.New("missing input") } if params.IP == "" && len(params.IPs) == 0 { return errors.New("missing IP"...
package config import ( "log" "os" ) func InitLogger() *log.Logger { logger := log.New(os.Stdout, "Tasker ", log.LstdFlags|log.Lshortfile|log.Lmicroseconds|log.LUTC) return logger }
package controller_adaptor import ( "github.com/eden-framework/reverse-proxy/worker" "github.com/robotic-framework/robotic-client/internal/constants/enums" "github.com/robotic-framework/robotic-client/internal/global" "github.com/sirupsen/logrus" "gobot.io/x/gobot" ) var typeInitializer map[enums.UpstreamAdaptor...
package groups import ( "context" "github.com/go-kit/kit/endpoint" "github.com/mainflux/mainflux/auth" ) func createGroupEndpoint(svc auth.Service) endpoint.Endpoint { return func(ctx context.Context, request interface{}) (interface{}, error) { req := request.(createGroupReq) if err := req.validate(); err !=...
package main import "fmt" /* 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? */ func main() { fmt.Println(LCM(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ...
package kob import "regexp" var rkey = regexp.MustCompile(`:[\w]+`) const rvalue = `([^/]+)` func PathToReg(path string) (reg *regexp.Regexp, keys []string, err error) { path = regexp.QuoteMeta(path) reg, err = regexp.Compile("^" + rkey.ReplaceAllStringFunc(path, func(m string) string { keys = append(keys, m[1:...
package lumps /** Lump 34: DispLightmapSamplePosition */ type DispLightmapSamplePosition struct { LumpGeneric data []byte } func (lump *DispLightmapSamplePosition) FromBytes(raw []byte, length int32) { lump.data = raw lump.LumpInfo.SetLength(length) } func (lump *DispLightmapSamplePosition) GetData() []byte { r...
package chconn import "github.com/vahid-sohrabloo/chconn/v2/internal/helper" // Progress details of progress select query type Progress struct { ReadRows uint64 ReadBytes uint64 TotalRows uint64 WriterRows uint64 WrittenBytes uint64 ElapsedNS uint64 } func newProgress() *Progress { return &Prog...
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild package test_formats import "github.com/kaitai-io/kaitai_struct_go_runtime/kaitai" type NestedSameName2 struct { Version uint32 MainData *NestedSameName2_Main Dummy *NestedSameName2_DummyObj _io *kaitai.Stream _r...
package tracer // VERSION is Epsagon tracer version2 const VERSION = "1.20.0"
package cmd_test import ( "encoding/json" "fmt" "io" "net/http" "os/exec" "path/filepath" "time" "github.com/CircleCI-Public/circleci-cli/api/graphql" "github.com/CircleCI-Public/circleci-cli/clitest" "github.com/CircleCI-Public/circleci-cli/pipeline" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ...
package configure import ( "errors" "fmt" "slices" "github.com/evcc-io/evcc/util/templates" ) // configureDeviceGuidedSetup lets the user choose a device that is set to support guided setup // these are typically devices that // - contain multiple usages but have the same parameters like host, port, etc. // - de...
package main import ( "fmt" "strings" "github.com/slack-go/slack" ) const slackToken = "slackUserToken" const typePrivateChannel = "private_channel" var api = slack.New(getToken(slackToken)) func slackGetChannelByName(channelName string) (slack.Channel, error) { channels, _, err := api.GetConversations(&slack...
package main import ( "fmt" "strings" "time" "github.com/dkim/aoc/2021/utils" ) type Node struct { Data string Next *Node } type LinkedList struct { Length int Head *Node Tail *Node } type InsertPair struct { Data string InsertPoint *Node } func (list *LinkedList) initList(a *Node) { list.H...
package ravendb var _ ILazyOperation = &LazyAggregationQueryOperation{} // LazyAggregationQueryOperation represents lazy aggregation query operation type LazyAggregationQueryOperation struct { conventions *DocumentConventions indexQuery *IndexQuery invokeAfterQueryExecuted func(*QueryRes...
package chat var ( PromoteCmd = "!promote" DemoteCmd = "!demote" JoinCmd = "!join" PartCmd = "!part" BlockCmd = "!block" )
/* * Created by lintao on 2023/7/27 下午2:36 * Copyright © 2020-2023 LINTAO. All rights reserved. * */ package data // //func TestNewUserDataSource(t *testing.T) { // // dbMock, _, err := sqlmock.New() // if err != nil { // t.Fatalf("an error '%s' was not expected when opening a stub database connection", err) // ...
package main import ( "errors" "fmt" "log" "time" "github.com/streadway/amqp" ) func failOnError(err error, msg string) { if err != nil { log.Fatalf("%s: %s", msg, err) } } var ( conn *amqp.Connection ch *amqp.Channel err error ) func reconnect() (<-chan amqp.Delivery, error) { var err error conn,...
package tsm1 import ( "reflect" "testing" "time" ) func Test_EntriesAdd(t *testing.T) { e := newEntries() v1 := NewValue(time.Unix(2, 0).UTC(), 1.0) v2 := NewValue(time.Unix(3, 0).UTC(), 2.0) v3 := NewValue(time.Unix(1, 0).UTC(), 2.0) e.add(uint64(100), []Value{v1, v2}) if e.size != uint64(v1.Size()+v2.Size...
package myhashmap import "testing" func TestMyHashMap(t *testing.T) { var value int hashMap := Constructor() hashMap.Put(1, 1) hashMap.Put(2, 2) if value = hashMap.Get(1); value != 1 { t.Errorf("hashMap.Get(1), get %d, expect %d", value, 1) } if value = hashMap.Get(3); value != -1 { t.Errorf("hashMap.Get(3...
package api import ( "services" "github.com/gorilla/mux" "net/http" "models" ) type PictureApiController struct { r *mux.Router service *services.PictureService } func NewPictureApiController(r *mux.Router) *PictureApiController { return &PictureApiController{ r: r, service: services.NewPictureServi...
// Copyright 2014 go-beacon 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 ( "path/filepath" "github.com/BurntSushi/toml" ) type configFile struct { Debug bool `toml:"debug"` TemplatesDir string ...
package main import ( "database/sql" "flag" "fmt" "github.com/gizak/termui" "github.com/jdormit/logr/offsets" "github.com/jdormit/logr/reader" "github.com/jdormit/logr/timeseries" "github.com/jdormit/logr/ui" _ "github.com/mattn/go-sqlite3" "log" "os" "os/signal" "path" "time" ) const defaultTimescale =...
package behaviourtest import ( "fmt" "github.com/AsynkronIT/protoactor-go/actor" "github.com/golang/protobuf/proto" "github.com/saintEvol/go-rigger/rigger" "time" ) func Start() { _ = rigger.Start(appName, "") } /* hello world 应用 */ // 应用名,应用标识 const appName = "behaviourtestapp" func init() { rigger.Registe...
// Command decrypt decrypts file encrypted with RSA public key, using matching // RSA private key. package main import ( "crypto/aes" "crypto/cipher" "crypto/rand" "crypto/rsa" "crypto/sha1" "crypto/x509" "encoding/pem" "errors" "flag" "fmt" "io" "io/ioutil" "log" "os" ) var privKey, inFile, outFile str...
// Copyright (c) 2014 ZeroStack 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...
package reduce import "testing" var examples = []struct { want int num int }{ { want: 6, num: 14, }, { want: 4, num: 8, }, { want: 12, num: 123, }, } func Test_examples(t *testing.T) { for i, e := range examples { got := numberOfSteps(e.num) if e.want != got { t.Fatalf("\ni:%v\nwant:%...
package main import ( "log" "os" "path/filepath" "github.com/pkg/errors" ) func main() { desktop := filepath.Join(os.Getenv("HOME"), "Desktop") // TODO configurable dir name bak := filepath.Join(desktop, "bak") if _, err := os.Stat(bak); os.IsNotExist(err) { err = os.Mkdir(bak, 0777) if err != nil { l...
package market import ( "testing" "fmt" "github.com/yangxinwei/gin-demo-api/config" ) func TestSearch(t *testing.T) { config.InitConfig() //keywords := `%yr,,d&b,b*ff%` keywords := `Yiren` if result, err := Search(keywords); err != nil { fmt.Println(err) } else { fmt.Println(result) } } func TestFilter...
package main import "LeetCode" func main() { LeetCode.Code1010() }
// Package smartling is a client implementation of the Smartling Translation // API v2 as documented at https://help.smartling.com/v1.0/reference package smartling import ( "net/http" "time" ) type ( // LogFunction represents abstract logger function interface which // can be used for setting up logging of librar...
package game import ( "errors" "time" ) var ErrGameInterrupt = errors.New("game was finished by user") type Game struct { painter *Painter events <-chan Event ticker *time.Ticker arena Arena } func NewGame(painter *Painter, events <-chan Event, arena Arena) *Game { return &Game{ painter: painter, eve...
package lc // Time: O(n) // Benchmark: 4ms 6.5mb | 100% func minPartitions(n string) int { var max int for _, ch := range n { if int(ch-'0') > max { if int(ch-'0') == 9 { return 9 } max = int(ch - '0') } } return max }
// Copyright 2019 Yunion // // 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 writi...
package vehicle import ( "math/rand" "time" ) var noop = func(*Vehicle) {} //Upgrade for a Vehicle type Upgrade struct { Name string Description string manipulate vehicleManipulator } var vehicleUpgrades = []Upgrade{ {"Balista", "A giant crossbow mounted on the car that deals 3 damage to its target on...
package action type Chart struct { name string version string } type Repository struct { name string charts map[string]*Chart }
// 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 peer import ( "encoding/binary" "github.com/bitmark-inc/bitmarkd/announce" "github.com/bitmark-inc/bitmarkd/asset" "github.com/bitmark...
package store type Store interface { UploadFile(remotePath, localPath, checksum string) error DownloadFile(remotePath, localPath string) (string, error) }
/* * Created on Wed Mar 20 2019 21:29:38 * Author: WuLC * EMail: liangchaowu5@gmail.com */ func numPairsDivisibleBy60(time []int) int { count := [60]int{0} for _, t := range time { count[t%60]++ } result := 0 for i := 0; i <= 30; i++ { if i == 0 || i == 30 { result += (count[i] * (count[i-1])) / 2 } ...
// Copyright 2019 Yunion // // 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 writi...
package mail import ( "crypto/tls" "errors" "fmt" "net/http" "net/mail" "net/textproto" "path/filepath" "sync" "time" "github.com/jrapoport/gothic/config" "github.com/jrapoport/gothic/core/validate" "github.com/jrapoport/gothic/log" "github.com/jrapoport/gothic/mail/template" "github.com/jrapoport/gothi...
package xpbonds import ( "bytes" "context" "encoding/base64" "sort" "github.com/pkg/errors" ) // FindBestBonds determinates the best bonds from the bond report. It expects // the report to contain a xlsx content (Excel) encoded in base64. After parsing // the xlxs it performs some filtering and sorting actions ...
package gago import "math/rand" // A Deme contains individuals. Individuals mate within a deme. Individuals can // migrate from one deme to another. type Deme struct { // Number of individuals in the deme, it is defined for convenience Size int // Individuals Individuals Individuals // Each deme has a random num...
package models import "gz.com/master/random" /* 案件关联的嫌疑人,嫌疑人在这个案件中的信息 */ type CaseSuspects struct { CsId string `orm:"pk;size(32)"` CsCaseId string `orm:"size(32)"` CsSuspectsId string `orm:"size(32)"` CsInfo string `orm:"type(text)"` } func (this *CaseSuspects)Read(field ...string) error { return o.Read(this, ...
// fmt.Println("InsertedOne(), newID", newID)
package core /** Lambda Running in AWS Receives Event Hits s3 bucket get config (Maybe Git) Processes Command: Each Task */ type Executor interface { Execute(task *Task) *TaskResult }
package plugin import ( "context" ) type DeletePlugin interface { // Return a unique key for this plugin GetKey() string // Return a parameter list with descriptions. GetParameters() map[string]string // Set a parameter. The plugin may return an error if the configuration value is not valid or no such configura...
package main import "fmt" // Notice the channel directions. Function and only send to c channel func Numbers(c chan<- int) { for i := 1; ; i++ { c <- i } return } // Here function can only send to out channel and receive from in channel func MultipleFilter(num int, in <-chan int, out chan<- int) { for i := ran...
/* Copyright © 2021 Bren 'fraq' Briggs (code@fraq.io) 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, publ...
package main import ( "common" "fmt" ) func main() { goHello := common.HelloWorld("golang") fmt.Println(goHello) }
package controllers import ( "io/ioutil" "log" "net/http" "encoding/json" "os" "github.com/mailgun/mailgun-go" "github.com/dev-lusaja/gomail/models" ) var ( config models.Config ) func init() { config_file, e := ioutil.ReadFile("configs/sender.json") if e != nil { log.Println(e) os.Exit(1) } json...
package leetcode import ( "fmt" "sort" "testing" "github.com/stretchr/testify/assert" ) func TestIntersect2ary2(t *testing.T) { assert.Equal(t, []int{2,2}, intersect([]int{1,2,2,1}, []int{2,2})) assert.Equal(t, []int{4,9}, intersect([]int{4,9,5}, []int{9,4,9,8,4})) } /** Intersection of ...
package notify func newNotifier() (Notifier, error) { return &emptyNotifier{}, nil }
package config func DSN() string { var User = "root" // exemple : "root" var Password = "" // laisser à vide si pas de mot de passe var DatabaseName = "alea_data_est" var Charset = "utf8" // exemple : "utf8" var ret = User + ":" + Password + "@/" + DatabaseName + "?charset=" + Charset return ...
// This file contains unit orders. package repcmd import "github.com/icza/screp/rep/repcore" // Order describes the unit order. type Order struct { repcore.Enum // ID as it appears in replays ID byte } // Orders is an enumeration of the possible unit orders. var Orders = []*Order{ {e("Die"), 0x00}, {e("Stop")...
// Copyright 2015 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 model import ( "errors" "fmt" "net/http" "strconv" "github.com/manyminds/api2go" "github.com/manyminds/api2go/jsonapi" ) type Car struct { ID uint64 `json:"-"` Brand string `json:"brand"` Model string `json:"model"` Price uint64 `json:"price"` Status string `json:"status"` // OnTheWa...
package main import ( "database/sql" "flag" "github.com/joho/godotenv" "log" "lucasantarella.com/businesscards/internal" "net" "net/http" "os" "strings" "context" "github.com/golang/glog" "github.com/grpc-ecosystem/grpc-gateway/runtime" pb "github.com/lucasantarella/business-profiles-grpc-golib" "google...
package v1alpha1 import ( "testing" "github.com/onsi/gomega" "golang.org/x/net/context" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" ) func TestStorageGlobalRoleBinding(t *testing.T) { key := types.NamespacedName{ Name: "dogs", } created := &GlobalRoleBinding{ ObjectMeta:...
package main import ( "bytes" "context" "flag" "fmt" "log" "net/http" "os" "time" "github.com/Masterminds/semver" "github.com/VictoriaMetrics/metrics" "github.com/afoninsky/version-exporter/probers" "gocloud.dev/blob" _ "gocloud.dev/blob/azureblob" _ "gocloud.dev/blob/fileblob" _ "gocloud.dev/blob/gcsb...
package users_test import ( "reflect" "testing" "users" _ "github.com/jinzhu/gorm/dialects/postgres" ) func testAuth(t *testing.T, repo users.UsersRepo) { s := users.NewService(repo) expectedUser := makeUser() if err := repo.Create(expectedUser); err != nil { t.Fatal(err) } // with email var emailActua...
package adding var DefaultOrders = []Order{ { ID: 1, Amount: 10, Status: "init", OrderLines: []OrderLines{ OrderLines{ SKU: "TROP-UA-PLAS-09", Price: 10, Quantity: 1, }, OrderLines{ SKU: "TROP-NP-PLAS-65", Price: 10, Quantity: 2, }, OrderLines{ SK...
package main import ( "fabriciojs/murmurhash3" "fmt" "time" "flag" ) var test = flag.Int("test", 0, "test") const K = 21474836 * 10 func main() { flag.Parse() fmt.Println("murmurhash") hashes := make([][2]uint64, *test) start := time.Now() for i := 0; i < *test; i++ { hashes[i] = murmurhash3.Murmur3F(...
package week02 import ( "fmt" "strconv" "strings" ) // https://leetcode-cn.com/problems/subdomain-visit-count/ // https://leetcode-cn.com/submissions/detail/190774264/ func subdomainVisits(cpdomains []string) []string { domainStat := map[string]int{} for _, v := range cpdomains { domains, stat := parseDomainV...
package handler import ( "encoding/json" "fmt" "io/ioutil" "net/http" "github.com/SuperTikuwa/mission-techdojo/dbctl" "github.com/SuperTikuwa/mission-techdojo/model" ) func EmissionRateHandler(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { http.Error(w, "Method Not Allowed", http...
// Constants package GridSearch import ( "fmt" "math" ) /* the relationship between parent node and child node: c1 = p*4 + 1 c2 = p*4 + 2 c3 = p*4 + 3 c4 = p*4 + 4 0|1,2,3,4|5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20|21,... suppose we have 11 layer: 4^0 + 4^1 + ... + 4^10 = 1398101 */ ...
package main import "fmt" type Node struct { Value int Next *Node } var head = new(Node) var end *Node func main() { for i := 0; i < 5; i++ { n := &Node{ Value: i + 1, } AddNode(n) } josephus(1, 3) } func AddNode(t *Node) { if end == nil { head = t t.Next = head end = t } else { end.Next...
package editorapi import ( "editorApi/controller/servers" "github.com/gin-gonic/gin" ) var ( COURSE_ASSETS_DOMAIN string = "https://course-assets1.talkmate.com" COURSE_ASSETS_BUCKET string = "assets" COURSE_UPLOADFILE_BUCKET string = "uploadfiles" COURSE_UPLOADFILE_DOMAIN string = "https://uploadfile1....
package service import ( "context" "flag" "fmt" "github.com/gorilla/mux" "google.golang.org/grpc" "myRPC/http" "myRPC/hystrix" balanceBase "myRPC/loadBalance/base" logBase "myRPC/log/base" limitBase "myRPC/limit/base" registryBase "myRPC/registry/base" "myRPC/prometheus" "myRPC/config" "myRPC/limit/limit...
package main import ( "fmt" "math/big" ) func main() { var n int fmt.Scanln(&n) if n <= 2 { fmt.Println(n) return } factorial := new(big.Int) factorial.SetInt64(1) for i := 2; i <= n; i++ { bigI := new(big.Int) bigI.SetInt64(int64(i)) factorial = factorial.Mul(factorial, bigI) } fmt.Println(fa...
package bizlogic import ( "fmt" "io/ioutil" "net/http" "net/url" "os" "path/filepath" "github.com/gin-gonic/gin" "github.com/pingcap/monitoring/reload/server/types" "github.com/pingcap/monitoring/reload/server/utils" "github.com/pkg/errors" "github.com/prometheus/common/log" "github.com/prometheus/prometh...
package loading import ( "errors" "io" ) var ( ErrTemplateNotFound = errors.New("Template not found") ) type TemplateResolver interface { GetTemplateReader(path string) (io.Reader, error) }
package troubleshoot import ( "fmt" "io" "os" "github.com/go-logr/logr" "go.uber.org/zap" "go.uber.org/zap/zapcore" ctrlzap "sigs.k8s.io/controller-runtime/pkg/log/zap" ) const ( prefixInfo = " " prefixNewTest = "--- " prefixSuccess = " \u2713 " // ✓ prefixWarning = " \u26a0 " // ⚠ prefixError ...
package zoidberg import ( "bytes" "encoding/json" "fmt" "io" "io/ioutil" "net/http" "net/http/httptest" "sort" "strings" "testing" "github.com/stretchr/testify/require" ) // Zoidberg encapsulates the testing environment and provides access to // the resources needed to read and parse the API calls. type Z...
package postgres /* Пакет для работы с БД Postgres */ import ( "context" "github.com/prometheus/common/log" "github.com/egor1344/banner/rotation_banner/pkg/ucb1" _ "github.com/jackc/pgx/stdlib" // stdlib "github.com/jmoiron/sqlx" "go.uber.org/zap" ) // PgBannerStorage - реализует работу с БД. Реализует интер...
package main import ( "bufio" "fmt" "log" "os" "sort" "strings" ) func contains(a []int, b int) bool { ix := sort.SearchInts(a, b) return ix < len(a) && a[ix] == b } func distinctTriangles(q string) (r uint) { g := make(map[int][]int) t := strings.Split(q, ",") p := make([]int, 2) for _, i := range t { ...
package uploadcard import ( "fmt" "net/http" "path/filepath" "strconv" "strings" "github.com/HanYu1983/gomod/lib/db2" tool "github.com/HanYu1983/gomod/lib/tool" "google.golang.org/appengine" ) func Serve_GetExtension(w http.ResponseWriter, r *http.Request) { defer tool.Recover(func(err error) { tool.Outp...
package mock import ( "context" "fmt" "github.com/dgraph-io/badger/v3" "github.com/ipfs/go-datastore" dssync "github.com/ipfs/go-datastore/sync" "github.com/kenlabs/pando-store/pkg/config" "github.com/kenlabs/pando-store/pkg/store" "github.com/kenlabs/pando/pkg/legs" "github.com/kenlabs/pando/pkg/metadata" "...
package main import "sort" // DocumentID is a unique identifier of a document type DocumentID = uint32 // Term is a search item of a document type Term = string // PostingList represents the list of documents that belongs to a search term type PostingList = []DocumentID // InvertedIndex is a datastructure, that ma...
package path import ( "errors" "fmt" "os" "path/filepath" "strings" ) var errNoPath = errors.New("no path provided") // FixHomePath returns the provided path adjusted to replace the home directory tilde if there is one. // The path may be provided as a single string or a list of elements that will be joined. fu...
package server_test import ( "net/http" "net/http/httptest" "os" "testing" "github.com/elhamza90/lifelog/internal/http/rest/server" "github.com/elhamza90/lifelog/internal/store/memory" "github.com/elhamza90/lifelog/internal/usecase/adding" "github.com/elhamza90/lifelog/internal/usecase/auth" "github.com/elha...
package auth551 import ( "database/sql" "github.com/go51/model551" "time" ) //--[ User Model ]-------- type UserModel struct { Id int64 `db_table:"users"` CreatedAt time.Time UpdatedAt time.Time Locked bool Enabled bool Name string Email string EmailC...
//go:build e2e package cloudnative const ( oneAgentInstallContainerName = "install-oneagent" )
/* Decoding MIPS Instructions I-Instruction format: | opcode | rs | rt | immediate | | ------ | ------ | ------ | ------------------------ | | 6 bit | 5 bits | 5 bits | 16 bits | J-Instruction format: | opcode | address | | ------ | ----...
package whitelist import ( "github.com/mrdniwe/clc.wtf/internal/config" "github.com/mrdniwe/clc.wtf/internal/interfaces" ) type wl struct { conf config.WhitelistConfig } func (s *wl) IsUserAllowed(id int) bool { for _, user := range s.conf.GetWhitelistedIds() { if id == user { return true } } return fal...
package storage import ( "github.com/jinzhu/gorm" "gitlab.cheppers.com/devops-academy-2018/shop2/pkg/shoe/model" ) type SQL struct { db *gorm.DB } func (s *SQL) Init(db *gorm.DB) { s.db = db } func (s *SQL) Insert(p model.Shoe) (model.Shoe, error) { pp := &p s.db.Model(p).Create(pp) return *pp, nil } func...
package beer import ( "fmt" ) func Verses() { fmt.Printf("99 bottles of beer on the wall, 99 bottles of beer.\n") for beer := 98; beer > 1; beer-- { fmt.Printf("Take one down and pass it around, %d bottles of beer on the wall.\n\n", beer) fmt.Printf("%d bottles of beer on the wall, %d bottles of beer.\n", beer, ...
/* Copyright 2019 Baidu, 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 in writing, software dis...
package main import ( "fmt" "math/rand" "runtime" "sync" "time" ) var total int32 = 10 var mu = &sync.Mutex{} func sell(id int) { for { mu.Lock() if total > 0 { time.Sleep(time.Duration(rand.Intn(5)) * time.Second) total-- fmt.Println("id:", id, "ticket:", total) } else { break } mu.Unloc...