text
stringlengths
11
4.05M
// SPDX-License-Identifier: MIT // Package asttest 提供了一个合法的 ast.APIDoc 对象 package asttest import ( "net/http" "path/filepath" "github.com/issue9/assert/v3" "github.com/issue9/source" "github.com/caixw/apidoc/v7/core" "github.com/caixw/apidoc/v7/internal/ast" "github.com/caixw/apidoc/v7/internal/xmlenc" ) //...
package util import "github.com/gin-gonic/gin" // RestHandleResponse handles the REST API response. func RestHandleResponse(context *gin.Context, body interface{}, err error) { if err == nil { context.JSON(200, body) } else { context.String(400, err.Error()) } }
package cassandradatacenter import ( "context" "fmt" "github.com/go-logr/logr" cassandraoperatorv1alpha1 "github.com/instaclustr/cassandra-operator/pkg/apis/cassandraoperator/v1alpha1" corev1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" ) const pvcDeletionFinalizer = "finalizer.pvcs.cassan...
package stat import ( "errors" "io" "os" "github.com/loov/goda/internal/memory" ) // Source contains basic analysis of arbitrary source code. type Source struct { // Files count in this stat. Files int // Binary file count. Binary int // Size in bytes of all files. Size memory.Bytes // Count of non-empty ...
package metrics import ( "github.com/prometheus/client_golang/prometheus" ) const namespace = "caddy" var ( requestCount *prometheus.CounterVec requestDuration *prometheus.HistogramVec responseSize *prometheus.HistogramVec responseStatus *prometheus.CounterVec responseLatency *prometheus.HistogramVec ) ...
package utils import ( "crypto/rand" "fmt" "io" "net/http" "o2clock/constants/appconstant" "runtime" "time" "google.golang.org/grpc" ) func ValidateAndPrintMemUsage(srv *grpc.Server) { var m runtime.MemStats runtime.ReadMemStats(&m) fmt.Println(time.Now()) fmt.Println(appconstant.MEM_ALLOC, bToMb(m.Alloc...
package middleware import ( "enroll/interfaces" "enroll/providers" "net/http" "strings" "github.com/gin-gonic/gin" ) func AdminAuth() gin.HandlerFunc { return func(c *gin.Context) { authHeader := c.GetHeader("Authorization") if len(authHeader) == 0 { c.AbortWithStatusJSON(http.StatusUnauthorized, interf...
package podres import ( "fmt" "log" "time" podresources "k8s.io/kubernetes/pkg/kubelet/apis/podresources" podresourcesapi "k8s.io/kubernetes/pkg/kubelet/apis/podresources/v1alpha1" ) const ( defaultPodResourcesTimeout = 10 * time.Second defaultPodResourcesMaxSize = 1024 * 1024 * 16 // 16 Mb // obtained these...
package Authentication //TODO: better way for import import ( "errors" "io/ioutil" "proxy/Logger" "strings" "github.com/gin-gonic/gin" "github.com/mitchellh/mapstructure" "net/http" ) type Authentication struct { Name string Auth_scheme string Auth_addr string Auth_type string Url_path string Req_header...
package main import ( "context" "fmt" "os" "runtime" "github.com/tanaton/covid-19-chart/app" ) func main() { defer func() { if err := recover(); err != nil { fmt.Fprintf(os.Stderr, "Error:\n%s", err) os.Exit(1) } }() os.Exit(_main()) } func _main() int { if envvar := os.Getenv("GOMAXPROCS"); envv...
package stream import ( "bytes" "io" containers "github.com/ernoaapa/eliot/pkg/api/services/containers/v1" "github.com/pkg/errors" ) // PipeStdout reads stdout from grpc stream and writes it to stdout/stderr func PipeStdout(stream StdoutStreamClient, stdout, stderr io.Writer) error { for { resp, err := stream...
package engine import ( "errors" "fmt" "runtime/debug" "strings" "time" "oh-my-posh/platform" "oh-my-posh/properties" "oh-my-posh/segments" "oh-my-posh/shell" "oh-my-posh/template" ) // Segment represent a single segment and it's configuration type Segment struct { Type SegmentType `json...
package main import "fmt" func main() { fmt.Println("Muhammad Hajid Al Akhtar") }
/* 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...
// 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 apps import ( "context" "path/filepath" "strconv" "time" "chromiumos/tast/ctxutil" "chromiumos/tast/errors" "chromiumos/tast/local/apps" "chromiumos/tast/lo...
// 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 internal const ( // CrasStopTimeFile is the file stores previous CRAS stop time. CrasStopTimeFile = "/var/lib/cras/stop" )
package solutions func trap(h []int) int { if len(h) < 3 { return 0 } var result, left, right, maxLeft, maxRight int right = len(h) - 1 for left < right { if h[left] > maxLeft { maxLeft = h[left] } if h[right] > maxRight { maxRight = h[righ...
// Copyright 2020 Ye Zi Jie. 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 applicable ...
// Copyright 2019 - 2022 The Samply Community // // 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 ...
package main import "fmt" func main() { //Provando que os slice fazem referencia ao mesmo trecho de memoria s1 := make([]int, 10, 20) s2 := append(s1, 1, 2, 3) fmt.Println(s1, s2) // Atribuindo valor novo apenas ao slice 1 altera o mesmo indice e valor do slice 2 s1[0] = 7 fmt.Println(s1, s2) }
package kuma import ( "context" "github.com/layer5io/meshery-adapter-library/adapter" "github.com/layer5io/meshery-adapter-library/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func (kuma *Kuma) installSampleApp(del bool, namespace string, templates []adapter.Template) (string, error) { st := status.I...
package main import ( "flag" "fmt" "github.com/coopernurse/retina/ws" "log" "os" "os/signal" "strconv" "strings" "syscall" "time" ) func run(url string, workers int, done chan bool, msgs chan string) { handler := func(headers map[string][]string, body []byte) (map[string][]string, []byte) { msgs <- strin...
package BLC import ( "bytes" "crypto/sha256" "fmt" "math/big" ) type ProofOfWork struct { Block *Block // The block which will be calculate target *big.Int // a block hash should satisfy hash < target } func PoWFactory(block *Block) *ProofOfWork { target := big.NewInt(1) target = target.Lsh(target, 256-ta...
package views import ( "PixelToolWindow/models" "github.com/asaskevich/EventBus" "github.com/therecipe/qt/widgets" ) /* --- Bus signal information --- Tag :sideWin:settingInfo */ /* SideWindow :Side window */ type SideWindow struct { // --- Enviroment Setting group --- gammaAdjuster *SliderInput ...
package chat import ( "github.com/gorilla/websocket" uuid "github.com/satori/go.uuid" "github.com/sirupsen/logrus" ) type Community struct { hubs map[*Hub]bool handler MessageServiceInterface logger *logrus.Logger } type Hub struct { id uuid.UUID clients map[*Client]bool register chan *Client...
package future // A thennable function type Promise interface { OnSuccess() OnFailure() }
// Package contradb contains functions for interacting with ContraDB. package contradb import ( "errors" "fmt" "net" "net/url" "reflect" "runtime/debug" "time" "github.com/jackc/pgx/v4" "github.com/jackc/pgx/v4/stdlib" "github.com/jmoiron/sqlx" "go.uber.org/atomic" "github.com/ajruckman/ContraCore/intern...
package main import ( "fmt" "github.com/gin-gonic/gin" "github.com/goweb/config" "os" "log" "io" "github.com/goweb/router" _ "github.com/goweb/db" "github.com/goweb/middleware" "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles" _ "github.com/goweb/docs" ) func main() { fmt.Print...
/* * Copyright 2020 zpxio (Jeff Sharpe) * * 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 ag...
package fileUtil import ( "bytes" "compress/zlib" "io" ) // 字节压缩(zlib方式压缩) // 参数: // data:待压缩的数组 // level:等级 // 返回值: // 1.压缩后的数据 // 2.错误对象 func Zlib(data []byte, level int) ([]byte, error) { var buffer bytes.Buffer zlibWriter, err := zlib.NewWriterLevelDict(&buffer, level, nil) if err != nil { return nil, err...
// 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 audio import ( "context" "encoding/json" "strconv" "time" "chromiumos/tast/common/perf" "chromiumos/tast/common/testexec" "chromiumos/tast/testing" ) type s...
package lifting import ( "sort" "strconv" "time" "cloud.google.com/go/civil" ) func parseInt(value string) (int, error) { if len(value) < 1 { return 0, nil } i, errs := strconv.Atoi(value) return i, errs } // Category is the category of exercises on a date type Category struct { Category string Reps ...
package models //PrecomputedStatistics Result of precomputed statistics type PrecomputedStatistics struct { Min float64 `json:"min"` Max float64 `json:"max"` Avg float64 `json:"avg"` MinCountry string `json:"minCountry"` MaxCountry string `json:"maxCountry"` }
package bind import ( "context" "fmt" "os" "os/exec" "strings" "time" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" binddnsv1 "github.com/bind-dns/binddns-operator/pkg/apis/binddns/v1" "github.com/bind-dns/binddns-operator/pkg/kube" "github.com/bind-dns/binddns-operator/pkg/utils" zlog "github.com/bind-dns/bi...
package internal import ( "encoding/json" "fmt" "os" "path/filepath" ) // ConfigFileName holds the name of the config file const ConfigFileName = "ahab.json" // UserConfigFilePath holds the path of the user's config file, relative to their home dir const UserConfigFilePath = ".config/ahab/config.json" // Versio...
package operator import ( "context" "os" "github.com/Dynatrace/dynatrace-operator/src/cmd/config" cmdManager "github.com/Dynatrace/dynatrace-operator/src/cmd/manager" "github.com/Dynatrace/dynatrace-operator/src/controllers/certificates" "github.com/Dynatrace/dynatrace-operator/src/kubeobjects" "github.com/Dyn...
package wxapp import ( "context" "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/bson" "jxc/api" "jxc/auth" "jxc/models" "jxc/serializer" "net/http" ) type UserAddressService struct { CustomerID int64 `json:"customer_id" bson:"customer_id"` AddressIDs []int64 `json:"address_ids" bson:"address_ids"` ...
/* 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 ( "errors" "fmt" ) func divide(divided float64, divisor float64) (float64, error) { if divisor == 0.0 { return 0, errors.New("На ноль делить ЗАПРЕЩЕНО") } return divided / divisor, nil } func main() { quotient, err := divide(5.6, 0.0) if err != nil { fmt.Println(err) } else { fmt.Pri...
package codegen import ( "bytes" "os" "regexp" "strings" "text/template" "golang.org/x/xerrors" "github.com/iotaledger/hive.go/lo" ) // Template is a wrapper around the text/template package that provides a generic way for generating files according // to the "go generate" pattern. // // In addition to the s...
package model import ( "gopkg.in/mgo.v2/bson" ) type Role int const ( Admin Role = iota Teacher Student ) type User struct { ID bson.ObjectId `json:"id" bson:"_id"` Name string `json:"name" bson:"name"` Email string `json:"email" bson:"email" validate:"regexp=^[0-9a-z]+@[0-9a-z]+(\\.[0-9a-z...
package keystore import ( crypto_rand "crypto/rand" "fmt" "io" "strconv" "sync" "github.com/golang/protobuf/proto" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "kope.io/auth/pkg/keystore/pb" //"k8s.io/apimachinery/pkg/watch" "strings" "time" "github.com/go...
package amx import ( "encoding/json" "fmt" "testing" "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" "github.com/prebid/prebid-server/adapters/adapt...
package models import ( "context" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" "time" ) /***************************************************** Model ************************************************...
package model const ( UserStateEnabled = "enable" UserStateDisabled = "disable" ) type User struct { Model Email string `gorm:"column:email;size:256;uniqueIndex;not null" json:"email"` Name string `gorm:"column:name;size:256;uniqueIndex;not null" json:"name"` EncryptedPassword string `...
package apm_test import ( "errors" "testing" "github.com/junhwong/goost/apm" ) func TestLog(t *testing.T) { t.Cleanup(apm.Flush) // apm.UseAsyncDispatcher() apm.LogComponent("test") apm.Default(apm.WithFields(apm.LogComponent(""))).Debug("hello") apm.Default().Debug(apm.WrapCallStack(errors.New("hhh"))) }
package parking import ( "strconv" "github.com/boantp/parking_lot/config" ) type Config struct { Id int ParkingLotSlot int } type ParkingLot struct { IdParkingLot int64 SlotNumber int ParkingStatus int } type ParkingCar struct { IdParkingCar int SlotNumber int CarPlateNumber string ...
package main const PATH_ACIHOME = "/acihome" const PATH_OPT = "/opt" const PATH_BUILDER = "/builder" const PATH_DGR = "/dgr" const PATH_OVERLAY = "/overlay" const PATH_UPPER = "/upper" const PATH_STAGE2 = "/stage2" const PATH_ATTRIBUTES = "/attributes" const PATH_TMP = "/tmp"
package model import ( "fmt" "strconv" "time" ) type Result struct { Name string True bool Time time.Time } func (r Result) ToString() string { return fmt.Sprintf("%s,%s,%s", r.Name, strconv.FormatBool(r.True), r.Time.Format(time.RFC822)) }
package main import ( "fmt" "sort" ) type people []string func (p people) Len() int { return len(p) } func (p people) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func (p people) Less(i, j int) bool { return p[i] < p[j] } func main() { studyGroup := people{"Zeno", "John", "Al", "Jenny"} fmt.Println(studyGrou...
package controller import ( "bytes" "fmt" "github.com/astaxie/beego/validation" "github.com/gin-gonic/gin" "dawn_media/conf" "dawn_media/model" "net/http" ) type MyValidator struct { validation.Validation } //v应该为指针,否则是向副本里面加入的参数,而不是向实体 func (v *MyValidator) Size(i interface{}, min int, max int, message ...s...
package solutions func gameOfLife(board [][]int) { if len(board) == 0 || len(board[0]) == 0 { return } x, y := len(board), len(board[0]) for i := 0; i < x; i++ { for j := 0; j < y; j++ { lives := 0 lives += isAlive(board, i - 1, j - 1) lives += isA...
package version // Version build time set version var Version = "_ci_build_not_run_properly_"
package mysql import ( "errors" "testing" "github.com/go-sql-driver/mysql" "github.com/stretchr/testify/assert" ) func TestConvertMysqlError(t *testing.T) { testCases := []struct { input error returnsSame bool output error }{{ input: nil, output: nil, }, { input: errors.New(`what...
package main import ( "context" "flag" "log" "net" epb "github.com/cpjudge/proto/evaluator" spb "github.com/cpjudge/proto/submission" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/testdata" ) var ( tls = flag.Bool("tls", false, "Connection uses TLS if true, el...
package main import ( "code.google.com/p/goprotobuf/proto" "io/ioutil" "log" "mobads_api" "net/http" ) func main() { http.HandleFunc("/api", CallBack) err := http.ListenAndServe(":8124", nil) if err != nil { log.Fatalf("start server fail . err[%s]", err.Error()) } return } func CallBack(resp http.Respon...
package main import ( "bytes" "crypto/rand" "encoding/hex" "encoding/json" "io/ioutil" "os" "os/exec" "path/filepath" "runtime" "strconv" "strings" "time" minio "github.com/minio/minio-go" nats "github.com/nats-io/go-nats" log "github.com/sirupsen/logrus" ) type PubSubEvent struct { ScanID string...
package minicon import ( "github.com/nsf/termbox-go" // termbox; for event handling ) // // Helper to processes input events to various useful ends. // type InputHandler struct { prompt *Prompt // input adds to the user's buffered, pending command box *TermBox // input displays on the screen tel...
// 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 kontena import ( "fmt" "github.com/inloop/goclitools" "github.com/jakubknejzlik/kontena-git-cli/model" "github.com/jakubknejzlik/kontena-git-cli/utils" ) // RegistryExists ... func (c *Client) RegistryExists(name string) (bool, error) { registries, err := c.RegistryList() if err != nil { return false...
// Package stringUtils : from https://github.com/elgs/gostrgen package stringUtils import ( "errors" "math/rand" "strings" "time" ) // Lower permet d'indiquer si l'on souhaite utiliser les lettres minuscules var Lower = 1 << 0 // Upper permet d'indiquer si l'on souhaite utiliser les lettres majuscules var Upper ...
package producer import ( "asyncMessageSystem/app/common" "asyncMessageSystem/app/middleware/log" "asyncMessageSystem/app/model" "encoding/json" "github.com/Braveheart7854/rabbitmqPool" //"asyncMessageSystem/app/middleware/rabbitmqPool" "github.com/kataras/iris" "strconv" "time" ) type Produce struct {} typ...
package googl import ( "fmt" "github.com/parnurzeal/gorequest" ) type Googl struct { Key string } type ShortMsg struct { Kind string `json:"kind"` Id string `json:"id"` LongUrl string `json:"longUrl"` } type LongMsg struct { Kind string `json:"kind"` Id string `json:"id"` LongUrl string `js...
package main import ( "fmt" "github.com/mholland/advent-of-code/2019/intcode" ) func main() { gameState := runGame(1) blocks := 0 for _, tile := range gameState { if tile == block { blocks++ } } fmt.Printf("Number of starting blocks: %v\n", blocks) finishedGame := runGame(2) pri...
package main import ( "fmt" "os" "strings" ) func parseCmdLine() { var gtver latest if len(os.Args) > 1 { args := os.Args[1:] switch strings.ToLower(args[0]) { case "refresh": fmt.Println(strFetchRemote) refreshDb() case "installed": if len(args) > 1 { if args[1] == "go" { printInstall...
// 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 service import ( "belajar-unit-testing/repository" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) var categoryRespository = &repository.CategoryRepositoryMock{Mock: mock.Mock{}} var categoryService = CategoryService{Repository: categoryRespository} func TestCategoryS...
package requests import ( "encoding/json" "fmt" "net/url" "strings" "github.com/google/go-querystring/query" "github.com/atomicjolt/canvasapi" "github.com/atomicjolt/string_utils" ) // EnableDisableOrClearExplicitCspSettingAccounts Either explicitly sets CSP to be on or off for courses and sub-accounts, // o...
package cncscraper type PollOption struct { Title string `bson:"label"` Votes int `bson:"votes"` }
// Package Mail is an abstraction around the gomail package that handles // sending user email confirmation messages. package mail import ( "fmt" "os" "github.com/sendgrid/rest" sendgrid "github.com/sendgrid/sendgrid-go" "github.com/sendgrid/sendgrid-go/helpers/mail" ) type MessageData struct { Address string ...
package main import "fmt" func square(x int) int { return x * x } type ListNode struct { data int link *ListNode } func main() { fmt.Println(square(1000)) }
package utils import ( "bytes" "container/list" "encoding/csv" "encoding/json" "strings" "github.com/pelletier/go-toml" "github.com/tealeg/xlsx" "sigs.k8s.io/yaml" ) // ParserResponse represents the Parser JSON response type ParserResponse struct { FileParsed bool JsonString string } // GetParserResponse ...
package raws // import "github.com/BenLubar/dfide/raws" import "errors" var ( ErrNoRawFileName = errors.New("raws: no file name (first line was blank)") ErrNoRawObjectType = errors.New("raws: missing OBJECT tag at start of file") ErrIncompleteTag = errors.New("raws: incomplete tag (missing closing bracket)"...
package app import ( "errors" "fmt" "github.com/tharsis/token/erc20" ) // DeployContract deploys ERC-20 contract using privateKey and ethClient that are stored on Client. func (c *Client) DeployContract() error { if c.privateKey == nil { return errors.New("privateKey is nil") } if c.ethClient == nil { ret...
package chapter2 import ( "container/list" "testing" ) func Test_kFromTail(t *testing.T) { getList := func() *list.List { l := list.New() l.PushBack(1) l.PushBack(2) l.PushBack(2) l.PushBack(1) l.PushBack(3) return l } type args struct { l *list.List k int } tests := []struct { name string ...
// Copyright 2019 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package crash import ( "context" "io/ioutil" "os" "path/filepath" "time" "chromiumos/tast/common/testexec" "chromiumos/tast/errors" "chromiumos/tast/local/chrome" ...
package gqlerrors import ( "encoding/json" "errors" "github.com/appleboy/graphql/language/location" ) // FormattedError contains user and machine readable, formatted error messages. type FormattedError struct { Message string `json:"message"` Locations []location.SourceLocation `json:"loc...
package zdb import ( "database/sql" "errors" "fmt" "reflect" "runtime/debug" "strconv" "strings" "time" "github.com/sohaha/zlsgo/zstring" "github.com/sohaha/zlsgo/ztime" "github.com/sohaha/zlsgo/ztype" ) type ( ByteUnmarshaler interface { UnmarshalByte(data []byte) error } // IfeRows defines methods ...
package cherryDataConfig import ( "fmt" cherryUtils "github.com/cherry-game/cherry/extend/utils" "github.com/cherry-game/cherry/interfaces" cherryLogger "github.com/cherry-game/cherry/logger" "github.com/cherry-game/cherry/profile" "sync" ) type DataConfigComponent struct { cherryInterfaces.BaseComponent sync...
import "sort" /* * @lc app=leetcode id=47 lang=golang * * [47] Permutations II * * https://leetcode.com/problems/permutations-ii/description/ * * algorithms * Medium (46.58%) * Likes: 2089 * Dislikes: 63 * Total Accepted: 366.7K * Total Submissions: 785.5K * Testcase Example: '[1,1,2]' * * Given ...
package main import ( _ "embed" "fmt" "math/rand" "strings" "time" ) // Here comes the embedding! //go:embed quotes.txt var quoteData string func main() { rand.Seed(time.Now().Unix()) quotes := strings.Split(quoteData, "\n\n") fmt.Println(quotes[rand.Intn(len(quotes))]) }
package main import ( "bufio" "fmt" "log" "os" "regexp" "strings" "time" ) var bagSearch = map[string]interface{}{"shiny gold": nil} func main() { start := time.Now() fmt.Printf("Result is %v \n", run()) log.Printf("Code took %s", time.Since(start)) } func run() int { var validRules = []string{} f, e...
// 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 wire import ( "encoding/json" "strings" "unicode/utf8" ) // FIBeneficiaryFIAdvice is the financial institution beneficiary financial institution type FIBeneficia...
package controllers import ( "fmt" "os" "github.com/itang/yunshang/main/app" "github.com/itang/yunshang/main/app/models/entity" "github.com/revel/revel" ) // 应用主控制器 type App struct { AppController } // 应用主页 func (c App) Index() revel.Result { c.setChannel("index/") return c.Render() } func (c App) AdImages...
package main import "fmt" //BynarySearch is struct base for implements methods to bynary search //algoritm. type BynarySearch struct{} //bynarySearch is responsable by search element in array. func bynarySearch(arr []int, elem, start, end int) int { index := (start + end) / 2 if index < len(arr) && arr[index] == e...
package entities import "time" //User connects to login credentials to a user object type User struct { *Entity `bson:",inline"` // main *unique* reference id, its additional to ID because it might be a list of reference ids in the future so a user // can merge multiple accounts (refids) into the same user object...
package controllers import ( "encoding/json" "fmt" "github.com/syndtr/goleveldb/leveldb" "net/http" "strconv" "time" ) type BlockData struct { Sender string Receiver string Data string TimeStamp int64 } type StroeData struct { Sender string Receiver string Data string TimeStamp int...
// 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 policy import ( "context" "time" "chromiumos/tast/common/fixture" "chromiumos/tast/common/pci" "chromiumos/tast/common/policy" "chromiumos/tast/common/policy/...
package main import ( "os" "testing" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/terraform" ) var testAccProviders map[string]terraform.ResourceProvider var testAccProvider *schema.Provider func init() { testAccProvider = Provider() testAccProviders = map[string]terraform.Re...
package httpbakery import ( "crypto/rand" "encoding/base64" "encoding/json" "fmt" "log" "net/http" "path" "gopkg.in/errgo.v1" "gopkg.in/macaroon.v1" "gopkg.in/macaroon-bakery.v0/bakery" "gopkg.in/macaroon-bakery.v0/bakery/checkers" ) type dischargeHandler struct { svc *bakery.Service checker func(r...
package def import ( "errors" "testing" ) func TestNormalizedKVError(t *testing.T) { kvErr := errors.New("Key not found") err := NormalizedKVError(kvErr) if err != nil { t.Log(err) } p2pErr := errors.New("invalid stream") err = NormalizedKVError(p2pErr) if err != nil { t.Log(err) } }
/** * @Author: lzw5399 * @Date: 2021/1/15 23:35 * @Desc: */ package service import ( "errors" "workflow/global" . "workflow/model" "workflow/model/request" "workflow/util" "gorm.io/gorm" ) // 创建新的process流程 func CreateProcess(r *request.ProcessRequest, originXml string) error { // 检查流程是否已存在 var c int64 ...
package main import "testing" func TestNewParser(t *testing.T) { p, err := NewParser(`test/MaxL.asm`) if err != nil { t.Fatal(err) } for p.HasMoreCommands() { t.Log(`=====`) t.Log(`CurrentLine: `, p.CurrentLine) t.Log(`CommandType: `, p.CommandType()) t.Log(`Symbol: `, p.Symbol()) t.Log(`Dest: `, p.De...
package ravendb import "strings" var _ queryToken = &fieldsToFetchToken{} type fieldsToFetchToken struct { fieldsToFetch []string projections []string customFunction bool sourceAlias string } func newFieldsToFetchToken(fieldsToFetch []string, projections []string, customFunction bool, sourceAlias string)...
type Command interface { Execute() ([]byte, error) ValidateInput() bool } type CommandExecutor struct { } func (c CommandExecutor) Execute(command Command) { if command.ValidateInput() { command.Execute() } } type FooCommand struct { args []string // need args } func (c FooCommand) ValidateInput() { // valid...
package keycode const ( M = "M" Space = "SPACE" Enter = "ENTER" LeftControl = "L_CTRL" RightControl = "R_CTRL" LeftAlt = "L_ALT" RightAlt = "R_ALT" One = "1" Two = "2" Three = "3" Four = "4" Five = "5" Q = "Q" W ...
package model import ( "errors" "lhc.go.game.center/libs/mysql" "time" ) type CrawlerMenu struct { Id int `json:"id" form:"id"` Name string `json:"name" form:"name"` Mark string `json:"mark" form:"mark"` CrawlerUrl string `json:"crawler_url" form:"crawler_url"` CronUrl string `json:"cron_url" form:"cron_url"`...
package main func bin_exprs() { var x int var y int var r int var b bool var c bool r = x + 1 r = x - 1 r = x * 1 r = x / 1 r = x % 1 r = x & 1 r = x | 1 r = x ^ 1 r = x &^ 1 r = x << 1 r = x >> 1 c = b && b c = b || b c = x < y c = x <= y c = x == y c = x != y c = x >= y c = x > y r = x + y...
package postgres import ( "bytes" "fmt" "strings" "github.com/Sirupsen/logrus" _ "github.com/jackc/pgx/stdlib" "github.com/jmoiron/sqlx" "github.com/segment-sources/sqlsource/domain" "github.com/segment-sources/sqlsource/driver" ) const chunkSize = 1000000 type tableDescriptionRow struct { Catalog strin...
package reverse // Reverse reverses a string func Reverse(s string) string { res := []rune(s) for i, j := 0, len(res)-1; i < j; i, j = i+1, j-1 { res[i], res[j] = res[j], res[i] } return string(res) }