text
stringlengths
11
4.05M
package cmd import ( "easyctl/sys" "easyctl/util" "fmt" "github.com/spf13/cobra" ) var CloseServiceForever bool var closeValidArgs = []string{"firewalld", "selinux", "desktop"} func init() { closeSeLinuxCmd.Flags().BoolVarP(&CloseServiceForever, "forever", "f", false, "Service closed duration.") closeFirewall...
// Copyright 2016 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 testing import ( "crypto/ecdsa" "crypto/elliptic" cryptorand "crypto/rand" "crypto/rsa" "crypto/x509" "crypto/x509/pkix" "encoding/pem" "fmt" "io/ioutil" "math/big" "math/rand" "net" "testing" "time" clusterv1 "github.com/open-cluster-management/api/cluster/v1" workapiv1 "github.com/open-clust...
package discovery import ( "context" "os" "path/filepath" "strings" "testing" "time" "github.com/coreos/etcd/client" "github.com/mhausenblas/reshifter/pkg/types" "github.com/mhausenblas/reshifter/pkg/util" ) var ( probetests = []struct { launchfunc func(string, string) (bool, error) scheme string ...
package main import "fmt" func split(sum int) (x, y int) { //return sum * 4 / 9, sum - sum * 4/ 9 x = sum * 4 / 9 y = sum - x return y, x } func main() { fmt.Println(split(17)) }
package main import ( "fmt" "github.com/hoisie/redis" "github.com/golang/glog" "os" "os/exec" "strconv" "time" "errors" "flag" ) var redisClient redis.Client var config *Config type Config struct { Key string RedisDb int RedisAddr string RedisPassword string LockTimeout time.Durat...
package config import ( "reflect" validator "github.com/go-ozzo/ozzo-validation/v4" "github.com/pkg/errors" ) func variablesValidator(variables interface{}) error { switch variables := variables.(type) { case *rawVariables: // variables section is not mandatory if variables == nil { return nil } if l...
package archive import ( "ms/sun/shared/golib/go_map" "sync" ) // collections os user type masterCache struct { mp map[int]*go_map.ConcurrentIntMap mux sync.RWMutex } func newMasterCache() *masterCache { return &masterCache{ mp: make(map[int]*go_map.ConcurrentIntMap, 10000), } } fun...
// Copyright 2020 Kentaro Hibino. All rights reserved. // Use of this source code is governed by a MIT license // that can be found in the LICENSE file. // Package rdb encapsulates the interactions with redis. package rdb import ( "encoding/json" "errors" "fmt" "strconv" "time" "github.com/go-redis/redis/v7" ...
package main import ( "fmt" "net/url" "os/exec" "strings" ) func Parse(path string) (wh webHook, err error) { wh.Commits = []string{} wh.HeadCommit.ID, err = commitID(path) if err != nil { return webHook{}, err } branch, err := branch(path) if err != nil { return webHook{}, err } wh.Ref = fmt.Sprintf...
package submerge import ( "fmt" "sort" "strconv" "strings" "time" ) type subLine struct { Num int Time string Text1 string Text2 string } func (s *subLine) isAfter(sub2 *subLine) bool { if sub2 == nil { return false } if s == nil { return true } times := []string{s.Time, sub2.Time} sort.Strings...
// ------------------------------------------------------------------- // // salter: Tool for bootstrap salt clusters in EC2 // // Copyright (c) 2013-2014 Orchestrate, Inc. All Rights Reserved. // // This file is provided to you under the Apache License, // Version 2.0 (the "License"); you may not use this file // exce...
package internal import ( "context" "go.mongodb.org/mongo-driver/bson/bsoncodec" "go.mongodb.org/mongo-driver/mongo/readconcern" "go.mongodb.org/mongo-driver/mongo/readpref" "go.mongodb.org/mongo-driver/mongo/writeconcern" "time" "github.com/5xxxx/pie/driver" "github.com/5xxxx/pie/schemas" "go.mongodb.org/...
package handlers import ( "net/http" "strconv" "strings" "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding" "github.com/pkg/errors" "github.com/decentraland/content-service/data" "github.com/decentraland/content-service/storage" . "github.com/decentraland/content-service/utils" "github.com/go-re...
package main import ( "fmt" "log" "strings" "sync" "time" stan "github.com/nats-io/stan.go" ) // AsyncReport is the report from a function executed on a queue worker. type AsyncReport struct { FunctionName string `json:"name"` StatusCode int `json:"statusCode"` TimeTaken float64 `json:"timeTaken"`...
package main import ( "context" "fmt" "github.com/antihax/optional" "github.com/outscale/osc-sdk-go/osc" "os" ) func main() { client := osc.NewAPIClient(osc.NewConfiguration()) auth := context.WithValue(context.Background(), osc.ContextAWSv4, osc.AWSv4{ AccessKey: os.Getenv("OSC_ACCESS_KEY"), SecretKey: os...
package osbuild1 import ( "bytes" "encoding/json" "strings" "testing" "github.com/stretchr/testify/assert" ) func TestUnmarshal(t *testing.T) { resultRaw := `{ "success": true, "build": { "success": true, "stages": [ { "name": "org.osbuild.rpm", "id": "9eb0a6f6fd6e2995e107f5bcc6aa3b196...
// Copyright (C) 2015 Nicolas Lamirault <nicolas.lamirault@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 required ...
package menu import ( "fmt" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" "projja_telegram/command/util" "projja_telegram/model" ) func MakeProjectMenu(message *util.MessageData, project *model.Project) tgbotapi.MessageConfig { text := fmt.Sprintf("Работаем над проектом '%s'", project.Name) msg := ...
package remote import ( "net/http" "net/http/httptest" ) func createTestClient(h http.HandlerFunc) (*client, *httptest.Server) { s := httptest.NewServer(h) c := &client{ httpClient: s.Client(), baseUrl: s.URL, retries: 1, tokenId: "testid", token: "testtoken", } return c, s }
package _91_Decode_Ways import "testing" func TestNumDecodings(t *testing.T) { if ret := numDecodings("12"); ret != 2 { t.Errorf("wrong answer with %d", ret) } if ret := numDecodings("226"); ret != 3 { t.Errorf("wrong answer with %d", ret) } if ret := numDecodings("0"); ret != 0 { t.Errorf("wrong answer wi...
package utils const ( navigatePages = 8 // 私有 ) /* 用于分页的工具 */ type Page struct { List interface{} `json:"list"` // 对象纪录的结果集 Total int64 `json:"total"` // 总纪录数 Limit int64 `json:"limit"` // 每页显示纪录数 Pages ...
/* SPDX-License-Identifier: Apache-2.0 * Copyright (c) 2019-2020 Intel Corporation */ package ngcnef // URI : string formatted accordingding to IETF RFC 3986 type URI string // Dnai : string identifying the Data Network Area Identifier type Dnai string // DnaiChangeType : string identifying the DNAI change type /...
package main import ( "encoding/csv" "flag" "fmt" "image" "io" "log" "net/http" "net/url" "strconv" "github.com/zxc111/go-heatmap" "github.com/zxc111/go-heatmap/schemes" ) const maxInputLength = 10000 type csvpoint []string func (c csvpoint) X() float64 { x, _ := strconv.ParseFloat(c[0], 64) return x ...
package execenv import ( "bytes" "fmt" "io" "os" "path/filepath" "strings" "time" "github.com/dnephin/dobi/logging" git "github.com/gogits/git-module" "github.com/metakeule/fmtdate" "github.com/pkg/errors" fasttmpl "github.com/valyala/fasttemplate" ) const ( startTag = "{" endTag = "}" execI...
///////////////////////////////////////////////////////////////////// // arataca89@gmail.com // 20210417 // // func IndexFunc(s string, f func(rune) bool) int // // Retorna o índice da primeira ocorrência de caracter que satisfaz a // função f() ou -1 se não houver ocorrência. // // Fonte: https://golang.org/p...
/* Package sort provide different sorting functions around an expand variety type of slices. For more information which the best solution for your case, consult our documentation page http://www.algo.org */ package sort
package client import ( "time" "github.com/CyCoreSystems/ari" "github.com/CyCoreSystems/ari-proxy/proxy" "github.com/CyCoreSystems/ari/rid" ) type channel struct { c *Client } func (c *channel) Get(key *ari.Key) *ari.ChannelHandle { k, err := c.c.getRequest(&proxy.Request{ Kind: "ChannelGet", Key: key, ...
package ipa import ( "errors" "fmt" "os" "runtime" "testing" "github.com/iineva/ipa-server/pkg/seekbuf" ) func TestReadPlistInfo(t *testing.T) { printMemUsage() fileName := "test_data/ipa.ipa" // fileName := "/Users/steven/Downloads/TikTok (18.5.0) Unicorn v4.9.ipa" f, err := os.Open(fileName) if err !=...
//go:build linux // +build linux /* Copyright © 2021 SUSE LLC 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 routes import ( "net/http" "github.com/gorilla/mux" ) type Route struct { Uri string Method string Handler func(http.ResponseWriter, *http.Request) } func Load() []Route { routes := usersRoutes return routes } func SetupRoutes(r *mux.Router) *mux.Router { for _, route := range Load() { r.Ha...
package draw type IHandler interface { SetObject(obj IObject) GetControlById(id int) IControlBase GetControlByName(name string) IControlBase //GetControlDialog(id int) IDialogBase SetVisible(name string, isVisible bool) SetDisable(name string, isDisable bool) SetTitle(name string, title string) GetTitle(name...
/* * @lc app=leetcode.cn id=1207 lang=golang * * [1207] 独一无二的出现次数 */ package main // @lc code=start func uniqueOccurrences(arr []int) bool { counter := make(map[int]int) for i := 0; i < len(arr); i++ { counter[arr[i]]++ } occu := make(map[int]bool) for _, v := range counter { if occu[v] { return false ...
package main import ( "fmt" "net" ) // MySever is server func MySever(over func()) { defer func() { over() }() // 监听 l, err := net.Listen("tcp", ":8080") if err != nil { fmt.Printf("[server] listen err(%v)\n", err) return } defer func() { l.Close() }() for { // 等待连接 c, err := l.Accept() if...
// 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...
package response type GetNamespacesResponse struct { Namespaces []Namespace `json:"namespaces"` } type Namespace struct { Name string `json:"name"` Status string `json:"status"` Age string `json:"age"` }
package lib import ( "bytes" "encoding/json" "io/ioutil" "net/http" "net/url" "path" "text/template" ) type Client struct { BaseURL *url.URL HTTPClient *http.Client } type Country struct { Name string `json:"country"` Cases int `json:"cases"` TodayCases int ...
package timeutil import ( "time" ) //millisecond base func Now() int64 { return time.Now().UnixNano() / int64(time.Millisecond) }
package main import ( "crypto/sha256" "encoding/hex" "encoding/json" "fmt" "reflect" "strconv" "time" "github.com/iRajesha/experiments/src/panic" ) type Persons struct { name string `required:"true"` age int siblings []string } func main() { var stringType string fmt.Printf("%v,%T\n", stringT...
package leetcode func prisonAfterNDays(cells []int, N int) []int { size := len(cells) encoded := 0 for i, v := range cells { encoded |= v << uint(i) } visit := make(map[int]int) visit[encoded] = 0 seq := make(map[int]int) seq[0] = encoded for x := 1; x <= N; x++ { nxt := 0 for i := 1; i < size-1; i++ {...
package shader import ( "fmt" "io/ioutil" "strings" wrapper "github.com/akosgarai/opengl_playground/pkg/glwrapper" "github.com/go-gl/mathgl/mgl32" ) // LoadShaderFromFile takes a filepath string arguments. // It loads the file and returns it as a '\x00' terminated string. // It returns an error also. func Load...
// Copyright 2021 Google LLC // // 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 ...
// Copyright 2015 The Chromium 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 isolated defines the isolated common code shared by the client and // server. package isolated
package main import ( "bufio" "encoding/json" "flag" "fmt" "io" "log" "os" "os/user" "path/filepath" "sort" "strings" "time" ) type Document struct { Topic string Since time.Time Topics map[string]time.Duration } func (j *Document) Load(filename string) error { f, err := os.Open(filename) if err !...
// Copyright 2020 The Moov Authors // Use of this source code is governed by an Apache License // license that can be found in the LICENSE file. package customers import ( "encoding/json" "fmt" "testing" "github.com/moov-io/base" ) func TestStatus__json(t *testing.T) { cs := Status(10) valid := map[string]Sta...
package yarn import ( "bufio" "encoding/json" "fmt" "github.com/Sirupsen/logrus" "github.com/bitly/go-simplejson" "github.com/rootsongjc/magpie/docker" "github.com/rootsongjc/magpie/utils" "github.com/samalba/dockerclient" "github.com/spf13/viper" "io" "io/ioutil" "net/http" "os" "sort" "strings" "sync...
// Copyright 2014, 2016 Claudemiro Alves Feitosa Neto. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package ipe import ( "net/http" "github.com/gorilla/mux" ) type router struct { ctx *applicationContext mux *mux.Router route...
package parser import ( "HelloGo/crawler/fetcher" "HelloGo/crawler/model" "fmt" "regexp" ) var rInfo = regexp.MustCompile(`<a href="(http://album.zhenai.com/u/[\d]+)"[^>]*>([^<]+)</a>`) func ParseUserInfo(b []byte) (res model.ParseResult) { sub := rInfo.FindAllSubmatch(b, -1) var req = make([]model.Request, ...
package imdb import ( "encoding/json" "fmt" "regexp" "strconv" "sync" "time" "golang.org/x/text/language" htmlParser "github.com/jbowtie/gokogiri/html" "github.com/jbowtie/gokogiri/xml" ) // Item represents a single item (either a movie or an episode) type Item struct { id int title ...
package middleware import ( "database/sql" "encoding/json" // package to encode and decode the json into struct and vice versa "fmt" "go-postgres/models" // models package where User schema is defined "log" "net/http" // used to access the request and response object of the api "os" // used to read the en...
package controller import ( "errors" "net/http" "github.com/appditto/pippin_nano_wallet/apps/server/models/requests" "github.com/appditto/pippin_nano_wallet/libs/database/ent" "github.com/appditto/pippin_nano_wallet/libs/utils" "github.com/appditto/pippin_nano_wallet/libs/wallet" "github.com/mitchellh/mapstruc...
package main import "fmt" func main() { var tampil_mahasiswa = map[string]string{"Aldo":"182 cm","Yosep":"178 cm"} fmt.Println ("Aldo :",tampil_mahasiswa["Aldo"]) fmt.Println("Yosep : ",tampil_mahasiswa["Yosep"]) } func tampil_mahasiswa(x string, y string)(string,string) { var m = x ; var m1 = y ...
package models import "github.com/jinzhu/gorm" type Saying struct { gorm.Model Content string Author string Status int } func (Saying) TableName() string { return "saying" }
package utils import ( "testing" "time" "github.com/stretchr/testify/assert" ) func TestTestingClock(t *testing.T) { c := &TestingClock{ now: time.Unix(0, 0), } assert.Equal(t, int64(0), c.Now().Unix()) c.now = time.Unix(20, 0) assert.Equal(t, int64(20), c.Now().Unix()) assert.Equal(t, int64(20000000000...
package main import ( "context" "flag" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" "github.com/go-chi/cors" "github.com/hardstylez72/bblog/ad/pkg/group" "github.com/hardstylez72/bblog/ad/pkg/grouproute" "github.com/hardstylez72/bblog/ad/pkg/infra/logger" "github.com/hardstylez72/bblog/ad/pkg/in...
// gopack - Golang asset pipeline // https://github.com/wcamarao/gopack // MIT Licensed // package gopack // Open-ended interface to define a custom pipeline, // grouping assets by patterns, and allowing multiple // processors to be applied per group. // // Group - asset group or type name (e.g. JavaScripts). // ...
package handlers import ( "fmt" "net/http" ) // HelloHandler takes a GET parameter "name" and responds // with Hello <name>! in plaintext func HelloHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "text/plain") if r.Method != http.MethodGet { w.WriteHeader(http.StatusMethodNotAll...
package main import ( "bytes" "fmt" "net/http" "net/url" "os" "os/exec" "path/filepath" "strings" "sync" log "github.com/sirupsen/logrus" ) type handler struct { log *log.Logger config *config m sync.Mutex } func (h *handler) logResponse(r *http.Request, code int) { level := log.InfoLevel if code...
package fuctional_options import ( "crypto/tls" "time" ) // 使用一个builder类来做包装 type ServerBuilder struct { Server } func (sb *ServerBuilder) Create(addr string, port int) *ServerBuilder { sb.Server.Addr = addr sb.Server.Port = port // 其它代码设置其它成员的默认值 return sb } func (sb *ServerBuilder) WithProtocol(protocol st...
package main import ( "testing" ) func ReadProfileTest(t *testing.T) { } func CreateProfileTest(t *testing.T) { profile := map[string]interface{}{ "name": "reza andriyunanto", "age": 22, } }
// 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 cmd import ( "errors" "fmt" bosherr "github.com/cloudfoundry/bosh-agent/errors" boshlog "github.com/cloudfoundry/bosh-agent/logger" boshsys "github.com/cloudfoundry/bosh-agent/system" bmconfig "github.com/cloudfoundry/bosh-micro-cli/config" bmcpideploy "github.com/cloudfoundry/bosh-micro-cli/cpideploy...
package oper_log import ( "errors" "xorm.io/builder" "yj-app/app/yjgframe/db" "yj-app/app/yjgframe/utils/excel" "yj-app/app/yjgframe/utils/page" ) // //查询列表请求参数 type SelectPageReq struct { Title string `form:"title"` //系统模块 OperName string `form:"operName"` //操作人员 BusinessTypes int ...
package triangle import ( "sort" "math" ) const testVersion = 3 func KindFromSides(a, b, c float64) Kind { // If any of the sides is not a number then not a triangle. if math.IsNaN(a) || math.IsNaN(b) || math.IsNaN(c) { return NaT } // If any of the sides is positive infinity then not a triangle. if math.I...
package blueprint import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestDeepCopy(t *testing.T) { bpOrig := Blueprint{ Name: "deepcopy-test", Description: "Testing DeepCopy function", Version: "0.0.1", Packages: []Package{ {Name: "dep-packag...
// This file is subject to a 1-clause BSD license. // Its contents can be found in the enclosed LICENSE file. package evdev import ( "errors" "fmt" "os" ) // List of device types. // // These are used to look for specific input device types // using evdev.Find(). // // The returned devices may not necessarily be ...
/* * @lc app=leetcode id=23 lang=golang * * [23] Merge k Sorted Lists */ /** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func mergeKLists(lists []*ListNode) *ListNode { var ret *ListNode var last *ListNode var candidate *ListNode var candidate_i...
package dao import ( "fmt" "github.com/xormplus/xorm" "go.uber.org/zap" "mix/test/codes" entity "mix/test/entity/core/transaction" mapper "mix/test/mapper/core/transaction" "mix/test/utils/status" ) func (p *Dao) CreateAudit(logger *zap.Logger, session *xorm.Session, item *entity.Audit) (id int64, err error) ...
package socketman import ( "crypto/aes" "crypto/cipher" "io" ) //NewAESPool instantiates a pool of aes encryptor/decryptor func NewAESPool(key []byte) (*AESPool, error) { block, err := aes.NewCipher(key) if err != nil { return nil, err } return &AESPool{ block: block, }, nil } //AESPool will create aes s...
package main import "fmt" func main() { fmt.Println("another-branch branch (default branch)") }
// 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 admin import ( "fmt" "github.com/rs/zerolog/log" "net/http" "net/url" "reflect" "toutiao/downloader" "toutiao/tools" "time" ) // 提交作品 const posturl = "http://mp.toutiao.com/core/article/edit_article_post/?downloader=mp&type=purevideo" type ArticleForm struct { ArticleAdType int `json:"article_ad_...
package seg import ( "bufio" "fmt" "io" "log" "os" "unicode" ) var isLoadDictFlag = false //TrieNode 一个节点一个汉字信息 type TrieNode struct { Count int //汉字出现次数 Son map[rune]*TrieNode //后继节点 } //Trie 用来保存整个字典 type Trie struct { Root *TrieNode } //Add 向Trie中新增汉子节点 func (self *Trie) Add(srune []r...
package factory import ( "errors" "fmt" "github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp" "github.com/HNB-ECO/HNB-Blockchain/HNB/bccsp/sw" ) const ( SoftwareBasedFactoryName = "SW" ) type SWFactory struct{} func (f *SWFactory) Name() string { return SoftwareBasedFactoryName } func (f *SWFactory) Get(config *Fac...
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
package scoring import ( "github.com/luuphu25/data-sidecar/stat" "github.com/luuphu25/data-sidecar/util" ) // HighwayVal is the kind of value a highway can hold type HighwayVal struct { High float64 Low float64 } // HighwayExits is the kind of value that exits can be/hold type HighwayExits struct { High bool ...
// +build disgord_removeDiscordMutex package disgord // Lockable is removed on compile time since it holds no content. This allows the removal of mutexes if desired by the // developer. type Lockable struct{} func (l *Lockable) RLock() {} func (l *Lockable) RUnlock() {} func (l *Lockable) Lock() {} func (l *Loc...
// jeff@archlinux.org package main import ( "bufio" "crypto/sha1" "encoding/json" "encoding/xml" "fmt" "io/ioutil" "net/http" "os" "os/exec" "path/filepath" "sync/atomic" ) var CacheFile string func init() { xch := os.Getenv("XDG_CACHE_HOME") if xch == "" { home := os.Getenv("HOME") xch = filepath.J...
package huobi_websocket import ( . "exchange_websocket/common" "strings" ) // huobi symbols type HuobiSymbol struct { HuobiUsdtSymbol []string HuobiBtcSymbol []string HuobiEthSymbol []string HuobiSymbols []string } func NewHuobiSymbol() *HuobiSymbol { hb := new(HuobiSymbol) return hb.huobiSymbolInit() }...
package 摩尔投票 func majorityElement(nums []int) int { candidateNum := getMajorElementCandidate(nums) minCountOfMajorElement := len(nums)/2 + 1 if getCountOfNum(nums, candidateNum) >= minCountOfMajorElement { return candidateNum } else { return -1 } } func getMajorElementCandidate(nums []int) int { countOfCandi...
package easypost import ( "context" "net/http" "net/url" ) // PickupRate contains data about the cost of a pickup. type PickupRate struct { ID string `json:"id,omitempty"` Object string `json:"object,omitempty"` Mode string `json:"mode,omitempty"` CreatedAt *DateTime `json:"created_at,o...
package transform import ( "fmt" "github.com/sparkymat/webdsl/css" "github.com/sparkymat/webdsl/css/size" ) func TranslateX(distance size.Size) css.Property { return css.Property{}.WithPropertyType("transform").WithValues(fmt.Sprintf("translateX(%v)", distance)) }
package main import ( "fmt" "log" "net/http" "time" "github.com/julienschmidt/httprouter" ) type Event struct { TimeToShow time.Time TimeEndShow time.Time Name string } func main() { router := httprouter.New() router.GET("/healthz", Healthz) log.Println("Listening at port 1337") go func() { lo...
package main import ( "golang/helper" "testing" ) func TestLetterCasePermutation(t *testing.T) { input := "a1b2" expect := []string{"a1b2", "a1B2", "A1b2", "A1B2"} helper.AssertStringArr(letterCasePermutation(input), expect, t) input = "3z4" expect = []string{"3z4", "3Z4"} helper.AssertStringArr(letterCasePe...
package main import ( "zhiyuan/scaffold/internal/server/http" ) //var log = logrus.New() //var isConnected bool func main() { http.New() }
package ca import ( "crypto" "crypto/rand" "crypto/sha1" "crypto/x509" "crypto/x509/pkix" "encoding/asn1" "encoding/hex" "encoding/json" "errors" "math/big" "time" "github.com/cloudflare/cfssl/certdb" "github.com/cloudflare/cfssl/config" "github.com/cloudflare/cfssl/csr" "github.com/cloudflare/cfssl/he...
package command import ( "bufio" "bytes" "flag" "fmt" _ "github.com/codegangsta/cli" "golang.org/x/text/unicode/norm" "io/ioutil" "os" "path/filepath" "regexp" "strings" pt "path" ) const PathSeparator = string(filepath.Separator) type ValidFilenameFunc func(string) bool func IsFile(path string) bool {...
package main import ( "bytes" "fmt" "io" "strings" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) func TestDumpCollectionTo_Ok(t *testing.T) { mockedMongoLib := new(mockMongoLib) mongoService := newMongoService("127.0.0.1:27010,127.0.0.2:27010", mockedMongoLib, n...
package common const ( PermissionVisitor = 0 PermissionAdmin = 1 )
package main import ( "agenda" "os" log "util/logger" cmd "github.com/Binly42/agenda-go/cmd" ) // var logln = util.Log // var logf = util.Logf func init() { } func main() { agenda.LoadAll() defer agenda.SaveAll() if err := cmd.RootCmd.Execute(); err != nil { log.Println(err) os.Exit(1) // FIXME: } }
package pxf_test import ( "errors" "github.com/greenplum-db/gp-common-go-libs/operating" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "os" "pxf-cli/pxf" ) var _ = Describe("RemoteCommandToRunOnSegments", func() { BeforeEach(func() { _ = os.Setenv("GPHOME", "/test/gphome") _ = os.Setenv("PXF_CONF",...
package tests import ( "testing" "time" "github.com/GoAdminGroup/go-admin/modules/config" "github.com/GoAdminGroup/go-admin/tests/frameworks/gin" ) func TestBlackBoxTestSuitOfBuiltInTables(t *testing.T) { BlackBoxTestSuitOfBuiltInTables(t, gin.NewHandler, config.DatabaseList{ "default": { Host: ...
package tea func Encrypt(v0, v1, k0, k1, k2, k3 uint32) (uint32, uint32) { var sum uint32 = 0x0 const delta uint32 = 0x9e3779b9 for i := 0; i < 32; i++ { sum += delta v0 += ((v1 << 4) + k0) ^ (v1 + sum) ^ ((v1 >> 5) + k1) v1 += ((v0 << 4) + k2) ^ (v0 + sum) ^ ((v0 >> 5) + k3) } return v0, v1 } // void decr...
package file import "os" // exist returns if the file exists func exist(path string) (exist bool, err error) { _, err = os.Stat(path) if err == nil { exist = true return } if os.IsNotExist(err) { exist = false err = nil return } return }
package main import ( "fmt" "math/rand" "time" ) func f(n int) { for i := 0; i < 3; i++ { fmt.Println(n, ":", i) amt := time.Duration(rand.Intn(250)) time.Sleep(time.Millisecond * amt) } } // Go supports concurrency func main() { for i := 0; i < 3; i++ { go f(i) // The `go` keyword forces the compi...
package main import ( "flag" "fmt" "io/ioutil" "strings" ) func main() { flag.Parse() fileBytes, _ := ioutil.ReadFile(flag.Args()[0]) fileStr := string(fileBytes) testCases := parseProblem(fileStr) for _, testCase := range testCases { fmt.Println(solve(testCase)) } } func parseProblem(input string) []...
package src import ( "fmt" "time" ) type Publisher struct { subscriptions []func(string) } func (p *Publisher) Start() { fmt.Println("Publisher: Wasting time...") time.Sleep(time.Second * 5) p.end() } func (p *Publisher) end() { fmt.Println("Publisher: Notifying subscribers that I am done wasting time...") ...
package pbkdf2_test import ( "testing" "github.com/stretchr/testify/assert" "cpl.li/go/cryptor/internal/crypt/pbkdf2" "cpl.li/go/cryptor/internal/crypt/ppk" ) func TestPBKDF2(t *testing.T) { t.Parallel() expected := "28df0b93627d5b50ed4fef574e774a00ac634cbd3395d0a57e769581e806f82f" expectedPub := "a5f68...
package writers import ( "fmt" "io" "strings" "text/template" "github.com/rightscale/rsc/gen" ) // ClientWriter struct exposes methods to generate the go API client code type ClientWriter struct { headerTmpl *template.Template resourceTmpl *template.Template } // NewClientWriter is the client writer facto...
package main import ( "TskSch/msgQ" "TskSch/logger" "TskSch/resultDB" "TskSch/mailer" "fmt" "github.com/garyburd/redigo/redis" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" "bytes" "os/exec" "strconv" "time" "encoding/json" "net/http" "io/ioutil" "code.google.com/p/goconf/conf" "os" "sync" "strings" ) t...