text
stringlengths
11
4.05M
// +build windows package main import "syscall" var suggestedShells = [][]string{ {"powershell"}, {"cmd"}, } func sysProcAttr() *syscall.SysProcAttr { return &syscall.SysProcAttr{HideWindow: true} }
package main import ( "github.com/julienschmidt/httprouter" "log" "net/http" ) func Home(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { w.WriteHeader(http.StatusOK) } func newRouter() *httprouter.Router { router := httprouter.New() router.GET("/", Home) return router } func main() { router ...
package fosscafe import ( "fmt" "strings" "testing" ) func TestGreeting(t *testing.T) { var g string g = "hello everyone" fmt.Println(g) if strings.Compare(g, "hello everyone") != 0 { t.Error("Expected hello everyone, got", g) } } func TestGreetingsToMe(t *testing.T) { // var g string // g = "hello every...
package config import ( "encoding/json" "os" ) // Config contains the information for ElasticSearch type Config struct { Elastic struct { URL string `json:"url"` } `json:"elastic"` } // New returns a Config struct filled with the json file func New(path string) (Config, error) { var cfg Config file, err := ...
// Copyright (c) 2018 Palantir Technologies. 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 require...
package client import ( "fmt" "github.com/UnityTech/nemesis/pkg/resource/gcp" "github.com/UnityTech/nemesis/pkg/utils" "github.com/golang/glog" ) // GetProjects gathers the list of projects and active API resources for the project func (c *Client) GetProjects() error { if *flagProjectFilter == "" { glog.Exit...
package shape import ( "fmt" "io" "github.com/gregoryv/draw/xy" "github.com/gregoryv/nexus" ) func NewDot() *Dot { return &Dot{ Radius: 6, class: "dot", } } type Dot struct { x, y int Radius int class string } func (d *Dot) String() string { return fmt.Sprintf("Dot") } func (d *Dot) Position() (...
// 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 wifiutil provides helper functions for the wificell package. package wifiutil
// Package apitypes defines types shared between the daemon and its api client. package apitypes import ( "strings" "github.com/arigatomachine/cli/identity" "github.com/arigatomachine/cli/primitive" ) // ErrorType represents the string error types that the daemon and registry can // return. type ErrorType string ...
// 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 arc import ( "context" "time" "chromiumos/tast/local/arc" "chromiumos/tast/local/bundles/cros/arc/motioninput" "chromiumos/tast/local/chrome" "chromiumos/tast...
package model import ( "testing" "github.com/stretchr/testify/assert" "github.com/tilt-dev/tilt/internal/ospath" "github.com/tilt-dev/tilt/internal/testutils/tempdir" ) func TestNewRelativeFileOrChildMatcher(t *testing.T) { f := tempdir.NewTempDirFixture(t) paths := []string{ "a", "b/c/d", ospath.MustA...
package postgres import ( "database/sql" "fmt" "net/url" "path" "strconv" "github.com/go-jet/jet/v2/generator/metadata" "github.com/go-jet/jet/v2/generator/template" "github.com/go-jet/jet/v2/internal/utils" "github.com/go-jet/jet/v2/internal/utils/throw" "github.com/go-jet/jet/v2/postgres" "github.com/jac...
// 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 arc import ( "context" "encoding/json" "time" arcpkg "chromiumos/tast/local/arc" "chromiumos/tast/local/chrome" "chromiumos/tast/testing" ) func init() { te...
package array import ( "fmt" "github.com/morzhanov/algorithm-problem-solutions/utils" ) // TrappingRainWatter test // Given n non-negative integers representing an elevation map // where the width of each bar is 1, // compute how much water it is able to trap after raining. // For example, given [0,1,0,2,1,0,1,3,2...
package trade_server import ( "db" "logger" "strategy" "trade_service" ) type TradeServiceHandler struct { } func (this *TradeServiceHandler) Ping() (err error) { return nil } func (this *TradeServiceHandler) ConfigKeys(exchange_configs []*trade_service.ExchangeConfig) (err error) { logger.Infoln("-->ConfigKe...
package gfx // FontStretch is used for Style's FontStretch property. type FontStretch uint // The following values are valid as FontStretch's values. const ( FontStretchInherit FontStretch = iota FontStretchWider FontStretchNarrower FontStretchUltraCondensed FontStretchExtraCondensed FontStretchCondensed FontS...
// 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 a11y provides functions to assist with interacting with accessibility // features and settings. package a11y import ( "context" "time" "chromiumos/tast/ctxuti...
// 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 rpc import ( "bytes" "sync" "time" "github.com/bitmark-inc/bitmarkd/announce/fingerprint" "github.com/bitmark-inc/bitmarkd/announce/h...
package carbon import ( "bytes" "fmt" "io/ioutil" "strings" "time" "github.com/BurntSushi/toml" "github.com/lomik/zapwriter" ) const MetricEndpointLocal = "local" // Duration wrapper time.Duration for TOML type Duration struct { time.Duration } var _ toml.TextMarshaler = &Duration{} // UnmarshalText from ...
/* Wetware - the distributed programming language Copyright 2020, Louis Thibault. All rights reserved. */ package main import ( "os" "github.com/urfave/cli/v2" "github.com/lthibault/log" "github.com/wetware/ww/internal/cmd/boot" "github.com/wetware/ww/internal/cmd/client" "github.com/wetware/ww/internal/c...
// 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 server import ( "errors" "github.com/bitmaelum/bitmaelum-server/core" "github.com/bitmaelum/bitmaelum-server/core/messagebox" ) type Service struct { repo Repository } // Create new service func AccountService(repo Repository) *Service { return &Service{ repo: repo, } } // Cr...
//This file is for the second problem in Exercise for Programmers: 57 Challenges //to Develop Your Coding Skills
package main import ( "bufio" "bytes" "crypto/tls" "encoding/json" "fmt" "math/rand" "net/http" "os" "os/exec" "syscall" "time" "golang.org/x/crypto/ssh/terminal" ) // Caracteres que formaran parte de la contraseña aleatoria const charset = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345...
package models import ( "errors" "github.com/jinzhu/gorm" "github.com/lib/pq" ) type YChaseModel struct { WalletAddress string `gorm:"primary_key" json:"walletAddress"` Assets pq.StringArray `gorm:"not null;type:varchar(64)[]" json:"assets"` } func (u *YChaseModel) Create(db *gorm.DB) (*YChaseMo...
package symbol import "fmt" // Symbol is for creating symbols that represent // values when evaluating the AST type Symbol interface { GetType() string GetValue() string } // Integer symbol type Integer struct { Value int64 } // GetType returns the INTEGER symbol type func (integer *Integer) GetType() string { ...
package main import ( "fmt" "os" "time" ) func count() { abord := make(chan struct{}) go func() { key := make([]byte, 1) os.Stdin.Read(key) abord <- struct{}{} }() // tick := time.Tick(time.Second * 1) tick := time.NewTicker(time.Second * 1) defer tick.Stop() for num := 10; num > 0; num-- { fmt....
package delta import ( "bytes" "fmt" "github.com/boltdb/bolt" ) var bucket = []byte("delta") func SetupDB() (*bolt.DB, error) { DB, err := bolt.Open("/var/lib/bolt.db", 0644, nil) if err != nil { return nil, fmt.Errorf("Failed to create DB File: %s", err) } DB.Update(func(tx *bolt.Tx) error { _, err := ...
package gsm import ( "fmt" "os" "path" ) var ( Version string Rev string progName string ) func init() { progName = path.Base(os.Args[0]) if Version == "" { Version = "<unknown>" } if Rev == "" { Rev = "<unknown>" } } func ProgVersion() string { return fmt.Sprintf("%s %s", progName, Version) }...
package main func (ll *LinkedList) reverse() { var prev, curr, next *Node curr = ll.head for curr != nil { // get the next item and put it in next next = curr.next // actually reverse the current node curr.next = prev // move prev forward prev = curr // we can still move curr "forward" bcs we alre...
package jsonp // Copyright (C) Philip Schlump, 2013-2015. // License in ./LICENSE file - MIT. // Version: 1.0.0 import ( "fmt" "net/http" "net/url" ) // // Example of Use // // In a handler you build some JSON then call JsonP on the return value. // // func handleVersion(res http.ResponseWriter, req *http.Reque...
package rock const ( DefaultClientAddr = "/" DefaultServerAddr = ":80" POST = "9b466094ec991a03cb95c489c19c4d75635f0ae5" GET = "783923e57ba5e8f1044632c31fd806ee24814bb5" V = "▼" Terror byte = iota Tbool Tstring Tint Tint8 Tint16 Tint32 Tint64 Tuint Tuint8 Tui...
/* Copyright 2021 The KodeRover 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, s...
package main //Invalid //Checks if the cases are on the same type as that of the switch expression func f () { switch a:=0; a { case 0 : { } case 'x': { } default : } }
package config import ( "github.com/benbjohnson/clock" "github.com/golang/glog" "github.com/prebid/prebid-server/analytics" "github.com/prebid/prebid-server/analytics/clients" "github.com/prebid/prebid-server/analytics/filesystem" "github.com/prebid/prebid-server/analytics/pubstack" "github.com/prebid/prebid-se...
package main import ( "database/sql" "fmt" "net/http" "encoding/json" _ "github.com/go-sql-driver/mysql" "github.com/gorilla/mux" "github.com/rs/cors" ) var ( err error db *sql.DB contador int contactos []Contacto estados []Estado ) type Contacto struct { IdContacto int `json:"i...
package config import ( "github.com/isaacRevan24/gamification-toolkit-logic/controller" "github.com/isaacRevan24/gamification-toolkit-logic/handler" "github.com/isaacRevan24/gamification-toolkit-logic/repository" "github.com/isaacRevan24/gamification-toolkit-logic/utility" ) // Run required configs at start of th...
package tests import ( "reflect" "testing" ) /** * [637] Average of Levels in Binary Tree * * Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. * * Example 1: * * Input: * 3 * / \ * 9 20 * / \ * 15 7 * Output: [3, 14.5, 11] ...
package data_test import ( "context" "testing" "time" "github.com/google/go-cmp/cmp" "github.com/raymonstah/ardanlabs-go-service/internal/data" "github.com/raymonstah/ardanlabs-go-service/internal/platform/auth" "github.com/raymonstah/ardanlabs-go-service/internal/tests" ) func TestUserCreate(t *testing.T) { ...
package cpu import ( "testing" "github.com/funsun/peridot/common" ) type testBus struct { code map[uint16]uint8 } func NewTestBus(code map[uint16]uint8) *testBus { t := &testBus{} t.code = code return t } func (t *testBus) Write(addr uint16, val uint8) { t.code[addr] = val } func (t *testBus) Read(addr uin...
package main import ( "github.com/abbot/go-http-auth" "golang.org/x/crypto/bcrypt" "net/http" ) func Secret(user, realm string) string { if user == "${username}" { hashedPassword, err := bcrypt.GenerateFromPassword([]byte("${password}"), bcrypt.DefaultCost) if err == nil { ...
package main import ( "fmt" ) func main() { my_map := map[string][]int{ "GK": {1, 99}, "CB": {3, 4, 6, 32, 51}, } my_map["ST"] = []int{9, 11, 21, 99} fmt.Println(my_map) delete(my_map, "GK") fmt.Println(my_map) }
package repository import ( "time" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" ) // SyslogType 系统日志类型 type SyslogType string const ( // SyslogTypeError 错误日志类型 SyslogTypeError SyslogType = "ERROR" // SyslogTypeAction 行为动作类型 SyslogTypeAction SyslogType = "ACTION" // SyslogT...
package main import ( "bufio" "fmt" "os" "path/filepath" ) func helpMessage(originalProgramName string) string { programName := filepath.Base(originalProgramName) return fmt.Sprintf(`%s [OPTIONS] [FILEs...] OPTIONS -n, --number 行番号を表示する. -b, --number-nonblank 行番号を表示する.ただし空白行には付けない. -s, --squeez...
package pond import ( "runtime" ) var maxProcs = runtime.GOMAXPROCS(0) // Preset pool resizing strategies var ( // Eager maximizes responsiveness at the expense of higher resource usage, // which can reduce throughput under certain conditions. // This strategy is meant for worker pools that will operate at a sma...
package math import ( "AlgorithmPractice/src/DataStructure/list" "testing" ) /** * @author liujun * @version V1.0 * @date 2022/7/9 13:54 * @author-Email ljfirst@mail.ustc.edu.cn * @description */ func Test_addMethod(t *testing.T) { params1 := &list.Node{ Value: 9, Next: &list.Node{ Value: 9, Next...
package store import ( "bytes" "fmt" "io/ioutil" "os" ) func ExampleLevelDbStore_readWrite() { dbPath, err := ioutil.TempDir("", "transformer-leveldb-test") if err != nil { panic(err) } store := NewLevelDbStore(dbPath, LevelDbReadWrite) if err := store.BeginWriting(); err != nil { panic(err) } writeR...
package quips import ( G "github.com/ionous/sashimi/game" ) type followsCb func(leads G.IObject, directly bool) bool // evaluate all quips which constrain this clip // ex. for QuipHelp(x).DirectlyFollows(y), then visit(x) will call cb(y, true) func visitFollowConstraints(g G.Play, follower G.IObject, cb followsCb) ...
package cap import ( "context" "fmt" "strings" "time" "github.com/capatazlib/go-capataz/internal/c" ) // nodeSepToken is the token use to separate sub-trees and child node names in // the supervision tree const nodeSepToken = "/" //////////////////////////////////////////////////////////////////////////////// ...
//Package rjshared contains structures used both in broker and workers package rjshared //Glvn struct type Glvn struct { //Key field Key string //Value field Value string }
package uaparser import "net/http" func (parser *UAParser) ParseFromHTTPRequest(r *http.Request) *UA { str := r.Header.Get("User-Agent") return parser.Parse(str) }
package main import ( "bufio" "encoding/json" "flag" "fmt" "os" "github.com/kiasaki/yelp-dataset-api/data" "labix.org/v2/mgo" ) // Readln returns a single line (without the ending \n) // from the input buffered reader. // An error is returned iff there is an error with the // buffered reader. func Readln(r *b...
package terminal import ( "bytes" ) // Bar presents progress bar type Bar struct { // Fill is the default character representing completed progress Fill byte // Head is the default character that moves when progress is updated Head byte // Empty is the default character that represents the empty progress Emp...
package functional func Filter[T any](arr []T, predicate func(val T) bool) []T { ret := make([]T, 0) for _, val := range arr { if predicate(val) { ret = append(ret, val) } } return ret }
// 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 ga import ( "fmt" "testing" ) func TestDefaultOutputFunc(t *testing.T) { t.Parallel() var genA = NewGeneticAlgorithm() genA.Output("Test") t.Log("Didn't panic. Assume success. No other way to test.") } func TestSetOutputFunc(t *testing.T) { t.Parallel() var genA GeneticAlgorithm var gotOutput string...
package game import ( "time" log "github.com/sirupsen/logrus" "github.com/talesmud/talesmud/pkg/entities" "github.com/talesmud/talesmud/pkg/mudserver/game/messages" ) func (game *Game) handleDefaultMessage(message *messages.Message) { user := "" if message.FromUser != nil { user = message.FromUser.Nickname...
package parsehtml import ( "strconv" "fmt" "sync" ) func MainProcess() { //获取所有uids allUids := getAllUids() urlPref := "https://www.jianshu.com/u/" //获取所有用户信息 var userInfos []UserInfo var channel = make(chan *UserInfo, 50) for _, v := range allUids { go func() { for _, innerV := range *v { userInfo...
// Copyright 2020 Trey Dockendorf // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in wri...
package main import "fmt" func main() { var name string fmt.Println("What's your name") //inputs, _ := fmt.Scanf("%s", &name) // input from scanf separated by space -> prints each value with the new-line character inputs, _ := fmt.Scanf("%q", &name) // input has to be within "" switch inputs { case 0: fmt.Pr...
package cliutil import ( "github.com/urfave/cli/v2" "github.com/urfave/cli/v2/altsrc" "github.com/cloudflare/cloudflared/config" "github.com/cloudflare/cloudflared/logger" ) func Action(actionFunc cli.ActionFunc) cli.ActionFunc { return WithErrorHandler(actionFunc) } func ConfiguredAction(actionFunc cli.Action...
package burrow import ( "time" "github.com/gorilla/websocket" ) const ( writeWait = 10 * time.Second pongWait = 60 * time.Second pingPeriod = (pongWait * 9) / 10 maxMessageSize = 4096 ) // connection is an middleman between the websocket connection and the hub. type Connection struct { ws ...
package camo import ( "encoding/json" "expvar" "io" ) // MetricInt ... type MetricInt struct { expvar.Int } // MarshalJSON ... func (i *MetricInt) MarshalJSON() ([]byte, error) { return json.Marshal(i.Value()) } // IOMetric ... type IOMetric struct { ReadBytes *MetricInt `json:"read_bytes"` WriteBytes *Metr...
// 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 scanner import ( "testing" ) func assertTrue(t *testing.T, b bool) { if !b { t.Errorf("Not true") } } func assertFalse(t *testing.T, b bool) { if b { t.Errorf("Not false") } } func TestR(t *testing.T) { l := r('c') assertTrue(t, l('c')) assertFalse(t, l('a')) assertFalse(t, l('b')) } func Tes...
package test import ( "context" "testing" "github.com/ncarlier/readflow/pkg/constant" "github.com/ncarlier/readflow/pkg/assert" "github.com/ncarlier/readflow/pkg/model" ruleengine "github.com/ncarlier/readflow/pkg/rule-engine" ) func newTestRule(rule string, category uint) model.Rule { id := uint(1) return ...
package test import ( "fmt" "github.com/coredumptoday/practice/tree" "github.com/coredumptoday/practice/utils" "testing" ) func TestPrefixTree(t *testing.T) { arrLen := 100 strLen := 20 testTimes := 100000 for i := 0; i < testTimes; i++ { arr := utils.GenerateRandomStringArray(arrLen, strLen) preTree := t...
/* Copyright (c) 2014 Dario Brandes Thies Johannsen Paul Kröger Sergej Mann Roman Naumann Sebastian Thobe All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code mu...
package main import ( "fastdb" "fastdb/cmd" "flag" "fmt" "io/ioutil" "log" "os" "os/signal" "syscall" ) func init() { logo, _ := ioutil.ReadFile("../../logo.txt") fmt.Println(string(logo)) } var config = flag.String("config", "", "the config file for fastdb") func main() { flag.Parse() // Set the con...
// Package feed is responsible for getting data from external source (RSS). package feed import ( "fmt" "time" "github.com/mmcdole/gofeed" ) // Storage describes persistent datastorage. type Storage interface { GetLastUpdate(feed string) time.Time SaveLastUpdate(feed string, t time.Time) error } // RSSFeed rea...
package parser type Kind uint const ( // Operators PLUS Kind = 0 MINUS MUL DIV IDENT NUMBER ) type Token struct { Kind Kind Content string }
package usersvc import ( "github.com/resilva87/usersvc/user" "github.com/go-kit/kit/endpoint" "golang.org/x/net/context" ) type signUpRequest struct { Data user.User `json:"data"` } type signUpResponse struct { Data user.User `json:"data,omitempty"` Err error `json:"error,omitempty"` } func (r signUpRes...
/* Copyright 2019 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 ( "flag" "fmt" "log" "net/http" "os" basename "book/ch03/basename/v2" ) var ( addr = flag.String("addr", "", "listening address") port = flag.Int("port", 8003, "listening port") ) func main() { flag.Parse() if *addr != "" { url := fmt.Sprintf("%s:%d", *addr, *port) handler := func(...
package forest import ( "bytes" "git.sr.ht/~whereswaldon/forest-go/fields" ) // serializer is a type that can describe how to serialize and deserialize itself type serializer interface { SerializationOrder() []fields.BidirectionalBinaryMarshaler } func MarshalBinary(s serializer) ([]byte, error) { buf := new(by...
package openface import ( "os/exec" "fa/s3util" "fmt" "io" "os" ) func Train(imgDir string, alignDir string, featureDir string, userId string, idToken string) error { err := AlignImages(imgDir, alignDir) if err != nil { return err } err = GenReps(alignDir, featureDir) i...
package bst import "fmt" func (r *node) getRank(t *item) uint { if r == nil || t == nil { return 0 } else if t.equal(r.data) { return r.leftSize + 1 } var rank uint if t.greater(r.data) { rank = r.leftSize + r.count + r.right.getRank(t) } else { rank = r.left.getRank(t) } return rank } func (r *node)...
package controllers import ( "encoding/json" "fmt" "io/ioutil" "log" "os" "path" "path/filepath" "github.com/darkcl/Notorious/lib/webview" "github.com/darkcl/Notorious/models" "github.com/mitchellh/go-homedir" ) // FolderController - Folder Controller type FolderController struct { Folder *models....
package main import ( "database/sql" "fmt" _ "github.com/go-sql-driver/mysql" ) var DRIVER string = "mysql" var URL string = "root:toor@tcp(127.0.0.1:3306)/?parseTime=true" var DB_NAME string = "testdb" var CREATE_TABLE_QUERY string = "create table if not exists TODO( " + " id integer AUTO_INCREMENT PRIMARY KEY...
package mdb import ( "container/heap" "fmt" "log" "sync" "time" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) type Session struct { *mgo.Session ref int index int } type SessionHeap []*Session func (h SessionHeap) Len() int { return len(h) } func (h SessionHeap) Less(i, j int) bool { return h[i].ref < ...
package main //1716. 计算力扣银行的钱 //Hercy 想要为购买第一辆车存钱。他 每天 都往力扣银行里存钱。 // //最开始,他在周一的时候存入 1块钱。从周二到周日,他每天都比前一天多存入 1块钱。在接下来每一个周一,他都会比 前一个周一 多存入 1块钱。 // //给你n,请你返回在第 n天结束的时候他在力扣银行总共存了多少块钱。 // // // //示例 1: // //输入:n = 4 //输出:10 //解释:第 4 天后,总额为 1 + 2 + 3 + 4 = 10 。 //示例 2: // //输入:n = 10 //输出:37 //解释:第 10 天后,总额为 (1 + 2 + 3 + 4...
package server import ( "encoding/json" "mime" "net/http" "os" "path" "path/filepath" "github.com/facette/facette/pkg/library" "github.com/facette/facette/pkg/logger" "github.com/facette/facette/thirdparty/github.com/fatih/set" ) func (server *Server) serveError(writer http.ResponseWriter, status int) { er...
// 遍历操作字符串,统计 UD 和 LR 的出现次数 // U, up++ // D, up-- // R, right++ // L, right-- // 所有操作后 up 和 right 都为 0 则返回 true,否则 false package judgecircle func judgeCircle(moves string) bool { var up, right int for _, v := range moves { switch v { case 85: // 'U' up++ case 68: // 'D' up-- case 82: // 'R' right++ ...
package rdb import ( "testing" ) func TestCounter_GetLargestEntries(t *testing.T) { //e := &Entry{ // Key: "RELATIONSFOLLOWERIDS6420000664", // Bytes: 1, // Type: "sortedset", // NumOfElem: 1, // LenOfLargestElem:1, // FieldOfLargestElem: "test", //} c := NewCounter() decoder := NewDecoder() c.Count(decod...
package roles import ( "testing" "github.com/stretchr/testify/suite" ) func TestHelpersSuite(t *testing.T) { suite.Run(t, new(HelpersTestSuite)) } type HelpersTestSuite struct { suite.Suite } func (suite *HelpersTestSuite) TestParseRight() { const someRight1 Right = 1 const someRight2 Right = 2 const someRi...
package internal import ( "context" "errors" "io/ioutil" "os" "os/exec" "path/filepath" "strings" "sync/atomic" "syscall" "testing" "time" "github.com/fsnotify/fsnotify" "github.com/stretchr/testify/assert" ) func Test_Dev_Escort_New(t *testing.T) { t.Parallel() assert.NotNil(t, newEscort(config{})) ...
// 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 config import ( "code.google.com/p/gcfg" golog "github.com/op/go-logging" ) var log = golog.MustGetLogger("main") var Config = struct { Templates struct { Path string } Database struct { Url string } Admins struct { Name []string } }{} func LoadConfig(filename string) { err := gcfg.ReadFileIn...
package picodi_test import ( "errors" "fmt" "math/rand" "testing" "github.com/quintans/picodi" "github.com/stretchr/testify/require" ) type Namer interface { Name() string } type Foo struct { name string } func (foo Foo) Name() string { return foo.name } type Bar struct { Foo Foo `wire:"foo"` F...
package design import ( . "github.com/goadesign/goa/design" . "github.com/goadesign/goa/design/apidsl" ) var _ = Resource("counters", func() { BasePath("/counters") DefaultMedia(Counter) Security(APIKey) Action("list", func() { Routing( GET(""), ) Description("Retrieve all Upstreams.") Response(OK,...
package conf import ( "fmt" "github.com/spf13/viper" ) func init() { viper.SetConfigName("config") viper.AddConfigPath(".") err := viper.ReadInConfig() if err != nil { panic(fmt.Errorf("Error reading config file: %s\n", err.Error())) } }
// Copyright 2020 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 db import "github.com/jmoiron/sqlx" const ( GET_STATUS_VISIT = "SELECT id, status_visit FROM status_visits" ) type TStatusVisit struct { ID int64 `db:"id"` StatusVisit string `db:"status_visit"` } func GetStatusVisits(database *sqlx.DB) ([]TStatusVisit, error) { var statusVisit = []TStatusVis...
package server import ( "W2ONLINE/AssessmentROUND2/bottlehtml/btm/database_set" "fmt" "html/template" "math/rand" "net/http" "strings" "time" ) //type MyMux struct { //} type MyForm struct { NAME string DATE string MESSAGE string } //func (p *MyMux) ServeHTTP(w http.ResponseWriter, r *http.Request){ // i...
package main import "os" import "fmt" func main() { const ( path = "/sys" ) fd, err := os.Open(path) if err != nil { panic(err.Error()) } fileinfo, err := fd.Readdir(0) for _, fi := range fileinfo { fmt.Println(fi.Name()) } }
package acceptance import ( "context" "os" "testing" . "github.com/databrickslabs/terraform-provider-databricks/access" "github.com/databrickslabs/terraform-provider-databricks/identity" "github.com/databrickslabs/terraform-provider-databricks/common" "github.com/databrickslabs/terraform-provider-databricks/i...
package builder // this function is helper to build a house type director struct { builder HouseBuilderIFace } func NewDirector(b HouseBuilderIFace) director { return director{ builder: b, } } func (d *director) BuildHouse() House { d.builder.SetWindowsType() d.builder.SetFloorType() d.builder.SetNumOfDoors...
// // Copyright (c) SAS Institute 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 agre...
package handler type Web struct{}
package odoo import ( "fmt" ) // AccountFiscalPositionTemplate represents account.fiscal.position.template model. type AccountFiscalPositionTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` AccountIds *Relation `xmlrpc:"account_ids,omptempty"` AutoApply *Bool `xmlrpc:"a...