text
stringlengths
11
4.05M
// 15 july 2014 package ui import ( "unsafe" ) // #include "winapi_windows.h" import "C" type textfield struct { *controlSingleHWNDWithText changed *event } var editclass = toUTF16("EDIT") func startNewTextField(style C.DWORD) *textfield { hwnd := C.newControl(editclass, style|C.textfieldStyle, C.textfie...
package app import "net/http" func (app *App) Routes() { app.router.Handle("/ads", app.log(http.HandlerFunc(app.getHandler))).Methods("GET") app.router.Handle("/ads", app.log(http.HandlerFunc(app.postHandler))).Methods("POST") app.router.Handle("/ads/{id:[0-9]+}", app.log(http.HandlerFunc(app.deleteHandler))).Meth...
package main import ( "code.google.com/p/go.net/idna" "fmt" "github.com/jlaffaye/ftp" "io" "log" "net/url" "os" "strings" "sync" "time" ) const ( STATUS_CONNECTING = iota STATUS_CONNECTED STATUS_ERROR STATUS_DISCONNECTING STATUS_INACTIVE FTP_RECONNECT_DELAY = 60 * time.Second FTP_DISCONNECT_DELAY ...
package main import ( "log" "strings" "time" "github.com/goodsign/monday" ) const ( defaultDateFormat = "2 de January de 2006" ) func daysBetween(start, end time.Time) []time.Time { nDays := int(end.Sub(start).Hours()/24) + 1 days := make([]time.Time, nDays) days[0] = start for i := range days[1:] { da...
package main import ( "os" "github.com/n0rad/go-erlog/logs" ) func (p *Pod) Clean() { logs.WithF(p.fields).Info("Cleaning") if err := os.RemoveAll(p.target + "/"); err != nil { logs.WithEF(err, p.fields.WithField("dir", p.target)).Warn("Cannot clean directory") } for _, e := range p.manifest.Pod.Apps { a...
// Copyright (c) 2016-2018, Jan Cajthaml <jan.cajthaml@gmail.com> // // 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 require...
package main import ( "fmt" "net" "os" "os/exec" "strings" "time" ) func main() { //display hostname name, err := os.Hostname() if err != nil { //error checking panic(err) } fmt.Println("hostname: ", name) //display date dt := time.Now() fmt.Println("Current date and time is: ", dt.String()) //ge...
package fiber type Request interface { Payload() []byte Header() map[string][]string Clone() (Request, error) OperationName() string Transform(backend Backend) (Request, error) }
package store import ( "testing" "github.com/angeldhakal/tv-tracker/models" "github.com/angeldhakal/tv-tracker/util" "github.com/stretchr/testify/require" ) var tokenRepo = NewTokenStore() func createRandomToken(t *testing.T) models.Tokens { user := createRandomUser(t) arg := CreateTokenParams{ CreatedAt: ...
package main import ( "bufio" "fmt" "log" "os" "strings" ) func bats(l, d, n int, s []string) (c int) { var t int tx := 6 - d for i := 6; i <= l-6; i += d { if i > tx-d { i = tx if t == n { tx = l - 6 + d } else { fmt.Sscanf(s[t], "%d", &tx) t++ } } else { c++ } } return c }...
package BiAStarFinder /* by stefan 2572915286@qq.com Based upon https://github.com/qiao/PathFinding.js */ import ( "go-PathFinding/core" "go-PathFinding/finders/AStarFinder" "math" ) type BiAStarFinder struct { *AStarFinder.TAStarFinder } /** * A* path-finder. * based upon https://github.com/bgrins/javascri...
package config import ( "github.com/grafeas/voucher" "github.com/grafeas/voucher/auth/google" ) func newAuth() voucher.Auth { return google.NewAuth() }
package main import ( "context" "fmt" "io" "time" "github.com/dfreilich/grpc-samples/greet/greetpb" "github.com/pkg/errors" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) // Server Implementation for Greet RPC Calls type Server struct{} // Greet is a unary RPC call to get a name, and send ...
package thirdpay import ( //"fmt" "github.com/astaxie/beego" //"tripod/convert" //"webserver/common" //"webserver/controllers/horder" "webserver/controllers/notify" //"webserver/controllers/service" "webserver/models" "webserver/models/maccount" "webserver/models/mservice" //"webserver/utils" ) type PayNot...
package mongodb // Order defines the storage form of an order type Order struct { ID int64 `json:"id" bson:"id"` Amount int64 `json:"amount" bson:"amount"` Status string `json:"status" bson:"status"` OrderLines []OrderLines `json:"order_lines" bson:"order_lin...
/* * @lc app=leetcode id=589 lang=golang * * [589] N-ary Tree Preorder Traversal * * https://leetcode.com/problems/n-ary-tree-preorder-traversal/description/ * * algorithms * Easy (71.53%) * Likes: 620 * Dislikes: 61 * Total Accepted: 109.2K * Total Submissions: 151.5K * Testcase Example: '[1,null,3...
package enum_test import ( "testing" "github.com/adamluzsi/frameless/pkg/enum" "github.com/adamluzsi/testcase" "github.com/adamluzsi/testcase/assert" ) func ExampleValidateStruct_string() { type ExampleStruct struct { V string `enum:"A;B;C;"` } _ = enum.ValidateStruct(ExampleStruct{V: "A"}) // no error _ ...
package model import "testing" func TestMethodCall_EqualsTo(t *testing.T) { testData := make([]*AlphaNodeTest, 0) testData = append(testData, &AlphaNodeTest{ A: &MethodCall{ MethodName: "funcName", MethodArguments: &FunctionArgument{Arguments: []*ArgumentHolder{}}, }, B: &MethodCall{ Me...
package model type Book struct { ID int64 `json:"id" db:"ID"` Name string `json:"name" db:"NAME"` URL string `json:"url" db:"URL"` CreatedAt string `json:"created_at" db:"CREATED_AT"` UpdatedAt string `json:"updated_at" db:"UPDATED_AT"` PreviewURL ...
package resource import ( "io" ) // // IResource interfaces with a rest-ish endpoint. // See also, Wrapper, which provides a function-based adapter. // type IResource interface { // Return the named sub-resource Find(string) (IResource, bool) // Return the resource Query() Document // Post to the resource Post...
package httptest import ( "io" "net/http" "strings" "sync" ) type FakeClient struct { requests []http.Request responseCode int responseBody string Err error mu sync.Mutex } func (fc *FakeClient) Do(req *http.Request) (*http.Response, error) { fc.mu.Lock() defer fc.mu.Unlock() fc.requests =...
package handlers import ( "net/http" "github.com/gorilla/mux" "github.com/justinas/alice" "github.com/orbis-challenge/src/config" "github.com/orbis-challenge/src/handlers/etf" "github.com/orbis-challenge/src/handlers/user" middleware "github.com/orbis-challenge/src/middlewares" ) // NewRouter creates a router...
package main import ( "flag" "fmt" "net/http" "companyxchallenge" ) var ( port int64 ) func init() { flag.Int64Var(&port, "port", 7163, "Port to serve on") } func jokeHandler(w http.ResponseWriter, r *http.Request) { joke, err := companyxchallenge.GetRandomJoke() w.Header().Set("Content-Type", "text/plain"...
package queryparser import ( "fmt" "testing" ) func TestParseQuery(t *testing.T) { s := "select a,b,c from db.dbname limit 1 orderby asc;" qp, er := ParseQuery(s) if er == nil { fmt.Println(qp.OrderBy) } s = "This is not a valid SQL query" qp, er = ParseQuery(s) if er == nil { fmt.Println(qp.OrderBy) }...
package dirsync import ( "io/ioutil" "log" "os" "path/filepath" "time" ) // A Syncer keeps a local folder up to date with a remote server. type Syncer struct { LocalPath string RemotePath string Lister Lister Downloader Downloader Interval time.Duration Verbose bool } // Sync runs an infinite sync...
package clair import ( "path" "strings" digest "github.com/opencontainers/go-digest" ) // GetNewLayerURI gets the new layer URI for the passed hostname. func GetNewLayerURI(hostname string) string { return createURI(hostname, "v1/layers") } // GetLayerURI gets the layer URI for the passed digest on the passed h...
// ===================================== // // author: gavingqf // // == Please don'g change me by hand == // //====================================== // /*you have defined the following interface: type IConfig interface { // load interface Load(path string) bool // clear interface Clear() }...
package cmd import ( "gorest/config" "gorest/database" "gorest/handler" "gorest/router" "log" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/logger" "github.com/spf13/cobra" ) // serveCmd represents the serve command var serveCmd = &cobra.Command{ Use: "serve", Short: "A brief desc...
package cmd import ( "path/filepath" "github.com/cidverse/cid/pkg/app" "github.com/cidverse/cid/pkg/common/api" "github.com/cidverse/cid/pkg/core/restapi" "github.com/cidverse/cid/pkg/core/state" "github.com/cidverse/repoanalyzer" "github.com/cidverse/repoanalyzer/analyzerapi" "github.com/rs/zerolog/log" "gi...
package regtable_test import ( "fmt" "net/http" "net/http/httptest" "testing" "github.com/greytabby/go-routing/regtable" "github.com/stretchr/testify/assert" ) func TestRouting(t *testing.T) { router := regtable.NewRouter() router.NewRoute(http.MethodGet, "/", http.HandlerFunc(func(w http.ResponseWriter, r *...
package main import ( "net/http" "github.com/jmoiron/sqlx" . "github.com/altrudos/api" ) type Getter func(db sqlx.Queryer, id string) (interface{}, error) func getById( paramKey string, itemName string, fn Getter, ) HandlerFunc { return func(c *RouteContext) { id := c.Params[paramKey] if c.HandledMissin...
package plugins type FilePlugin struct { name string } func NewFilePlugin() Plugin { return &FilePlugin{} } func (f *FilePlugin) Equal(p Plugin) bool { a, ok := p.(*FilePlugin) if ok { return *f == *a } return false } func (f *FilePlugin) Configure(name string, settings map[string]interface{}) erro...
package main import ( "context" "flag" "fmt" "os" "sort" "strings" "time" "github.com/dustin/go-humanize" "github.com/mroth/deepclean" "github.com/tj/go-spin" ) const defaultTargets = "node_modules,.bundle,target" var ( targetStr = flag.String("target", defaultTargets, "dirs to scan for") sorted = fl...
// Project Euler problem 15 // Solution by Kevin Retzke // December 2012 package main import ( "fmt" "math/big" ) func factorial(n int) *big.Int { fac := new(big.Int) fac.MulRange(1, int64(n)) return fac } func paths(n int) *big.Int { r := new(big.Int) fn := factorial(n) r.Div(factorial(2*n), fn.Mul(fn, fn))...
package debug import ( "log" "time" "golang.org/x/net/websocket" ) func (d *Debugger) IO(ws *websocket.Conn) { err := websocket.Message.Send(ws, d.g.IO[:]) if err != nil { log.Printf("error sending data: %v\n", err) return } for range time.NewTicker(time.Millisecond * 100).C { err := websocket.Message....
package cache import ( "context" "github.com/go-redis/redis/v7" ) // Client represents the functions needed for this wrapper. type Client interface { AddHook(redis.Hook) WithContext(context.Context) *redis.Client } // Cache is a logged and instrumented wrapper around a redis client. type Cache struct { client ...
/* Copyright 2021 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...
// Copyright © 2020 Weald Technology Trading // 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 a...
package html5_test import ( . "github.com/bytesparadise/libasciidoc/testsupport" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("symbols", func() { Context("in final documents", func() { Context("m-dashes", func() { It("should detect between word characters", func() { sou...
package main import ( "bytes" "encoding/json" "errors" "flag" "fmt" "io" "io/ioutil" "log" "math/rand" "net" "strings" "time" ) // message is the data that travels between peers. type message struct { User string Text string } // peerMessage is a message recieved from a peer. type peerMessage struct { ...
// 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...
package main import ( "fmt" "regexp" ) //正则 func main() { matchString, _ := regexp.MatchString("p([a-z]*)ch", "patch") fmt.Println(matchString) compile, _ := regexp.Compile("p([a-z]*)ch") fmt.Println(compile.MatchString("pathc")) fmt.Println(compile.FindString("patch pahyc passch")) fmt.Println(compile.FindAl...
package connection import "github.com/multivactech/MultiVAC/model/shard" // Connector is used for inject. type Connector interface { UpdatePeerInfo([]shard.Index) } // BroadcastParams defines the broadcast params. type BroadcastParams struct { ToNode toNodeType ToShard shard.Index IncludeSelf bool //ex...
package client import ( "fmt" "io" "net" "net/http" "net/http/httputil" "strings" "time" "github.com/hyperhq/hyper/lib/promise" "github.com/hyperhq/hyper/lib/term" "github.com/hyperhq/hyper/utils" ) func (cli *HyperClient) dial() (net.Conn, error) { return net.Dial(cli.proto, cli.addr) } func (cli *Hyper...
// 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 main import ( "fmt" "os" ) // TODO extract into package or such // // because this is "frikkin rad" it's basically upload // with the args moved up one. type RunCmd struct { UploadCmd } func (r *RunCmd) Usage() { fmt.Fprintln(os.Stderr, `usage: iron run [-zip my.zip] -name NAME [OPTIONS] some/image[:tag...
package template import "testing" func TestChangeEmail_Load(t *testing.T) { t.Parallel() testTemplateLoad(t, func(sub string, test testCase) Template { c := test.mc.ChangeEmail c.Subject = sub c.Template = test.tmpl return NewChangeEmail(c, test.to, fromEmail, test.tok, test.ref) }) } func TestChangeEmail...
package checker import "github.com/bborbe/backup/dto" type statusCheckerMock struct { status []dto.Status err error } func NewStatusCheckerMock(status []dto.Status, err error) StatusChecker { s := new(statusCheckerMock) s.status = status s.err = err return s } func (s *statusCheckerMock) Check() ([]dto.Sta...
package slidingWindow /** * @author liujun * @version 1.0 * @date 2021/7/21 * @author—Email liujunfirst@outlook.com * @blogURL https://blog.csdn.net/ljfirst * @description 数组的连续积小于给定值的组合 * 求出数组中连续数的积小于给定值的组合,使用滑动窗口 * <p> * 输入:{10, 5, 2, 6},target:100 * 输出:{ * {10}, {10,5}, {10,5,2}, * {5}, {5,2}, {5,2,6}, ...
package main func main() { FlagTest() CommandTest() PlatformTest() ProtobufTest() JsonTest() XMLTest() GoroutineTest() FileTest() ZlibTest() AESCtyptTest() }
package ohdear import ( "errors" "fmt" "io/ioutil" "net/http" "net/url" "testing" "github.com/stretchr/testify/assert" ) func TestNewClient(t *testing.T) { type args struct { baseClient *http.Client baseURL string apiToken string } cases := []struct { name string args args wantErr b...
// Copyright 2018 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 main import "testing" type InterfaceA interface { AA() } type A struct { v int } func (a *A) AA() { a.v += 1 } func TypeSwitch(v interface{}) { switch v.(type) { case InterfaceA: v.(InterfaceA).AA() } } func NormalSwitch(a *A) { a.AA() } func InterfaceSwitch(v interface{}) { v.(InterfaceA).AA()...
package controller import ( "encoding/hex" "sort" "testing" "github.com/multivactech/MultiVAC/base/vrf" "github.com/multivactech/MultiVAC/configs/config" "github.com/multivactech/MultiVAC/model/shard" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) var shardListForTest = []uint32{0,...
//bool 運算子 條件 package main import ( "fmt" ) func main() { //&&:且 (and) //||:或 (or) //!:非 (not) fmt.Println(true && true) //true fmt.Println(true && false) //false fmt.Println(true || true) //true fmt.Println(true || false) //true fmt.Println(!true) //false }
package types // VersionLatest is a string signaling that the latest version should be retrieved for k3s. const VersionLatest string = "latest" // ManifestMetaFile is the name used when writing the version information to an archive. const ManifestMetaFile = "manifest.json" // ManifestEULAFile is the name used when a...
package models import ( "github.com/UniversityRadioYork/myradio-go" ) // ShowModel is the model for the Show controller. type ShowModel struct { Model } // NewShowModel returns a new ShowModel on the MyRadio session s. func NewShowModel(s *myradio.Session) *ShowModel { return &ShowModel{Model{session: s}} } // G...
/* vim:set sw=8 ts=8 noet: * * Copyright (c) 2017 Torchbox Ltd. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely. This software is provided 'as-is', without any express or implied * warranty. */ package m...
package lc // Time: O(n) func numIdenticalPairs(nums []int) int { var c int seen := make(map[int]int, len(nums)-1) for _, v := range nums { n, ok := seen[v] if ok { c += n } seen[v] = n + 1 } return c }
// handlers_test.go package main import ( "io/ioutil" "net/http" "net/http/httptest" "os" "testing" "github.com/eferhatg/cas-stress/cashttpclient" "github.com/julienschmidt/httprouter" ) func TestGetContent(t *testing.T) { cserver := NewCasServer() d1 := []byte("hello cas server") err := ioutil.WriteFile...
package aoc2019 import "testing" func TestCalculateDay15_Part1(t *testing.T) { count, err := solveDay15Part1("day15_input.txt") if err != nil { t.Fatalf("Day 15 solver failed: %s", err) } t.Logf("Solution Day 15 Part 1: %d", count) } func TestCalculateDay15_Part2(t *testing.T) { res, err := solveDay15Part2("...
package db import ( "github.com/jmoiron/sqlx" ) const ( CREATE_DEPARTMENT = "INSERT INTO departments (name, leader_id) VALUES (?, ?)" SELECT_DEPARTMENTS = ` SELECT departments.id, departments.name, IFNULL(departments.schedule_id, 0) AS schedule_id, users.id AS userID, users.first_name, users.last_name, users...
package client_test import ( "bytes" "context" "encoding/json" "io/ioutil" "net/http" "testing" "github.com/darren-west/app/user-service/client" "github.com/darren-west/app/user-service/models" "github.com/stretchr/testify/suite" ) func TestClientSuite(t *testing.T) { suite.Run(t, &ClientSuite{}) } type C...
// Package Overview. // mastodon cli tool package main import ( "bytes" "context" "fmt" "log" "os" "strings" "github.com/comail/colog" "github.com/fatih/color" m "github.com/mattn/go-mastodon" "github.com/spf13/viper" "golang.org/x/net/html" kingpin "gopkg.in/alecthomas/kingpin.v2" ) // MainFunction // こ...
package main import ( "context" "io" "log" "net/http" "time" "google.golang.org/grpc" protodata "./protodata" ) const ( serverAddress = "localhost:5000" inputPort = ":8083" ) type grpcClient struct { client protodata.ReplyStreamerClient } func (gc *grpcClient) getConnection(address string) { conn, ...
package ipsubnet import "testing" type TestCase struct { ip string subnet int numberIPAddresses int numberAddressableHosts int ipAddressRange []string networkSize int } func builder() TestCase { test := TestCase{} test.ip = "192.168.112.203" test.s...
package keeper_test import ( "github.com/Sifchain/sifnode/x/dispensation/test" "github.com/Sifchain/sifnode/x/dispensation/types" "github.com/google/uuid" "github.com/stretchr/testify/assert" "testing" ) func TestKeeper_GetDistributions(t *testing.T) { app, ctx := test.CreateTestApp(false) keeper := app.Dispen...
// Copyright 2019 Tetrate // // 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 teststore_test import ( "awesomeProject3/internal/app/model" "awesomeProject3/internal/app/store/teststore" "github.com/stretchr/testify/assert" "testing" "time" ) func TestStatisticRepository_Create(t *testing.T) { s := teststore.New() u := model.TestStatistic(t) stat, err := u.ToStatistic() if err ...
package serializer // //func BuildInteractive(item model.Interactive) InteractiveData { // return InteractiveData{ // Collect : item.Vid, // Like : item.Video.Title, // Follow : item.Follow, // } //} //
package main type ServerInfo struct { Id int `json:"id"` Url string `json:"url"` } type PingResponse struct { Status string `json:"status"` Time int64 `json:"time"` }
package main import ( "flag" "fmt" "github.com/jcuga/go-upnp" "os" ) func main() { displayExternalIpPtr := flag.Bool("ip", false, "Display external IP address and exit.") useUdpPtr := flag.Bool("udp", false, "Use UDP (instead of TCP) when opening/closing port forward.") doClosePtr := flag.Bool("close", false, ...
package main import ( "fmt" "strings" "testing" ) type tuple struct { p, q string } func TestPanacea(t *testing.T) { for k, v := range map[tuple]bool{ tuple{"64 6e 78", "100101100 11110"}: true, tuple{"5e 7d 59", "1101100 10010101 1100111"}: true, tuple{"93 75", "1000111 1011010 1100010"}: fa...
package portutil import ( "regexp" "strconv" "github.com/pkg/errors" "github.com/LarsFronius/rootlesskit/pkg/port" ) // ParsePortSpec parses a Docker-like representation of PortSpec. // e.g. "127.0.0.1:8080:80/tcp" func ParsePortSpec(s string) (*port.Spec, error) { r := regexp.MustCompile("^([0-9a-f\\.]+):([0-...
package main import "fmt" func main() { A := []int{2, 4, 5, 7, 1, 2, 3, 6} for j := 1; j < len(A); j++ { key := A[j] i := j - 1 for i >= 0 && A[i] > key { A[i+1] = A[i] i = i - 1 } A[i+1] = key } fmt.Println(A) }
package main import ( "bytes" "flag" "fmt" "io/ioutil" "log" "net/http" "os" "os/signal" "path" "strings" "syscall" "github.com/julienschmidt/httprouter" ) const ( // LogDebug specific more detail for process LogDebug = 1 << iota ) var ( version string env struct { Addr string ConfigFi...
///usr/bin/env go run "$0" "$@"; exit /* This file is part of eRCaGuy_hello_world: https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world GS Learn to get the hostname in Go. 14 Feb. 2023 STATUS: done and works! To compile and run (assuming you've already `cd`ed into this dir): ```bash # As a bash-like executa...
package git import ( "errors" "fmt" "path/filepath" "go.starlark.net/starlark" "github.com/tilt-dev/tilt/internal/tiltfile/starkit" "github.com/tilt-dev/tilt/internal/tiltfile/value" ) type Repo struct { basePath string } var _ starlark.Value = &Repo{} func (gr *Repo) String() string { return fmt.Sprintf(...
package image_store import ( "database/sql" "fmt" "sync" "github.com/Emoto13/photo-viewer-rest/image-service/src/image_store/image_data" ) type ImageStore interface { UploadImage(imageData *image_data.UploadImage) (string, error) } type imageStore struct { connector S3Connector db *sql.DB mu s...
package utils import ( "fmt" "io" "net/http" "net/http/httptest" "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestWrapHTTPClient(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Pa...
package logger import ( "fmt" "io" "os" "strings" "sync" "time" "github.com/fatih/color" ) type LogType string type LogLevel int const ( TypeDebug LogType = "DEBUG" TypeSuccess LogType = "SUCCESS" TypeInfo LogType = "INFO" TypeWarning LogType = "WARNING" TypeError LogType = "ERROR" TypeCrit...
package collections import ( "github.com/crowleyfelix/star-wars-api/server/errors" "github.com/bouk/monkey" "github.com/crowleyfelix/star-wars-api/server/database/mongodb" "github.com/crowleyfelix/star-wars-api/server/database/mongodb/mocks" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "gopkg.in/mgo....
package controller import ( "encoding/json" "math/rand" "strings" "time" ) // maybe control group 30 minute, and release // setting with after const ( SETTING_FULL_GROUP_START = 100 ) // setting with timer notify const ( SETTING_FULL_GROUP_IMG_NOTIFY = 200 ) const ( ControlGroupAllTime = 1800 ) type GroupFu...
package main import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) func TestCases(t *testing.T) { tcs := []struct { n uint expected int }{ {17, 35}, {7, 12}, {45, 119}, {127, 448}, } for idx, tc := range tcs { t.Run(fmt.Sprint(idx), func(t *testing.T) { assert.Equal(t, tc.ex...
package main import ( "net" "net/http" "os" "runtime" "sync" "time" "github.com/google/gopacket/pcap" "github.com/maxbaldin/dissertation-project/src/implementation/agent/entity" "github.com/maxbaldin/dissertation-project/src/implementation/agent/integration/collector" "github.com/maxbaldin/dissertation-proj...
/* Package gostruct is a generated package which contains definitions of structs which represent a YANG schema. The generated schema can be compressed by a series of transformations (compression was false in this case). This package was generated by /Users/cmo/.gvm/pkgsets/go1.10.2/global/src/github.com/openconfig/ygo...
// 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 ( "fmt" "reflect" ) // TypeName returns v's package-qualified type name. func (d *Descriptor) TypeName(v interface{}) string { return reflect.TypeOf(v).String() } // RequestTypeName calls d.TypeName(d.Request). func (d *Descriptor) RequestTypeName() string { return d.TypeName(d.Request) } //...
package parser import ( "time" "github.com/bytesparadise/libasciidoc/pkg/types" log "github.com/sirupsen/logrus" ) // Aggregate pipeline task which organizes the sections in hierarchy, and // keeps track of their references. // Also, takes care of wrapping all blocks between header (section 0) and first child se...
package smartling import "fmt" import "time" const tokenExpirationSafetyDuration = 30 * time.Second // Token represents authentication token, either access or refresh. type Token struct { // Value is a string representation of token. Value string // ExpirationTime is a expiration time for token when it becomes i...
package main import ( "context" "flag" "fmt" "log" "net" "net/http" "net/http/httputil" "net/url" "strings" "sync" "sync/atomic" "time" ) const Attempts = "ATTEMPTS" type Backend struct { URL *url.URL Alive bool ReverseProxy *httputil.ReverseProxy } // ServerPool holds information abo...
package b import ( "fmt" "net/http" "goedge/middleware/a" ) // NewEchoNameHandler echos the users name -- it depends on NameExtractorMiddleware running before it. func NewEchoNameHandler(key a.NameKey) http.Handler { return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { name := a.GetName(re...
package main import ( "encoding/base64" "flag" "fmt" "io/ioutil" "net/http" "os" "time" log "github.com/golang/glog" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "golang.org/x/net/context" "golang.org/x/net/context/ctxhttp" "github.com/fsnotify/fsnotify" "gopkg.in/yaml.v2" ...
package main import( "fmt" "rand" ) func sort (s []int) { quicksort(s, 0, len(s)-1) } func quicksort(s []int, low int, high int){ low = 0 high = len(s)-1 pivot := s[0] for low != high { if s[high] < pivot{ s[low] = s[high] low++ } else { high-- continue } for low != high { if s[low] ...
package rpc type RPCPayment struct { Coin string TxId string Vout uint32 Blockhash string Blockheight uint32 Address string Amount uint64 ScriptPK string Time int64 } type RPCBlock struct { Coin string Height uint32 ...
package controller import ( "encoding/json" "log" "net/http" "strconv" "github.com/shyam-unnithan/go-restful/domain" "github.com/gorilla/mux" "github.com/pkg/errors" ) //CustomerController manage customer type CustomerController struct { Store domain.CustomerStore } //PostCustomer ... func (handler Custome...
// Copyright 2018 NetApp, Inc. All Rights Reserved. package utils import ( "testing" "time" ) func TestLockCreated(t *testing.T) { Lock("testContext", "myLock") defer Unlock("testContext", "myLock") if _, ok := sharedLocks.lockMap["myLock"]; !ok { t.Error("Expected lock myLock to exist.") } if _, ok := s...
package main import ( "fmt" "strconv" ) func nextInt(E []byte) (int, []byte) { sgn, num := 1, 0 if E[0] == '+' { E = E[1:] } else if E[0] == '-' { E, sgn = E[1:], -1 } for len(E) > 0 && '0' <= E[0] && E[0] <= '9' { E, num = E[1:], num*10+int(E[0]-'0') } return num * sgn, E } type F...
package common import ( "errors" ) const ( CHAN_INPUT_NAME = "InputChan" CHAN_INPUT_CAPACITY = 5000 CHAN_PROCESS_NAME = "ProcessChan" CHAN_PROCESS_CAPACITY = 5000 CHAN_OUTPUT_NAME = "OutputChan" CHAN_OUTPUT_CAPACITY = 5000 PROCESSOR_URL = "processor_url" PROCESSOR_IMAGE = "processor_imag...
package cron import ( "strconv" "sync" "time" "github.com/jancajthaml-openbank/vault/actor" "github.com/jancajthaml-openbank/vault/metrics" "github.com/jancajthaml-openbank/vault/model" "github.com/jancajthaml-openbank/vault/utils" log "github.com/sirupsen/logrus" ) type saturationCallback = func(utils.RunP...