text
stringlengths
11
4.05M
// Install view - shows install menu, and executes install upon chosen options // ================================================= package views import ( "strings" "net/http" "text/template" ) type InstallData struct { Logo string ClientSecret string FoldersMap map[string]string AvailableO...
package main //392. 判断子序列 //给定字符串 s 和 t ,判断 s 是否为 t 的子序列。 // //你可以认为 s 和 t 中仅包含英文小写字母。字符串 t 可能会很长(长度 ~= 500,000),而 s 是个短字符串(长度 <=100)。 // //字符串的一个子序列是原始字符串删除一些(也可以不删除)字符而不改变剩余字符相对位置形成的新字符串。(例如,"ace"是"abcde"的一个子序列,而"aec"不是)。 // //示例1: //s = "abc", t = "ahbgdc" // //返回true. // //示例2: //s = "axc", t = "ahbgdc" // //返回fal...
package engineserver import ( "encoding/json" "github.com/engelsjk/faadb/internal/codes" "github.com/engelsjk/faadb/internal/service" "github.com/engelsjk/faadb/internal/utils" ) type EngineService struct { Name string svc *service.Service codes Codes } func NewEngineService(dataPath, dbPath string, reloa...
package middle_test import ( "net/http" "net/http/httptest" "testing" "github.com/labstack/echo/v4" "github.com/shandysiswandi/echo-service/internal/infrastructure/app/middle" "github.com/stretchr/testify/assert" ) func TestLogger(t *testing.T) { // setup req := httptest.NewRequest(http.MethodGet, "/", nil) ...
package debug import ( "net/http" "strconv" "github.com/pokemium/worldwide/pkg/util" ) func (d *Debugger) Trace(w http.ResponseWriter, req *http.Request) { switch req.Method { case "GET": if !*d.pause { http.Error(w, "trace API is available on pause state", http.StatusBadRequest) return } q := req....
package kubectl import ( "context" "github.com/pkg/errors" "io" v1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes/scheme" ) // ReadLogs reads the logs and returns a string func (client *client) ReadLogs(ctx context.Context, namespace, podName, containerName string, lastContainerLog bool, tail *int64) (string,...
package main import ( "encoding/json" "fmt" "log" "net/http" "database/sql" "github.com/gorilla/mux" _ "github.com/lib/pq" ) const ( ACCIDENTS_QUERY = `SELECT id,regis_no,ev_id,acft_make,afm_hrs,afm_hrs_last_insp,date_last_insp,owner_acft FROM events WHERE regis_no ~* '%s'` EVENTS_QUERY = `SELECT id,regi...
package oauth2bearer import ( "fmt" "log" "reflect" "time" "golang.org/x/oauth2" ) // this loops on one goroutine, waiting until the token is about to expire // and then grabbing a new one func mainRefreshLoop(source TokenSource) { timeToWait := 0.0 for { time.Sleep(time.Duration(timeToWait) * time.Second) ...
package statefulset import ( "context" "hash/fnv" "reflect" "strconv" dynatracev1beta1 "github.com/Dynatrace/dynatrace-operator/src/api/v1beta1" "github.com/Dynatrace/dynatrace-operator/src/controllers" "github.com/Dynatrace/dynatrace-operator/src/controllers/dynakube/activegate/capability" "github.com/Dynatr...
package timetosell2 func maxProfit(prices []int) int { if len(prices) <= 1 { return 0 } totalProfit := 0 subProfit := 0 buy := prices[0] for i, this := range prices[1:] { last := prices[i] if last <= this { // a profit to be made subProfit = this - buy } else { // prices have gone down since...
package main import ( "fmt" "time" "github.com/garyburd/redigo/redis" ) func checkErr(errMasg error) { if errMasg != nil { panic(errMasg) } } func main() { //建立连接 c, err := redis.Dial("tcp", "127.0.0.1:6379") checkErr(err) defer c.Close() //查看redis已有数据量 size, err := c.Do("DBSIZE") fmt.Printf("size is %d...
package matchers_test import ( "errors" "github.com/hashicorp/go-multierror" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" pkgerrors "github.com/pkg/errors" . "github.com/rgalanakis/golangal/errmatch" ) var _ = Describe("BeCausedBy matcher", func() { e := errors.New("blah") It("matches if the erro...
package clock import "fmt" type clock struct { hour, minute int } func New(hour, minute int) clock { return clock{hour, minute} } func (c clock) Add(minute int) clock { var m int = (c.hour * 60) + c.minute + minute m %= 24 * 60 if m < 0 { m += 24 * 60 } c.hour = m / 60 c.minute = m % 60 return c } fun...
package serializer import ( "bytes" "encoding/binary" "fmt" "math" "math/big" "reflect" "sort" "time" ) type ( // ArrayOf12Bytes is an array of 12 bytes. ArrayOf12Bytes = [12]byte // ArrayOf20Bytes is an array of 20 bytes. ArrayOf20Bytes = [20]byte // ArrayOf32Bytes is an array of 32 bytes. ArrayOf32B...
// Implements the 'customer' web service package services /* Copyright (C) 2015 J. Robert Wyatt This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) a...
package main import ( "fmt" "io/ioutil" "log" "os" ) func main() { // ioutil.WriteFile will create/open, write a slice of byte and close. // quick and dirty err := ioutil.WriteFile("test.txt", []byte("Hey mamma!\r\nI'm on tv :)"), 0666) if err != nil { log.Fatalln(err) } file, err := os.OpenFile("test.txt...
package main import ( "github.com/astaxie/beego/config" "github.com/astaxie/beego/logs" ) type Conf struct { redisConf RedisConf logConf LogConf } var ( // redisConf *RedisConf myConf *Conf ) func loadLogConf(conf config.Configer) { myConf.logConf.LogPath = conf.String("log::log_path") myConf.logConf.LogL...
// 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...
// Copyright (C) 2018 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...
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved. // This program and the accompanying materials are made available under the terms of the 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 Licen...
package lru import ( "container/list" ) /* LRU: 最近最少使用,核心思想是(如果数据最近被访问过,那么将来被访问的几率也更高) 1. 新数据插入到链表头部; 2. 每当缓存命中(即缓存数据被访问),则将数据移到链表头部; 3. 当链表满的时候,将链表尾部的数据丢弃。 */ type LRUCache struct { capacity int cache map[int]*list.Element list *list.List } type Pair struct { key int value int } func Constru...
package participant import "t32/game" type spyCoordinates struct { X, Y int } type spyClient struct { Coordinates []spyCoordinates game.Board game.Player Message string ReqWaitingForOthers bool ReqItsAnothersTurn bool ReqItsYourTurn bool ReqStalemate bool ReqAnotherWon bool ReqYouWon ...
package swift import ( "regexp" "strings" "github.com/anecsoiu/banking/country" ) const ( // lengthSwift8 represents length of type Swift8 swift codes. lengthSwift8 = 8 // lengthSwift11 represents length of type Swift11 swift codes. lengthSwift11 = 11 ) var ( // regexBankCode holds Regexp for matching bank...
package mondohttp import ( "net/http" "net/url" "strings" ) // NewAuthCodeAccessRequest creates a request for exchanging authorization codes. // https://getmondo.co.uk/docs/#exchange-the-authorization-code func NewAuthCodeAccessRequest(clientID, clientSecret, redirectURI, authCode string) *http.Request { body := ...
package mysql import ( "reflect" ) type Field struct { *FieldStruct *FieldValue } func NewField(fieldStruct *FieldStruct, fieldValue *FieldValue) *Field { return &Field{ FieldStruct: fieldStruct, FieldValue: fieldValue, } } type FieldValue struct { Value []byte NeedUpdate bool } func NewInitFieldV...
package ispalindrome import ( "strings" "unicode" ) func isPalindrome(s string) bool { if len(s) <= 1 { // 空串和单个字符 return true } str := strings.ToLower(s) var i, j int for i, j := 0, len(str)-1; i < j; { if unicode.IsLetter(rune(str[i])) == false && unicode.IsDigit(rune(str[i])) == false { i++ c...
package api import ( "bytes" "context" "encoding/json" "errors" "fmt" "net/http" "github.com/chadweimer/gomp/db" "github.com/chadweimer/gomp/upload" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/rs/zerolog" "github.com/rs/zerolog/hlog" "github.com/rs/zerolog/log" ) // ----...
package test import ( "github.com/muidea/magicOrm/provider" "testing" "time" "github.com/muidea/magicOrm/orm" ) func TestLocalExecutor(t *testing.T) { orm.Initialize() defer orm.Uninitialize() config := orm.NewConfig("localhost:3306", "testdb", "root", "rootkit") provider := provider.NewLocalProvider("defau...
/* Copyright 2020 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...
package main import ( "encoding/json" "fmt" "regexp" "sort" "strings" "syscall/js" "github.com/fanaticscripter/EggContractor/api" ) var _playerIdPattern = regexp.MustCompile(`(?i)^EI\d+$`) type result struct { Successful bool `json:"successful"` Data interface{} `json:"data"` Err strin...
package main import ( "flag" "log" "net" "golang.org/x/net/ipv4" ) var ( listenAddr = flag.String("listen-addr", ":10000", "listen addr") batchSize = flag.Int("batch-size", 1000, "batch size") ) func main() { flag.Parse() ra, err := net.ResolveUDPAddr("udp", *listenAddr) if err != nil { log.Fatal(err) ...
package goxf import ( "encoding/json" "fmt" "github.com/kramerdust/goxf/client" "io/ioutil" "net/http" "strings" "time" ) const oxfordURL = "https://od-api.oxforddictionaries.com:443/api/v2" // Client is Dictionary API client type Client struct { appID string appKey string httpClient *http.Client ...
package commands import ( "fmt" "github.com/brooklyncentral/brooklyn-cli/api/entity_policies" "github.com/brooklyncentral/brooklyn-cli/command_metadata" "github.com/brooklyncentral/brooklyn-cli/error_handler" "github.com/brooklyncentral/brooklyn-cli/net" "github.com/brooklyncentral/brooklyn-cli/scope" "github.c...
/* * This file is simply a mirror of the interfaces in interfaces/interfaces.go. * This was done in order to prevent an import cycle. */ package cop import ( "fmt" "os" real "github.com/hyperledger/fabric/cop/api" def "github.com/hyperledger/fabric/cop/lib/defaultImpl" ) // Mgr is the main interface to COP f...
package micro import ( "context" "errors" "fmt" "net" "net/http" "net/http/httptest" "testing" "time" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/stretchr/testify/assert" "google.golang.org/grpc" ) var reverseProxyFunc ReverseProxyFunc var httpPort, grpcPort uint16 func init() { reverse...
/*------------------------------------------------------------------------- * * discoverer.go * Discoverer interface * * * Copyright (c) 2021, Alibaba Group Holding Limited * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * ...
// 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 typec import ( "bytes" "context" "encoding/json" "io/ioutil" "net/http" "net/http/httptest" "os" "path" "time" "chromiumos/tast/ctxutil" "chromiumos/tast...
package flow import ( "github.com/futurehomeno/fimpgo" "github.com/futurehomeno/fimpgo/fimptype" actfimp "github.com/thingsplex/tpflow/node/action/fimp" trigfimp "github.com/thingsplex/tpflow/node/trigger/fimp" "github.com/imdario/mergo" "github.com/mitchellh/mapstructure" "strings" ) func (fl *Flow) SendInclu...
package validate import ( "fmt" "testing" ) func ExampleV_Validate() { type X struct { A string `validate:"long"` B string `validate:"short"` C string `validate:"long,short"` D string } vd := make(V) vd["long"] = func(i interface{}) error { s := i.(string) if len(s) < 5 { return fmt.Errorf("%q i...
// 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 clipboardhistory import ( "context" "fmt" "strings" "time" "chromiumos/tast/ctxutil" "chromiumos/tast/errors" "chromiumos/tast/local/chrome" "chromiumos/tas...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package utility import ( "testing" "github.com/mattermost/mattermost-cloud/model" "github.com/golang/mock/gomock" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" ) func Tes...
package engine // movegen.go implements the move generator for Blunder. import ( "fmt" ) const ( // These masks help determine whether or not the squares between // the king and it's rooks are clear for castling F1_G1, B1_C1_D1 = 0x600000000000000, 0x7000000000000000 F8_G8, B8_C8_D8 = 0x6, 0x70 ) // Generate a...
package main import ( "encoding/json" "errors" "net/http" "strconv" "strings" "github.com/johnamadeo/server" ) const ( // NoMaxRoundErr : TODO NoMaxRoundErr = "converting driver.Value type <nil>" // TimestampFormat : Postgres timestamp string template patterns can be found in https://www.postgresql.org/doc...
package todo import ( "errors" "time" "github.com/t-ash0410/tdd-sample/backend/internal/api/todo/entities" ) type SuccessListUsecase struct{} func (u SuccessListUsecase) Handle(result *[]entities.Task) error { *result = append(*result, entities.Task{ Id: "", Name: "", Description: "", Up...
package pack import ( "testing" "time" ) func Test_GetInfoFile_ReturnsCorrectTimeFormat(t *testing.T) { goLaunchDate := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC) actual := getInfoFileFormattedTime(goLaunchDate) expected := "2009-11-10T23:00:00Z" if expected != actual { t.Errorf("invalid infof...
package main import ( "fmt" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "math/rand" "net/http" "time" ) func main() { counter := prometheus.NewCounter(prometheus.CounterOpts{ Name:"example_counter", }) rand.Seed(time.Now().Unix()) prometheus...
package main import "fmt" func requester(typeName string) string { return fmt.Sprintf(`func (x *%[1]sRequestType) Request(eBayAuthToken, siteID string) (response %[1]sResponseType, err error) { if x.RequesterCredentials == nil { x.RequesterCredentials = &XMLRequesterCredentialsType{} } x.RequesterCredential...
// Package c2netapi provides a rest api for c2net iot hub functions package c2netapi import ( "database/sql" "encoding/json" "fmt" "net/http" _ "github.com/mattn/go-sqlite3" log "github.com/sirupsen/logrus" ) type HubId struct { Id int `json:"id"` } func InsertHubId(w http.ResponseWriter, r *http.Request) {...
package environment import ( "testing" "github.com/bingo-lang/bingo/object" ) func TestEnvironment(t *testing.T) { key1 := "random1" key2 := "random2" obj1 := object.Integer{Value: 1} obj2 := object.Integer{Value: 2} parent := New(nil) parent.Set(key1, obj1) parent.Set(key2, obj1) environment := New(parent...
package nsq import ( "encoding/json" "jkt/gateway/hotel" "jkt/jktgo/log" "jkt/jktgo/message" "time" "github.com/nsqio/go-nsq" ) // ConsumerService 用于描述一个服务 type ConsumerService struct{} // HandleMessage 用于处理消息 func (cs *ConsumerService) HandleMessage(msg *nsq.Message) error { log.Debug("接受到的消息是:" + string(ms...
package main import ( "fmt" "strconv" "strings" ) func isDigit(s string) bool { digits := "+-*/" return !strings.Contains(digits, s) } func evalRPN(s []string) int { stack := []int{} for i := 0; i < len(s); i++ { if isDigit(s[i]) { num, _ := strconv.Atoi(s[i]) stack = append(stack, num) } else { ...
package api import ( dbm "github.com/tendermint/tm-db" "sync" ) // frame stores all Iterators for one contract type frame []dbm.Iterator // iteratorStack contains one frame for each contract, indexed by a counter // 10 is a rather arbitrary guess on how many frames might be needed simultaneously var iteratorStack ...
package handlers import ( "net/http" "github.com/gtongy/demo-echo-app/errors" "github.com/gtongy/demo-echo-app/models" "github.com/gtongy/demo-echo-app/mysql" "github.com/labstack/echo" ) var Task task type task struct{} func (t *task) Get(c echo.Context) error { var tasks []models.Task db := mysql.GetDB() ...
package number import ( "shared/utility/rand" "testing" ) func TestNewYggdrasilMail(t *testing.T) { set := NewSortedInt64sSet() for i := 0; i < 1000; i++ { set.Add(int64(rand.RangeInt(0, 1000))) } t.Log(set) }
package generativerecursion // File contains Gauss elimination algorithm // SOE is a non empty matrix // SOE = system of equations like // 2x + 2y + 3z = 10 // 2x + 5y + 12z = 31 // 4x + y - 2z = 1 // // data example: [][]int{{2,2,3,10}, {2,5,12,31}, {4,1,-2,1}} type SOE []Equation // TSOE is a triangular SOE...
package main import ( "encoding/json" "github.com/gorilla/mux" "log" "net/http" ) type Article struct { Id string `json:"id,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` } var articles []Article func viewHandler(response http.ResponseWriter...
package initialize import ( "crypto/rand" "fmt" "log" "os" "github.com/ejcx/passgo/v2/pc" "github.com/ejcx/passgo/v2/pio" "golang.org/x/crypto/nacl/box" ) const ( saltLen = 32 configFound = "A passgo config file was already found." ) // Init will initialize a new password vault in the home directory. f...
package Contains_Duplicate_III import ( "testing" "github.com/stretchr/testify/assert" ) func TestContainsDuplicates(t *testing.T) { ast := assert.New(t) ast.Equal(false, containsNearbyAlmostDuplicate([]int{1,5,9,1,5,9}, 2, 3)) ast.Equal(true, containsNearbyAlmostDuplicate([]int{1, 2, 3, 1}, 3, 0)) ast.Equal(...
package logger import ( "fmt" "myRPC/util" "os" "path/filepath" "time" ) const ( default_path = "../logs/" default_max_size = 50000000 ) //文件日志输出器 type FileOutputer struct { //文件句柄 file *os.File //文件最大 maxSize int64 //文件路径 path string //原始文件名 originFileName string //当前文件名 ...
package anton // SLAVE CONSOLIDATION CHECKED import ( "fmt" "strconv" "strings" ) /* Compare Lines Function Breakdown: - Line Method - CompareSlaveLineToMasterLine - ValidateSingleLine - Master - Slave - ValidateAgainstProfile - ValidateAgainstLine - CompareJuiceValues - CompareSpreadLine ...
// 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 interfaces type ErrorResponse struct { Data string `json:"data"` Status int `json:"status"` } type SpectraCreatedResponse struct { Data SpectraIdResponse `json:"data"` Status int `json:"status"` } type SpectraIdResponse struct { Id string `json:"id"` }
package autocomplete import ( "testing" ) func TestCompletionForBash(t *testing.T) { cmd := NewAutoCompleteCommand() err := cmd.Execute() if err != nil { t.Fatal(err) } } func TestCompletionForNotBash(t *testing.T) { opts := &autocompleteOptions{ acType: "zsh", } err := runAutoComplete(nil, opts) if e...
package constant const ( OrderCommandBusAddr = "192.168.99.100:4150" OrderCommandTopic = "command_order" )
package main import ( "LeetCodeGo/base" "LeetCodeGo/utils" "fmt" "sort" ) type NodeInfo struct { value int y int } type NodeInfoSlice []NodeInfo func (slice NodeInfoSlice) Swap(i, j int) { slice[i], slice[j] = slice[j], slice[i] } func (slice NodeInfoSlice) Len() int { return le...
package printout import ( "fmt" "time" "strings" "strconv" "../ds" "github.com/jroimartin/gocui" ) func Overview(g *gocui.Gui) error { var yearO, monthO, dayO string var year, month, day string var yearN, monthN, dayN int var maxX int var err error var v *gocui.View var index int var minX int = 136 ma...
//+build integration package collections import ( "strings" "github.com/crowleyfelix/star-wars-api/server/database/mongodb/models" "github.com/crowleyfelix/star-wars-api/server/errors" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/satori/go.uuid" ) var _ = Describe("Planets", func() { va...
package daemon import ( "fmt" "log" "os" "os/exec" "path/filepath" "time" "github.com/kiyonlin/dawn/config" ) const envDaemon = "DAWN_DAEMON" const envDaemonWorker = "DAWN_DAEMON_WORKER" var stdoutLogFile *os.File var stderrLogFile *os.File var osExit = os.Exit func Run() { if isWorker() { return } //...
// Copyright (c) 2016-2019 Uber Technologies, 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...
package main import( "fmt" "io" "os" ) type MyReader struct{ Str string } func (mr MyReader) Read(b []byte)( count int, err error){ var buffLen, strLen, readLen int = len(b),len(mr.Str), 0; readLen = buffLen; if strLen< readLen{ readLen = strLen; } for i:=0; i< readLen; i++{ b[i] =...
package model import ( "github.com/layer5io/meshkit/errors" ) const ( ErrInvalidRequestCode = "1000" ErrNilClientCode = "1001" ErrCreateDataCode = "1002" ErrQueryCode = "1003" ErrMeshsyncSubscriptionCode = "1004" ErrOperatorSubscriptionCode = "1...
package bus import ( "context" "fmt" "log" "strconv" "sync" "time" ) // stderrLogger 默认错误日志 type stderrLogger struct{} func (stderrLogger) Errorf(format string, args ...interface{}) { log.Println(fmt.Sprintf("easy-bus: %s", fmt.Sprintf(format, args...))) } // nullIdempotent 空的幂等实现 type nullIdempotent struct{...
/* * @lc app=leetcode id=283 lang=golang * * [283] Move Zeroes * * https://leetcode.com/problems/move-zeroes/description/ * * algorithms * Easy (57.54%) * Likes: 3731 * Dislikes: 121 * Total Accepted: 825.9K * Total Submissions: 1.4M * Testcase Example: '[0,1,0,3,12]' * * Given an array nums, writ...
package complex import ( "errors" "log" "os" "time" flutter "github.com/go-flutter-desktop/go-flutter" "github.com/go-flutter-desktop/go-flutter/plugin" ) // Example demonstrates how to call a platform-specific API to retrieve // a complex data structure type Example struct { channel *plugin.MethodChannel } ...
// Each new term in the Fibonacci sequence is generated by adding the previous // two terms. By starting with 1 and 2, the first 10 terms will be: // // 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... // // By considering the terms in the Fibonacci sequence whose values do not // exceed four million, find the sum of the even-va...
// Showcase the `binding` feature from gin. based on: // https://github.com/gin-gonic/gin#model-binding-and-validation // // Uage examples: // // 1. curl --data '{"user":"andi", "pass":"123", "pin":""}' -X POST 'localhost:8080/login' // // results: {"status":"you are logged in"} // // 2. curl --data '{"user":"carl",...
package gha import ( "bufio" "fmt" "io/ioutil" "os" "syscall" "golang.org/x/crypto/ssh/terminal" ) func fileExist(fname string) bool { _, err := os.Stat(fname) return err == nil } // CLI gets Psersonal access token of GitHub. // username and password are got from STDIN // And save key to the file. // If you...
package routers import ( "github.com/astaxie/beego" "webserver/controllers/account" "webserver/controllers/auth" "webserver/controllers/chat" "webserver/controllers/forum" "webserver/controllers/home" "webserver/controllers/message" //"webserver/controllers/phonecall" "webserver/controllers/notify" //"webser...
package crcind import ( "github.com/jgolang/config" "github.com/jgolang/log" "github.com/jhuygens/searcher-engine" ) var crcindSearcher = Searcher{} func init() { name := config.GetString("searchers.crcind") err := searcher.RegisterSearcher(name, crcindSearcher) if err != nil { log.Fatal(err) return } lo...
package majiangserver import ( "logger" //"sort" ) type MaJiangPattern struct { id int32 ptype int32 cType int32 cards []*MaJiangCard isShowPattern bool } //新建一个模式 func NewPattern(ptype int32, cards []*MaJiangCard, isShowPattern bool) *MaJiangPattern { if cards == nil || le...
package ewkb import ( "testing" "github.com/paulmach/orb" "github.com/paulmach/orb/encoding/internal/wkbcommon" ) func TestLineString(t *testing.T) { large := orb.LineString{} for i := 0; i < wkbcommon.MaxPointsAlloc+100; i++ { large = append(large, orb.Point{float64(i), float64(-i)}) } cases := []struct {...
package sandstormhttpbridge import ( "context" "errors" "net" "os" "time" bridge "zenhack.net/go/tempest/capnp/sandstorm-http-bridge" "capnproto.org/go/capnp/v3" "capnproto.org/go/capnp/v3/rpc" ) // Connect to the API socket, using exponential backoff to wait for the bridge to // start listening. // // TODO...
package routers import ( "opscenter/controllers" "github.com/astaxie/beego" ) func init() { beego.Router("/", &controllers.IndexController{}) beego.Router("/regist",&controllers.RegistController{}) beego.Router("/login",&controllers.LoginController{}) beego.Router("/logout",&controllers.LogoutUserController{...
package sync import ( "fmt" "os/exec" "strings" "time" log "github.com/sirupsen/logrus" ) // StartRsync path to target rsync server on given interval func StartRsync(done <-chan struct{}, host string, port int, syncs []Sync, interval time.Duration) { go func() { for { select { case <-time.After(interva...
package devices import ( "math/rand" "time" ) func randomizeCollection() time.Duration { min := 0 max := 300 rand.Seed(time.Now().UTC().UnixNano()) i := rand.Intn(max - min) + min return time.Duration(int64(i)) }
package session import ( "github.com/garyburd/redigo/redis" "sync" ) type RedisSession struct { pool *redis.Pool rwlock sync.RWMutex } func NewRedisSession(id string) *RedisSession { return &RedisSession{} } func (r *RedisSession) Set(key string, value interface{}) (err error) { return } func (r *RedisSess...
/* 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...
package main import ( "bytes" "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "net/url" "strings" ctx "golang.org/x/net/context" "golang.org/x/oauth2/clientcredentials" ) // UploadConfig represents the basic configuration necessary to connect // to the database. type UploadConfig struct { SiteURL ...
package nopaste import ( "log" "net/http" ) const MsgrRoot = "/irc-msgr" func RunMsgr(configFile string) error { var err error config, err = LoadConfig(configFile) if err != nil { return err } var chs []MessageChan if config.IRC != nil { ircCh := make(IRCMessageChan, MsgBufferLen) chs = append(chs, irc...
package cli import ( "fmt" "os" "path" "github.com/bitrise-io/bitrise-plugins-analytics/configs" "github.com/bitrise-io/bitrise-plugins-analytics/version" bitriseConfigs "github.com/bitrise-io/bitrise/configs" "github.com/bitrise-io/bitrise/plugins" log "github.com/bitrise-io/go-utils/log" "github.com/urfave...
package model // WordCount はまとめ記事へのワードの出現回数を扱うための構造体 type WordCount struct { Word string Count int }
package xmppim import ( "encoding/xml" "github.com/rez-go/xmpplib/xmppcore" ) const ClientPresenceElementName = xmppcore.JabberClientNS + " presence" // RFC 6121 2.2.1 and 4.7.1 const ( PresenceTypeUnavailable = "unavailable" PresenceTypeError = "error" PresenceTypeProbe = "probe" PresenceTyp...
package redis import ( "github.com/go-redis/redis" "github.com/ypyf/salmon/store" ) type RedisStore struct { engine *redis.Client } func New() store.Store { // redis.Client代表连接池,它是Goroutine安全的 // 多个goroutine对redis.Clien的并发使用是安全的 return &RedisStore{engine: redis.NewClient(&redis.Options{ Addr: "10.10.110....
// Unless explicitly stated otherwise all files in this repository are licensed // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-present Datadog, Inc. package remoteconfig import ( "testing" corev1 "k8s.io/api/core/v1" ...
type MessageReceipt struct { exitCode UInt returnValue Bytes gasUsed UInt } // representation tuple
package main import ( "flag" "fmt" "os" pb "github.com/azmodb/exp/azmo/azmopb" "golang.org/x/net/context" ) var putCmd = command{ Help: ` Put sets the value for a key. If the key exists and tombstone is true then its previous versions will be overwritten. Supplied key and value must remain valid for the life o...
package service import ( "github.com/zdnscloud/gorest/resource" common "github.com/zdnscloud/cluster-agent/commonresource" ) type InnerService struct { resource.ResourceBase `json:",inline"` Name string `json:"name"` Workloads []*Workload `json:"workloads"` } func (s InnerServ...
package main import "fmt" /* Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the same array must be preserved. Return an array of the k digits. Note: You should try to optimize y...
// 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 wifi import ( "bytes" "context" "net" "time" cip "chromiumos/tast/common/network/ip" "chromiumos/tast/common/shillconst" "chromiumos/tast/errors" "chromiumo...
// Copyright 2019 tsuru 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 test import ( "context" "encoding/json" "fmt" "os/exec" "strings" "k8s.io/apimachinery/pkg/runtime" ) func createNamespace(ns string) (func() er...