text
stringlengths
11
4.05M
// 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 project import ( "golang.org/x/net/context" "github.com/codeship/libcompose/project/events" ) // Unpause pauses the specified services containers (like docker pause). func (p *Project) Unpause(ctx context.Context, services ...string) error { eventWrapper := events.NewEventWrapper("Project Pause", events.N...
package river import ( "bytes" "os" "path" "sync" "time" "github.com/BurntSushi/toml" "github.com/go-mysql-org/go-mysql/mysql" "github.com/juju/errors" "github.com/siddontang/go-log/log" "github.com/siddontang/go/ioutil2" ) type masterInfo struct { sync.RWMutex Name string `toml:"bin_name"` Pos uint...
// 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 policy import ( "context" "chromiumos/tast/common/fixture" "chromiumos/tast/common/pci" "chromiumos/tast/common/policy" "chromiumos/tast/common/policy/fakedms"...
package service import ( "github.com/LiveSocket/bot/service/db" "github.com/LiveSocket/bot/service/healthcheck" "github.com/LiveSocket/bot/service/socket" ) const ( ALL = 0x7 SOCKET = 0x1 DB = 0x2 HEALTHCHECK = 0x4 ) type Service struct { *db.DB *socket.Socket } type model struct { d...
// 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. // This file contains helper functions to allocate memory on ChromeOS. // Package memory contains common utilities to allocate memory and read memory // pressure state on Ch...
package cmd import ( "bytes" "strings" "testing" ) func TestRoot(t *testing.T) { tcs := []struct { name string command string want string wantErr bool }{ {"้•ทใ„ใ‚„ใค", "gomah -m 123123123123 -s 123 -p 123 -w 111", "๐Ÿ€‡ ๐Ÿ€ˆ ๐Ÿ€‰ ๐Ÿ€‡ ๐Ÿ€ˆ ๐Ÿ€‰ ๐Ÿ€‡ ๐Ÿ€ˆ ๐Ÿ€‰ ๐Ÿ€‡ ๐Ÿ€ˆ ๐Ÿ€‰ ๐Ÿ€ ๐Ÿ€‘ ๐Ÿ€’ ๐Ÿ€™ ๐Ÿ€š ๐Ÿ€› ๐Ÿ€€ ๐Ÿ€€ ๐Ÿ€€ \n", false}, {"ๆ™ฎ้€šใฎใ‚„ใค",...
package main import ( "errors" "os/exec" "strings" "sync/atomic" "time" ) var ErrCmdStatus = errors.New("Code != 200") type WorkerCmd struct { Id int cmd atomic.Value task chan *Task s *Scheduler } func (w *WorkerCmd) Init(id int, s *Scheduler) *WorkerCmd { w.Id = id w.s = s w.task = make(chan *Tas...
package main import ( "errors" "github.com/graphql-go/graphql" "github.com/renteasy/marketplace/internal/database" "time" ) var rentalType = graphql.NewObject( graphql.ObjectConfig{ Name: "Rental", Fields: graphql.Fields{ "id": &graphql.Field{ Type: graphql.Int, Resolve: func(p graphql.ResolvePara...
// 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...
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. // package supervisor_test import ( "fmt" "math/rand" "testing" ec2Types "github.com/aws/aws-sdk-go-v2/service/ec2/types" eksTypes "github.com/aws/aws-sdk-go-v2/service/eks/types" "github.com/matterm...
// 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 hpsutil contains functionality used by the HPS tast tests. package hpsutil import ( "context" "regexp" "time" "chromiumos/tast/common/testexec" "chromiumos/...
// 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 chimera import ( "crypto/tls" "crypto/x509" "io" "io/ioutil" "log" "net/http" "net/url" "os" "strings" "github.com/engineerd/wasm-to-oci/pkg/oci" "github.com/pkg/errors" ) type ModuleSource int const ( UnknownSource ModuleSource = iota FileSource ModuleSource = iota HTTPSource ModuleS...
package base import ( "github.com/stretchr/testify/assert" "math" "testing" ) const simTestEpsilon = 1e-3 func TestCosine(t *testing.T) { a := NewSparseVector() a.Add(1, 4) a.Add(2, 5) a.Add(3, 6) b := NewSparseVector() b.Add(0, 0) b.Add(1, 1) b.Add(2, 2) sim := CosineSimilarity(a, b) assert.False(t, ma...
// DailyGakki - handler // 2020-10-17 14:03 // Benny <benny.think@gmail.com> package main import ( "bytes" "fmt" log "github.com/sirupsen/logrus" tb "gopkg.in/tucnak/telebot.v2" "path/filepath" "strconv" "strings" ) import "github.com/tgbot-collection/tgbot_ping" func startHandler(m *tb.Message) { caption :...
// 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 types // PredefinedAttributes the predefined document attributes // May be converted into HTML entities var predefinedAttributes = []string{ "sp", "blank", "empty", "nbsp", "zwsp", "wj", "apos", "quot", "lsquo", "rsquo", "ldquo", "rdquo", "deg", "plus", "brvbar", "vbar", "amp", "lt", "gt", ...
package sort func ShellSort(a []int) { h := 1 for h < len(a) { h = 3*h + 1 } for h >= 1 { for i := h; i < len(a); i++ { for j := i; j >= h && a[j] < a[j-h]; j = j - h { a[j], a[j-h] = a[j-h], a[j] } } h = h / 3 } } func ShellSortV2(a []int, n int) { var i, j, increment int for increment = n ...
//ๅนถๅ‘่Žทๅ–ๅคšไธชURL--ไธ€ไธชๅฐๅž‹็š„็ฝ‘้€Ÿๆต‹่ฏ•ๅทฅๅ…ท package main import ( "fmt" "io" "io/ioutil" "net/http" "os" "time" ) func main() { start := time.Now() ch := make(chan string) //ๅˆ›ๅปบ้€š้“ for _,url := range os.Args[1:] { go fetch(url, ch) } // ไธปๅ็จ‹่ดŸ่ดฃๅ–ๆ•ฐๆฎ // ๅฝ“ไธ€ไธชgoroutineๅฐ่ฏ•ๅœจไธ€ไธชchannelไธŠๅšsendๆˆ–่€…receiveๆ“ไฝœๆ—ถ๏ผŒ่ฟ™ไธชgoroutineไผš้˜ปๅกžๅœจ่ฐƒ็”จๅค„๏ผŒ // ็›ดๅˆฐๅฆไธ€ไธชgor...
// 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 nmt import ( "bytes" "errors" "fmt" "hash" "math/bits" "github.com/celestiaorg/nmt/namespace" ) // ErrFailedCompletenessCheck indicates that the verification of a namespace proof failed due to the lack of completeness property. var ErrFailedCompletenessCheck = errors.New("failed completeness check") /...
package delta import ( "fmt" "github.com/cskr/pubsub" "github.com/mozilla/libaudit-go" "syscall" ) var PubSub *pubsub.PubSub var AuditChannel = "audit" func (dc *DeltaCore) StartAuditEngine() { s, err := libaudit.NewNetlinkConnection() if err != nil { fmt.Printf("%v\n", err) return } defer s.Close() ...
// +build !race package common import ( "os" "sync" "testing" "github.com/stretchr/testify/assert" "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd/api" ) func TestMergeConfig(t *testing.T) { path := "./test.lock" _ = os.Setenv(clientcmd.RecommendedConfigPathEnvVar, path) _, err := os.C...
package usecase import ( "github.com/ikmski/git-lfs3/entity" ) // BatchService is ... type BatchService interface { Batch(req *BatchRequest) (*BatchResult, error) } type batchService struct { MetaDataRepository MetaDataRepository ContentRepository ContentRepository } // NewBatchService is ... func NewBatchServ...
package ThreadPool import ( "fmt" "math" "runtime" "sync" ) type TaskStruct struct { Fun func() error TheWaitGroup *sync.WaitGroup } // Synergetic Process Pool type SPP struct { Capacity int TaskChan chan TaskStruct sync.Mutex } func NewSPP(capacity int) *SPP { taskChannel := make(chan TaskStruc...
package main import ( "fmt" "time" ) func producer2(queue chan string) { for i := 0; i < 100; i++ { queue <- fmt.Sprintf("liuruichao_%d", i) fmt.Printf("send %d to queue.\n", i) } } func consumer2(queue chan string) { for { str := <-queue fmt.Println("consumer receive: " + str) time.Sleep(3 * time.Sec...
package httpclient import ( "context" "log" "net/http" "testing" "time" "github.com/stretchr/testify/assert" "github.com/valyala/fasthttp" "github.com/mts-test-task/internal/sitesdataservice" "github.com/mts-test-task/internal/sitesdataservice/httpserver" svc "github.com/mts-test-task/pkg/sitesdataservice"...
package leetcode_0006_Zๅญ—ๅฝขๅ˜ๆข /* ๅฐ†ไธ€ไธช็ป™ๅฎšๅญ—็ฌฆไธฒๆ นๆฎ็ป™ๅฎš็š„่กŒๆ•ฐ๏ผŒไปฅไปŽไธŠๅพ€ไธ‹ใ€ไปŽๅทฆๅˆฐๅณ่ฟ›่กŒ Z ๅญ—ๅฝขๆŽ’ๅˆ—ใ€‚ ๆฏ”ๅฆ‚่พ“ๅ…ฅๅญ—็ฌฆไธฒไธบ "LEETCODEISHIRING" ่กŒๆ•ฐไธบ 3 ๆ—ถ๏ผŒๆŽ’ๅˆ—ๅฆ‚ไธ‹๏ผš L C I R E T O E S I I G E D H N ไน‹ๅŽ๏ผŒไฝ ็š„่พ“ๅ‡บ้œ€่ฆไปŽๅทฆๅพ€ๅณ้€่กŒ่ฏปๅ–๏ผŒไบง็”Ÿๅ‡บไธ€ไธชๆ–ฐ็š„ๅญ—็ฌฆไธฒ๏ผŒๆฏ”ๅฆ‚๏ผš"LCIRETOESIIGEDHN"ใ€‚ ่ฏทไฝ ๅฎž็Žฐ่ฟ™ไธชๅฐ†ๅญ—็ฌฆไธฒ่ฟ›่กŒๆŒ‡ๅฎš่กŒๆ•ฐๅ˜ๆข็š„ๅ‡ฝๆ•ฐ๏ผš string convert(string s, int numRows); ็คบไพ‹ 1: ่พ“ๅ…ฅ: s = "LEETCODEISHIRING", numRows = 3 ่พ“ๅ‡บ:...
package search // ็ฉบ็ป“ๆž„ๅœจๅˆ›ๅปบๅฎžไพ‹ๆ—ถ๏ผŒไธไผšๅˆ†้…ไปปไฝ•ๅ†…ๅญ˜ใ€‚ type defaultMatcher struct { } type defaultMatcherV2 struct { } // ไฝฟ็”จๅ€ผไฝœไธบๆŽฅๆ”ถ่€…ๅฃฐๆ˜Ž็š„ๆ–นๆณ•๏ผŒๅœจๆŽฅๅฃ็ฑปๅž‹็š„ๅ€ผไธบๅ€ผๆˆ–่€…ๆŒ‡้’ˆๆ—ถ๏ผŒ้ƒฝๅฏไปฅ่ขซ่ฐƒ็”จใ€‚ไธๆ‡‚๏ผŸ TODO func (m defaultMatcher) Search(feed *Feed, searchTerm string) ([]*Result, error) { return nil, nil } // ไฝฟ็”จๆŒ‡้’ˆไฝœไธบๆŽฅๆ”ถ่€…ๅฃฐๆ˜Ž็š„ๆ–นๆณ•๏ผŒๅช่ƒฝๅœจๆŽฅๅฃ็ฑปๅž‹็š„ๅ€ผๆ˜ฏไธ€ไธชๆŒ‡้’ˆ็š„ๆ—ถๅ€™่ขซ่ฐƒ็”จใ€‚ไธๆ‡‚๏ผŸ TODO func (m *default...
package main //1370. ไธŠๅ‡ไธ‹้™ๅญ—็ฌฆไธฒ //็ป™ไฝ ไธ€ไธชๅญ—็ฌฆไธฒs๏ผŒ่ฏทไฝ ๆ นๆฎไธ‹้ข็š„็ฎ—ๆณ•้‡ๆ–ฐๆž„้€ ๅญ—็ฌฆไธฒ๏ผš // //ไปŽ sไธญ้€‰ๅ‡บ ๆœ€ๅฐ็š„ๅญ—็ฌฆ๏ผŒๅฐ†ๅฎƒ ๆŽฅๅœจ็ป“ๆžœๅญ—็ฌฆไธฒ็š„ๅŽ้ขใ€‚ //ไปŽ sๅ‰ฉไฝ™ๅญ—็ฌฆไธญ้€‰ๅ‡บๆœ€ๅฐ็š„ๅญ—็ฌฆ๏ผŒไธ”่ฏฅๅญ—็ฌฆๆฏ”ไธŠไธ€ไธชๆทปๅŠ ็š„ๅญ—็ฌฆๅคง๏ผŒๅฐ†ๅฎƒ ๆŽฅๅœจ็ป“ๆžœๅญ—็ฌฆไธฒๅŽ้ขใ€‚ //้‡ๅคๆญฅ้ชค 2 ๏ผŒ็›ดๅˆฐไฝ ๆฒกๆณ•ไปŽ sไธญ้€‰ๆ‹ฉๅญ—็ฌฆใ€‚ //ไปŽ sไธญ้€‰ๅ‡บ ๆœ€ๅคง็š„ๅญ—็ฌฆ๏ผŒๅฐ†ๅฎƒ ๆŽฅๅœจ็ป“ๆžœๅญ—็ฌฆไธฒ็š„ๅŽ้ขใ€‚ //ไปŽ sๅ‰ฉไฝ™ๅญ—็ฌฆไธญ้€‰ๅ‡บๆœ€ๅคง็š„ๅญ—็ฌฆ๏ผŒไธ”่ฏฅๅญ—็ฌฆๆฏ”ไธŠไธ€ไธชๆทปๅŠ ็š„ๅญ—็ฌฆๅฐ๏ผŒๅฐ†ๅฎƒ ๆŽฅๅœจ็ป“ๆžœๅญ—็ฌฆไธฒๅŽ้ขใ€‚ //้‡ๅคๆญฅ้ชค 5๏ผŒ็›ดๅˆฐไฝ ๆฒกๆณ•ไปŽ sไธญ้€‰ๆ‹ฉๅญ—็ฌฆใ€‚ //้‡ๅคๆญฅ้ชค 1 ๅˆฐ 6 ๏ผŒ็›ดๅˆฐ sไธญๆ‰€ๆœ‰ๅญ—็ฌฆ้ƒฝๅทฒ็ป่ขซ้€‰่ฟ‡ใ€‚ //ๅœจไปปไฝ•ไธ€ๆญฅไธญ๏ผŒๅฆ‚ๆžœๆœ€ๅฐๆˆ–่€…ๆœ€ๅคงๅญ—็ฌฆไธๆญขไธ€ไธช๏ผŒ...
package main import ( "flag" "github.com/golang/glog" "net/http" ) func init() { flag.Set("alsologtostderr", "true") } var resp_chanel = make(chan interface{}) func getRequest(url string) { resp, err := http.Get("http://www.baidu.com") if err != nil { panic(err) } //s,err:=io.Copy(os.Stdout,resp.Body) //...
package lib import ( "encoding/json" "net/http" ) func Json(w http.ResponseWriter, v interface{}) error { err := json.NewEncoder(w).Encode(v) if err != nil { w.WriteHeader(http.StatusInternalServerError) return err } return nil } func BodyToJson(r *http.Request, v interface{}) error { err := json.NewDecod...
package handlers type banksDetails struct { Details []branchInformation `json:"bank_details"` } type branchInformation struct { Name string `json:"name,omitempty"` Ifsc string `json:"ifsc,omitempty"` BankID int64 `json:"bank_id,omitempty"` Branch string `json:"branch,omitempty"` Address string `js...
package main import ( "fmt" "math/big" ) func main() { lightSpeed := big.NewInt(299792) secondPerDay := big.NewInt(86400) distance := new(big.Int) distance.SetString("24000000000000000000", 10) fmt.Println("ใ‚ขใƒณใƒ‰ใƒญใƒกใƒ€้Š€ๆฒณใพใงใฎ่ท้›ขใฏใ€", distance, "km.") seconds := new(big.Int) seconds.Div(distance, lightSpeed) days :...
package orm type sqlParameter map[string]interface{} func (this sqlParameter) Set(key string, value interface{}) SqlParameter { this[key] = value return this } func NewSqlParameter() SqlParameter { return sqlParameter{} }
package utils import ( "HeartBolg/models" "fmt" "github.com/astaxie/beego/orm" ) type ArticlePageables struct { //ๆ€ป้กตๆ•ฐ PageCount int `json:"pageCount"` //ๅฝ“ๅ‰้กต*M CurrentPage int `json:"currentPage"` //ๆ€ปๆกๆ•ฐ TotalCount int `json:"totalCount"` //ๆฏ้กตๆกๆ•ฐ*M TotalNumber int `json:"totalNumber"` //่ตทๅง‹ๆกๆ•ฐ InitialNumber i...
package udwDockerV2 import ( "fmt" "github.com/tachyon-protocol/udw/udwFile" "github.com/tachyon-protocol/udw/udwGoSource/udwGoBuild" "github.com/tachyon-protocol/udw/udwGoSource/udwGoBuildCtx" "github.com/tachyon-protocol/udw/udwGoSource/udwGoWriter/udwGoTypeMarshal" "github.com/tachyon-protocol/udw/udwProjectP...
// Copyright (C) 2015-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 th...
package main import ( "encoding/json" "fmt" "log" ) type codes struct { Code int Description string } func main() { var data []codes rcvd := ` [{"Code":200,"Description":"StatusOK"}, {"Code":301,"Description":"StatusMovedPermanently"}, {"Code":302,"Description":"StatusFound"}, {"Code":303,"Descript...
package domain import ( "context" "time" "cloud.google.com/go/spanner" "github.com/google/uuid" ) type SessionService interface { GetSessionByID(ctx context.Context, txn Transaction, id string) (*Session, error) CreateSession(ctx context.Context, userID string) (string, error) ExpiresSessionByID(ctx context.C...
package sham import ( log "github.com/sirupsen/logrus" "time" ) // Scheduler ๆ˜ฏๆจกๆ‹Ÿ็š„่ฐƒๅบฆๅ™จ type Scheduler interface { // schedule ๅฎŒๆˆ่ฐƒๅบฆ๏ผšไผ ๅ…ฅCPU ๅฎžไพ‹ใ€่ฟ›็จ‹่กจ๏ผŒ // ๅŽŸๅ€ๅฎŒๆˆ่ฟ›็จ‹้˜Ÿๅˆ—่ฐƒๆ•ด๏ผŒๅนถๅœจ้œ€่ฆ็š„ๆ—ถๅ€™ๅš CPU.Switch๏ผˆไนŸๅฏไปฅไธๅš๏ผ‰ schedule(os *OS) } // NoScheduler ๆ˜ฏไธ€ไธชไธ่ฐƒๅบฆ็š„่ฐƒๅบฆๅ™จ๏ผŒ // ๅฎƒๅช่ฟ่กŒ่กจไธญ็ฌฌไธ€ไธชไธœ่ฅฟ๏ผŒ็„ถๅŽ็ป“ๆŸ้€€ๅ‡บใ€‚ type NoScheduler struct{} func (n NoScheduler) schedule(os...
package sqlx import "fmt" type ParameterGetter interface { Get(key string) (interface{}, error) } type ParameterHolder func(ParameterGetter) (interface{}, error) type ParameterHolders []ParameterHolder func (ph ParameterHolders) Values(getter ParameterGetter) ([]interface{}, error) { values := make([]interface{}...
// +build gateway package gateway import ( "github.com/kumahq/kuma/pkg/api-server/definitions" core_plugins "github.com/kumahq/kuma/pkg/core/plugins" core_mesh "github.com/kumahq/kuma/pkg/core/resources/apis/mesh" "github.com/kumahq/kuma/pkg/core/resources/registry" "github.com/kumahq/kuma/pkg/kds" "github.com/...
// // 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 config type Device[T any] interface { Config() Named Instance() T } type ConfigurableDevice[T any] interface { Device[T] ID() int Update(map[string]any, T) error Delete() error } type configurableDevice[T any] struct { config Config instance T } func NewConfigurableDevice[T any](config Config, inst...
package main import ( "log" "net/http" "text/template" ) var tpl *template.Template func init() { tpl= template.Must(template.ParseGlob("temp/*")) } func main() { http.HandleFunc("/slice",HomePage) log.Fatal(http.ListenAndServe(":8086",nil)) } func HomePage(w http.ResponseWriter, r *http.Request) { s := [...
package odoo import ( "fmt" ) // AccountChartTemplate represents account.chart.template model. type AccountChartTemplate struct { LastUpdate *Time `xmlrpc:"__last_update,omptempty"` AccountIds *Relation `xmlrpc:"account_ids,omptempty"` BankAccountCodePrefix ...
// Speak HTTP like a local -- a simple, intuitive HTTP console // This is a port of http://github.com/cloudhead/http-console package main import ( "bufio" "bytes" "crypto/tls" "encoding/base64" "flag" "fmt" "github.com/mattn/go-colorable" "github.com/peterh/liner" "io" "io/ioutil" "net" "net/http" "net/h...
package main import "fmt" func main(){ i:=1 fmt.Println(i) i=2 fmt.Println(i) i=1 for i<3 { fmt.Println(i) i=i+1 } for j:=5; j<9; j++{ fmt.Println("loop",j) if j==8{ break } } for n:=0; n<5;n++{ if n%2==0{ fmt.Println(n) } } }
// 16 july 2014 package ui import ( "unsafe" ) // #include "objc_darwin.h" import "C" type label struct { *controlSingleObject } func newLabel(text string) Label { l := &label{ controlSingleObject: newControlSingleObject(C.newLabel()), } l.SetText(text) return l } func (l *label) Text() string { r...
// 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 channel // ReceiveLightMeasurementParams holds the channel parameters used by the ReceiveLightMeasurement operation type ReceiveLightMeasurementParams struct { // StreetlightId is the ID of the streetlight. StreetlightId string } // TurnOnParams holds the channel parameters used by the TurnOn operation type...
package webui import ( "encoding/json" "fmt" "io" "net/http" "path" ) func parseUUID(r *http.Request) (string, error) { p := path.Base(r.URL.Path) if len(p) <= 1 { return "", fmt.Errorf("UUID value %q rejected", p) } return p, nil } func parseMap(r *http.Request) (v map[string]interface{}, err error) { d...
package main import ( "encoding/json" "fmt" "log" "os" "strings" "time" "github.com/PuerkitoBio/goquery" "github.com/gocolly/colly" ) type CoinEvent struct { Coin string Event string EventDate string } func main() { // Instantiate default collector c := colly.NewCollector( // Visit only dom...
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved. // See License for license information. package jobs import ( "io" "testing" "time" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "github.com/mattermost/mattermost-plugin-api/cluster" "github.com/mattermost/mattermost...
package tcx import ( "encoding/xml" "fmt" "io" "math" "os" "time" ) // Tcx represents the root of a TCX file type Tcx struct { XMLName xml.Name `xml:"TrainingCenterDatabase"` XMLNs string `xml:"xmlns,attr"` XMLNsXsi string `xml:"xsi,attr,omitempty"` XMLNsXsd string `xml:"xs...
package main import ( "log" "net/http" "time" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/vickleford/promex/flipper" "github.com/vickleford/promex/flopper" ) func main() { flipper := flipper.New() flopper := flopper.New() flopper....
package database //** Structs for Mutable's config.json **// // Mutable Configs type config struct { Prod envConfig Dev envConfig } //** Example Environment Configs // type envConfig struct { // Postgres postgresConfig }
// 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...
package expr import ( "image/color" "net/http" "time" "math" "strconv" "strings" ) var DefaultColorList = []string{"blue", "green", "red", "purple", "brown", "yellow", "aqua", "grey", "magenta", "pink", "gold", "rose"} type YAxisSide int const ( YAxisSideRight YAxisSide = 1 YAxisSideLeft = 2 ) ...
package abcc import ( "encoding/json" "fmt" "github.com/hexoul/go-abcc/types" ) // Me obtains your own personal asset information // arg: - // src: https://api.abcc.com/api/v1/members/me // doc: - func (s *Client) Me(options *types.Options) (*types.UserInfo, error) { url := fmt.Sprintf("%s/members/me?%s", ...
package auction import ( "io" "net/http" "net/http/httptest" "os" "testing" "time" ) func TestGetAuctionHouseSnapshotURL(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) if r.URL.EscapedPath() != "/wow/auction/data/server...
package main import ( "fmt" "io" "os" //"path/filepath" //"strings" "sort" ) func dirTree(out io.Writer, path string, printFiles bool) error { current_file, err := os.Open(path) if err != nil { return err } res, err1 := current_file.Readdir(-1) // ัะผะพั‚ั€ะธะผ, ั‡ั‚ะพ ะฒ ะดะธั€ะตะบั‚ะพั€ะธะธ sort.Sort(ByName(res)) // ัะพั€...
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in complian...
package main //Structure representation of game informations specific for a player type game struct { id int NbPlayer int Statistics statistic Team int }
package main import "fmt" func main() { expr := "favSport" switch expr { case "favSport": fmt.Println("Should Print") case "favColor": fmt.Println("Should Not Print") } }
package main import ( "fmt" "sort" ) type foo []int32 func (a foo) Len() int { return len(a) } func (a foo) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a foo) Less(i, j int) bool { return a[i] < a[j] } // Complete the maximumToys function below. func maximumToys(prices []int32, k int32) int32 ...
package cf import ( "log" "github.com/cloudfoundry-community/go-cfclient" "github.com/cloudfoundry-community/go-cfenv" ) // Bind - Bind will add a route to the App published on CF func Bind(routehost string, appGUID string, spaceGUID string, Username string, Password string, searchdomain string) (err error) { l...
/* 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 parser_test import ( "github.com/bytesparadise/libasciidoc/pkg/types" . "github.com/bytesparadise/libasciidoc/testsupport" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("checked lists", func() { Context("in final documents", func() { It("with title and dashes", func() {...
package ezgobot import ( "bytes" "regexp" "strings" "testing" ) func test(result, expected string, t *testing.T) { if result != expected { t.Errorf("Wrong output. Got |%s|, should be |%s|.", result, expected) } } func buildBot() { bootState := Init() s1 := bootState.BuildTransitionState("Hi. What's your na...
package main import ( "fmt" "os" "bufio" "strings" "strconv" ) func main() { fmt.Print("Enter a string:") scanner := bufio.NewScanner(os.Stdin) scanner.Scan() text := scanner.Text() fmt.Printf("IP string : <%s>..\n", text) words := strings.Split(text,".") if (len(words) != 4) { fm...
package main import ( "appengine" "appengine/datastore" "encoding/json" "io/ioutil" "net/http" "time" "strings" "fmt" "appengine/urlfetch" "errors" "bytes" ) // Data structure got from datastore user kind type User struct { InstanceId string `json:"instanceid"` RegistrationToken string ...
package gpgcli import ( // "io" "os/exec" "bytes" // "fmt" ) func (g *Gpg) cmd (args ...string) (string, string, error) { var err error var stdout bytes.Buffer var stderr bytes.Buffer var cmdArgs []string cmdArgs = append(cmdArgs, g.gpgOptions...) cmdArgs = append(cmdArgs, args...) cmd := exec.Command(`gpg`...
package test_test import ( "testing" "github.com/Rubentxu/lbricks/bgo" "os" "fmt" ) var testMemory *bgo.Memory func TestMain(m *testing.M) { // your func setup() retCode := m.Run() // your func //teardown() // call with result of m.Run() os.Exit(retCode) } func setup() { blac...
package nopaste import ( "fmt" "log" "net/http" "time" irc "github.com/thoj/go-ircevent" ) const ( MsgBufferLen = 100 ) var ( IRCThrottleWindow = 1 * time.Second ) type MessageChan interface { PostNopaste(np nopasteContent, url string) PostMsgr(np *http.Request) } type IRCMessage struct { Channel string...
/* * @Author: Sy. * @Create: 2019-11-01 20:54:15 * @LastTime: 2019-11-16 18:30:34 * @LastEdit: Sy. * @FilePath: \server\models\role_auth.go * @Description: ่ง’่‰ฒๆƒ้™ๆŽงๅˆถ */ package models import ( "bytes" "strconv" "strings" "github.com/astaxie/beego/orm" ) type RoleAuth struct { AuthId int `orm:"pk"` RoleId ...
package todo type Todo struct { Title string Done bool } func (t *Todo) Finish() { t.Done = true }
/* Package gadget provides a smallish web application framework with a soft spot for content negotiation. An overview of usage can be found at http://redneckbeard.github.io/gadget. */ package gadget
/* 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 io import ( "encoding/csv" "fmt" "io" "log" "os" ) type FileHandler interface { ReadFile() WriteFile() CreateFile() } func WriteToJsonFile(jsonStr string) { f, err :=os.OpenFile("data.json", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755) if err != nil { log.Fatal(err) } defer f.Close() f.WriteString...
// +build storage_all !storage_pgx,!storage_boltdb,!storage_fs,!storage_badger,!storage_sqlite package app import ( "path" "unsafe" authbadger "github.com/go-ap/auth/badger" authboltdb "github.com/go-ap/auth/boltdb" authfs "github.com/go-ap/auth/fs" authpgx "github.com/go-ap/auth/pgx" authsqlite "github.com/g...
package repository import "github.com/fwchen/jellyfish/domain/taco" type Repository interface { List(userId string, filter taco.TacoFilter) ([]taco.Taco, error) Save(taco *taco.Taco) (*string, error) SaveList(tacos []taco.Taco) error FindById(tacoID string) (*taco.Taco, error) MaxOrderByCreatorId(userId string) ...
// Copyright 2015 go-swagger maintainers // // 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 agr...
package controller import ( "encoding/json" "fmt" "log" "net/http" "os" "time" "github.com/slack-go/slack" "github.com/tarao1006/attendance-slackapp/sheet" ) type Submit struct { client *slack.Client spreadsheetService *sheet.SpreadsheetService } func NewSubmit(client *slack.Client, spreadshee...
package Produce import ( "bytes" "reflect" "github.com/mkocikowski/libkafka/wire" ) func UnmarshalResponse(b []byte) (*Response, error) { r := &Response{} buf := bytes.NewBuffer(b) err := wire.Read(buf, reflect.ValueOf(r)) return r, err } type Response struct { TopicResponses []TopicResponse ThrottleTimeMs...
// MIT License // // Copyright (c) Microsoft Corporation. All rights reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the righ...
// 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 v1beta1 contains API Schema definitions for the auth v1beta1 API group // +k8s:deepcopy-gen=package,register // +groupName=auth.example.com package v1beta1
package prototmpl import ( "encoding/json" "fmt" "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/reflect/protoreflect" "regexp" "strconv" ) var substitutionExpressionRegex *regexp.Regexp func init() { var err error substitutionExpressionRegex, e...
package helpers import "golang.org/x/crypto/bcrypt" func PasswordHash(password string) (string, error) { hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.MinCost) return string(hash), err } func ValidateHash(secret, hash string) bool { err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(sec...
package config import ( "github.com/hashicorp/vault/api" "github.com/mitchellh/mapstructure" ) type Vault interface { LookupWithAppRole(roleID, secretID, path string) (*Config, error) LookupWithToken(token, path string) (*Config, error) } type vault struct { client *api.Client } func NewVault(vaultAddr, caCert...
package runner import ( "bytes" "flag" "testing" ) func TestProcessChunks(t *testing.T) { flag.Set("log_chunk_size", "3") in := []byte("aaa\naaa\naaa\n") ch := make(chan LogChunk) go func() { processChunks(ch, bytes.NewReader(in)) close(ch) }() cnt := 0 for _ = range ch { cnt++ } if cnt != 3 { ...
package models //LoginCredentials model for manage login data type LoginCredentials struct { Email string `json:"email"` Password string `json:"password"` }
package main import ( "testing" ) func TestBitSet_Has(t *testing.T) { bs := NewBitSet() bs.Add(1) bs.Add(3) bs.Add(5) bs.Add(7) bs.Add(100) bs.Add(101) bs.Add(102) bs.Add(103) bs.Add(104) bs.Add(105) bs.Add(106) bs.Del(101) bs.Del(103) bs.Del(105) tests := []struct { val int want bool }{ {0, ...
package info import ( "encoding/json" "fmt" "net/http" "strings" "github.com/golang/glog" "github.com/julienschmidt/httprouter" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" ) const ( statusActive string = "ACTIVE" statusDisabled string = "DISABLED" ) // NewBidde...
package appendOnly_test import ( "bytes" "github.com/SarthakMakhija/basics-of-database-design/kv/appendOnly" "os" "testing" ) func TestCreatesANewFile(t *testing.T) { fileIO := appendOnly.NewFileIO() fileName := "./kv.test" fileIO.CreateOrOpenReadWrite(fileName) defer deleteFile(fileName) if fileIO.File.Na...
// Copyright 2021 The gVisor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agree...
package main import ( "context" "fmt" "time" log "github.com/sirupsen/logrus" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" khjobv1 "github.com/kuberhealthy/kuberhealthy/v2/pkg/apis/khjob/v1" "k8s.io/client-go/kubernetes" _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" ) // ReapCh...