text
stringlengths
11
4.05M
package main import ( "fmt" "math/rand" "sync" "time" ) // 读写模式,一把锁 var rwMutex sync.RWMutex func readGo(in <-chan int, i int) { for { rwMutex.RLock() // 以读模式加锁 num := <-in // 读取数据(但没有数据,会阻塞) fmt.Printf("-----%dth 读 协程,读出:%d\n", i, num) rwMutex.RUnlock() // 以读模式解锁 } } func writeGo(out chan<- int, i i...
package analysis import ( "encoding/json" "net/http" "strconv" "github.com/gorilla/handlers" "github.com/gorilla/mux" "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/gtosh4/WoWCDHelper/internal/pkg/ctx" "github.com/gtosh4/WoWCDHelper/pkg/warcraftlogs" "github.com/gtosh4/WoWCDHelper/pkg/war...
package flakeid import ( "errors" "sync" ) type Flaker struct { shardID uint16 seqID uint8 seqMutex *sync.Mutex } func NewFlaker(shardID uint16) *Flaker { return &Flaker{ shardID: shardID, seqID: 0, seqMutex: &sync.Mutex{}, } } func (flaker *Flaker) nextSeqID() uint8 { flaker.seqMutex.Lock() ...
package main import ( "bufio" "errors" "fmt" "os" "strconv" ) func solve(entries []int) (int, error) { for _, a := range entries { for _, b := range entries { if a+b == 2020 { return a * b, nil } } } return 0, errors.New("no match") } func main() { scanner := bufio.NewScanner(os.Stdin) entri...
package palindrome import "sort" func isEqual(s sort.Interface, i, j int) bool { return !s.Less(i, j) && !s.Less(j, i) } func isPalindrome(s sort.Interface) bool { lastIdx := s.Len() - 1 for i := 0; i < s.Len()/2; i++ { if !isEqual(s, i, lastIdx-i) { return false } } return true }
// 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, ...
// +build windows package open import ( "os" "os/exec" "path/filepath" ) var ( cmd = "url.dll,FileProtocolHandler" runDll32 = filepath.Join(os.Getenv("SYSTEMROOT"), "System32", "rundll32.exe") ) func open(input string) *exec.Cmd { cmd := exec.Command(runDll32, cmd, input) return cmd }
package requests import ( "fmt" "net/url" "strings" "github.com/atomicjolt/canvasapi" ) // DeleteEntryGroups Delete a discussion entry. // // The entry must have been created by the current user, or the current user // must have admin rights to the discussion. If the delete is not allowed, a 401 will be returned...
package main import ( "bufio" "bytes" "context" "flag" "fmt" "io" "io/ioutil" "log" "net/http" "os" "path/filepath" "strings" "github.com/apoorvam/goterminal" "github.com/common-nighthawk/go-figure" "github.com/oracle/oci-go-sdk/common" "github.com/oracle/oci-go-sdk/objectstorage" ) func main() { s...
package gbt2659 func LookupCode2(code string) *Record { s := getStore() return dup(s.code2[code]) } func dup(r *Record) *Record { if r != nil { rr := *r return &rr } return nil }
package config import ( "bytes" "context" "example.com/http_demo/utils/zlog" "github.com/spf13/viper" "go.etcd.io/etcd/client/v3" "go.uber.org/zap" "io" "time" ) type RemoteConfig struct { viper.RemoteProvider Username string Password string } func (c *RemoteConfig) Get(rp viper.RemoteProvider) (io.Reade...
package db import ( "fmt" "os" "sort" "strconv" "time" golog "github.com/op/go-logging" ) var log = golog.MustGetLogger("main") func GetUniqueId() string { //https://groups.google.com/forum/#!topic/golang-nuts/d0nF_k4dSx4 f, err := os.OpenFile("/dev/urandom", os.O_RDONLY, 0) if err != nil { log.Info("Err...
// Copyright 2018, OpenCensus 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 ( "bytes" "io" "os" "strings" ) // https://en.wikipedia.org/wiki/ROT13 type rot13Reader struct { r io.Reader } var from = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz") var to = []byte("NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm") func rot13(b byte) byte { //// In...
package mappers import ( "RBStask/app/models/entity" "database/sql" "fmt" ) type RemTaskMapper struct { db *sql.DB } func (m *RemTaskMapper) Init(db *sql.DB) error { m.db = db return nil } func (m *RemTaskMapper) RemoveTasks(projectId *entity.Project) error { sqlSelect := `DELETE FROM public.tasks WHERE id...
package main import ( "context" "sync/atomic" pb "github.com/xpunch/go-micro-example/v3/event/proto" ) type handler struct{} func (h *handler) Statistics(ctx context.Context, in *pb.StatisticsRequest, out *pb.StatisticsReply) error { if in.Method == nil || len(*in.Method) == 0 { out.AccessCount = atomic.LoadI...
package main import ( "fmt" "time" ) // 生产者:发送数据端 func producer(out chan<- int, value int) { for i:=0; i<50; i++ { fmt.Printf("生产者[%d],生产[%d]\n", value, i) out <- value*i } close(out) } // 消费者:接受数据端 func consumer(in <- chan int) { for num := range in { fmt.Println("消费者,消费:", num) time.Sleep(time.Second...
/* 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 ipam import ( "context" "fmt" "net" "github.com/giantswarm/ipam" "github.com/giantswarm/microerror" "github.com/giantswarm/micrologger" "github.com/giantswarm/e2etests/v2/ipam/provider" ) type Config struct { Logger micrologger.Logger Provider provider.Interface ClusterID string } type IPAM st...
// 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 main /** 漏桶算法 当桶里的水满的时候,则拒绝服务 每服务一次,则添加水 */ import ( "fmt" "math" "sync" "time" ) type LeakyBucket struct { rate float64 //固定每秒出水速率 capacity float64 //桶的容量 water float64 //桶中当前水量 lastLeakMs int64 //桶上次漏水时间戳 ms lock sync.Mutex } func (l *LeakyBucket) Allow() bool { l....
package models type PaymentMethod struct { ConektaBase Type string `json:"type,omitempty"` TokenId string `json:"token_id,omitempty"` PaymentSourceID string `json:"payment_source_id,omitempty"` ServiceName string `json:"service_name,omitempty"` BarcodeURL ...
package channel import ( "errors" "fmt" "io" "io/ioutil" "sync" "github.com/FISCO-BCOS/crypto/tls" "github.com/FISCO-BCOS/crypto/x509" "github.com/chislab/go-fiscobcos/common/hexutil" "github.com/chislab/go-fiscobcos/core/types" "github.com/tidwall/gjson" ) type Client struct { conn *tls.Conn buffer ...
package bittrex_test import ( "testing" "time" "github.com/carterjones/bittrex" ) func TestTick_String(t *testing.T) { cases := map[string]struct { in bittrex.Tick exp string }{ "normal": { in: bittrex.Tick{ Timestamp: "faketimestamp", Open: 2.1, High: 3.0, Low: 1.0, ...
package main // _ . alias import "fmt" func main() { fmt.Println("Hello World") }
package engine // movelist.go implements a very basic stack for holding moves const MaxMoves = 255 type MoveList struct { Moves [MaxMoves]Move Count uint8 } func (moveList *MoveList) AddMove(move Move) { moveList.Moves[moveList.Count] = move moveList.Count++ }
package dceif import ( "log" dcejs "spca/infra/de/json" dcexml "spca/infra/de/xml" apdm "spca/apd/models" ) const ( DTJSON = "json" DTXML = "xml" ) var DceifHdl map[string]DataCtrlIf // DataCtrlInit Initialize the interface func DataCtrlInit(){ log.Println("Data Controller Initializat...
package pogs import ( "errors" "time" ) // AuthenticateResponse is the serialized response from the Authenticate RPC. // It's a 1:1 representation of the capnp message, so it's not very useful for programmers. // Instead, you should call the `Outcome()` method to get a programmer-friendly sum type, with one // case...
package common import ( "fmt" "github.com/gogf/gf/net/ghttp" "github.com/gogf/gf/os/glog" "github.com/gogf/gf/util/gconv" "github.com/zhwei820/gadmin/app/model" "strings" ) var RouterMap = make(map[string]model.RolePolicy) // BindGroup 绑定分组路由 // // createTime:2019年04月29日 16:45:55 // author:hailaz func BindGrou...
package routers import ( "main/core" "main/core/business" "main/core/models" "net/http" "github.com/labstack/echo/v4" ) type UserRouter struct { Name string g *echo.Group } func (r *UserRouter) Connect(s *core.Server) { r.g = s.Echo.Group(r.Name) user := business.UserBusiness{ DB: s.DB, } user.Cre...
package main import ( "context" "fmt" "log" "os" "os/signal" "sync" "syscall" "github.com/docktermj/go-logger/logger" "github.com/docktermj/go-etcd-service/common/runner" "github.com/docktermj/go-etcd-service/service/etcd" "github.com/docopt/docopt-go" "github.com/spf13/viper" ) var ( programName = "...
// This file was generated by counterfeiter package fakes import ( "sync" "github.com/cfmobile/gopivnet/api" "github.com/cfmobile/gopivnet/resource" ) type FakeApi struct { GetLatestProductFileStub func(productName string, fileType string) (*resource.ProductFile, error) getLatestProductFileMutex sy...
package adddigits import "testing" func TestAddDigits(t *testing.T) { var result int if result = addDigits(38); result != 2 { t.Errorf("Get %d, Expect 2", result) } if result = addDigits(12); result != 3 { t.Errorf("Get %d, Expect 3", result) } if result = addDigits(1234); result != 1 { t.Errorf("Get %...
// Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
package storageos import ( "context" "fmt" "net" "reflect" "strings" "time" storageosv1 "github.com/storageos/cluster-operator/pkg/apis/storageos/v1" storageosapi "github.com/storageos/go-api" v1 "k8s.io/api/core/v1" ) var ( // nodeLivenessTimeout specifies how long we should wait for a connection to // t...
package salt import ( "crypto/rand" "fmt" "sync" "time" "google.golang.org/protobuf/proto" pb "github.com/iotaledger/hive.go/autopeering/salt/proto" ) // SaltByteSize specifies the number of bytes used for the salt. const SaltByteSize = 20 // Salt encapsulates high level functions around salt management. typ...
package user import( "2fa/domain/model" "time" ) type User struct { ID model.UserID Email string MFAType string CreatedAt time.Time UpdatedAt time.Time }
package main import ( "context" //快速构建命令行应用程序 "github.com/urfave/cli/v2" //Trace包 调试跟踪信息 "go.opencensus.io/trace" //build全局信息和一些基础定义(编译) "github.com/filecoin-project/lotus/build" //cmd包,包括基础cmd和开发者cmd lcli "github.com/filecoin-project/lotus/cli" //log 日志信息 "github.com/filecoin-project/lotus/lib/lotuslog" ...
package stub import ( "fmt" "strings" "sync" "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/service/athena" "github.com/aws/aws-sdk-go/service/athena/athenaiface" "github.com/pkg/errors" "github.com/skatsuta/athenai/internal/testhelper" ) const out...
package v1 import ( "errors" "net/http" "net/url" "github.com/google/uuid" "github.com/labstack/echo/v4" "github.com/traPtitech/trap-collection-server/src/config" "github.com/traPtitech/trap-collection-server/src/domain/values" "github.com/traPtitech/trap-collection-server/src/handler/v1/openapi" "github.com...
package main import ( "github.com/SantiagoZuluaga/GoAuth/app" ) func main() { app.RunServer() }
package websever import ( "../utils" "github.com/axgle/mahonia" "time" ) func NoCahce() { logger.Println(_url, " cookie 读取失败...") //请求url _, err := utils.GetUrlHtml(_url) if err != nil { logger.Fatal(err) } time.Sleep(100 * 5) logger.Println(_url, "打开主页.....") _, err = utils.PostUrlHtml(_url+"/auth/login...
// 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 urlstore import ( "testing" "github.com/stretchr/testify/assert" ) func TestShorten(t *testing.T) { urlStore := NewURLStore() url := "http://justincampbell.me" token := "1" assert.Equal(t, token, urlStore.Shorten(url)) } func TestExpand(t *testing.T) { urlStore := NewURLStore() url := "http://justin...
package dynamicProgramming import "math" // Recursion func RodMaximumProfitCut_Recursive(cutPrices []int, currentLength int) int { // No cut is possible if original rod length is zero if currentLength == 0 { return 0 } // We assume that the current length has the maximum price currentMaxPrice := cutPrices[cur...
package util import ( "testing" "github.com/stretchr/testify/assert" ) func TestRegexFormatB(t *testing.T) { tests := []struct { input string regexExpr string outputTemplate string expectedOutput string expectedError error }{ {"input string", `input (?P<val>.*)`, "{{.val}}", "string", ...
package role import ( "time" ) const TBNRole = "role" type TblRole struct { Id int64 CreateAt *time.Time Status int `json:"status"` Name string `orm:"varchar(30)" json:"name"` } func (m *TblRole) TableName() string { return TBNRole }
package hivesql import ( "errors" ) //Error in package var ( ErrInvalidConn = errors.New("invalid connection") ErrMalformPkt = errors.New("malformed packet") ErrNoTLS = errors.New("TLS requested but server does not support TLS") ErrCleartextPassword = errors.New("this user requires clear...
// 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 graphfsm import ( "errors" "fmt" ) const InitialStateName = "-1" type StateOrderAction interface { StateDefaultHandler(fsmObj *TransactionFSMObj, totalArgs int, data interface{}) EmptyStateHandler(fsmObj *TransactionFSMObj, totalArgs int, data interface{}) } type StateActionFunc func(*TransactionFSMObj,...
package comm import ( "testing" ) func TestCal_2009_02_02(t *testing.T) { ld := ToLunarDate("2009-02-02") if ld.Format("2006-01-02") != "2009-01-08" { t.Error("lunar calendar error") } } func TestCal_2010_02_02(t *testing.T) { ld := ToLunarDate("2010-02-02") if ld.Format("2006-01-02") != "2009-12-19" { t.Er...
package main import ( "encoding/json" "fmt" "log" "net/http" "net/http/httputil" "os" "strings" "sync" "time" "github.com/KEXPCapstone/shelves-server/gateway/handlers" "github.com/KEXPCapstone/shelves-server/gateway/models/users" "github.com/KEXPCapstone/shelves-server/gateway/sessions" mgo "github.com/g...
package azure_test import ( "errors" "github.com/genevieve/leftovers/azure" "github.com/genevieve/leftovers/azure/fakes" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("Group", func() { var ( client *fakes.GroupsClient name string group azure.Group ) BeforeEach(func() { ...
package main import ( "bytes" "fmt" "io/ioutil" "log" "net/http" "net/http/httputil" "net/url" "strconv" "time" ) func replaceRequest() { director := func(request *http.Request) { request.URL.Scheme = "http" request.URL.Host = ":9001" } rp := &httputil.ReverseProxy{ Director: director, } server :=...
package models type PlatForm struct { Osname string `json:"osname"` //linux windows Arch string `json:"arch"` //arm x86 }
package main import "fmt" func main() { x := 12121 fmt.Println(isPalindrome(x)) } func isPalindrome(x int) bool { // 负数不是 if x < 0 { return false } reverse := 0 tmp := x for tmp != 0 { reverse = reverse*10 + tmp%10 tmp /= 10 } return reverse == x }
package process import ( "testing" "time" "github.com/newrelic/infra-integrations-sdk/integration" "github.com/newrelic/nri-vsphere/internal/config" "github.com/stretchr/testify/assert" "github.com/vmware/govmomi/vim25/types" ) func TestSnapshots(t *testing.T) { snapshot := types.ManagedObjectReference{ Ty...
package helper import "testing" func Equal(a, b []interface{}) bool { if len(a) != len(b) { return false } for i, v := range a { if v != b[i] { return false } } return true } func TestCompactPassingNil(t *testing.T) { _, error := Compact(nil) if error == nil { t.Errorf("Compact function is incorre...
package main import "sync" type PoolSeg struct { ID int Nodes map[string]*NodeStatus Lock sync.Mutex Next *PoolSeg }
package main import ( "fmt" "github.com/cloudfoundry/cli/plugin" ) type TunnelService struct { ServiceInstanceName string ServiceInstancePort string ServiceName string ServicePlan string } func (t *TunnelService) GetMetadata() plugin.PluginMetadata { return plugin.PluginMetadata{ Name: "Tun...
package main func main() { numbers := []int{1, 2, 3} }
package util import ( "fmt" "net/http" "github.com/gin-gonic/gin" ) // A stupid simple middleware that checks that a request has a // Authorization: Basic $SECRET // header func SecretProvided(secret string) gin.HandlerFunc { expectedValue := fmt.Sprintf("Bearer %s", secret) return func(c *gin.Context) { if c...
package queues import ( "bufio" "os" "testing" ) func TestMain(t *testing.T) { f, _ := os.Open("test_input1") reader := bufio.NewReader(f) main(reader) }
// 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 avl import ( "fmt" ) // CheckUp - check the up pointers for consistency func (tree *Tree) CheckUp() bool { return checkUp(tree.root, nil...
package cmd import ( "github.com/golang-friends/members/internal/application" "github.com/golang-friends/members/internal/client" "github.com/golang-friends/members/internal/config" "github.com/spf13/cobra" "github.com/spf13/viper" ) var writeCmd = &cobra.Command{ Use: "write", Short: "it will write `members...
package lc import "sort" // Time: O(n logn) // Benchmark: 0ms 2.1mb | 100% func lastStoneWeight(stones []int) int { sort.Ints(stones) for len(stones) >= 2 { stone := stones[len(stones)-1] - stones[len(stones)-2] stones = stones[:len(stones)-2] if stone > 0 { // get the index to push stone on slice. id...
package main func main() { }
// Copyright 2015 Google Inc. 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 applicabl...
package mservice type ServicePettransfer struct { ServiceRecord Price float64 Age string SelfIntroduction string PetIntroduction string Image string Hint string }
/** * Copyright (c) 2020 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless ...
package core import ( "bytes" "github.com/moltin/gomo/form" ) // FileUploadRequest represents a request to upload a file to Moltin type FileUploadRequest struct { File bytes.Buffer `json:"file"` Public bool `json:"public,omitempty"` } // File is a Moltin File - https://docs.moltin.com/advanced/files t...
// Copyright 2019 Istio 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 i...
package typapp_test import ( "fmt" "log" "strings" "testing" "github.com/stretchr/testify/require" "github.com/typical-go/typical-go/pkg/typapp" "go.uber.org/dig" ) func ExampleStartApp() { typapp.Reset() // make sure constructor and container is empty (optional) typapp.Provide("", func() string { return "w...
package main import ( "encoding/json" "flag" "fmt" "io/ioutil" "net/http" "os" "log" ) type Dependency struct { Name string `json:"name"` Implied bool `json:"implied"` Optional bool `json:"optional"` Title string `json:"title"` Version string `json:"version"` } type Plugin struct { BuildDat...
package repository import ( "testing" "Assignment/models" "github.com/DATA-DOG/go-sqlmock" "github.com/stretchr/testify/assert" ) func Test_gitUserRepository_CreateGitUser(t *testing.T) { mock, db := NewMock() defer mock.Close() type args struct { uow *UnitOfWork out *models.Github } tests := []struct {...
package service import ( "errors" "fmt" "github.com/google/uuid" "github.com/jinzhu/copier" "log" "pub/data" "pub/dtos" "sync" ) type RPC int var mu sync.RWMutex func (a *RPC) CreateTopic(topicID string, replyTopic *dtos.TopicDto) error { if topicID == "" { return errors.New("TopicID empty") } mu.Lock(...
package apprpc import "github.com/cmu440/airline/util" type Status int const ( OK Status = iota + 1 FlightNotExist TicketSoldOut Fail ) type GetTicketArgs struct{ TicketReq *util.TicketRequest } type ReserveTicketArgs struct { ClientId string TicketReq *util.TicketRequest } type CancelTicketArgs struct {...
package migrate // アプリケーションのv1 type ( GameTable = gameTable GameVersionTable = gameVersionTable GameURLTable = gameURLTable GameFileTable = gameFileTable GameFileTypeTable = gameFileTypeTable GameImageTable = gameImageTable GameIma...
package logging import ( "context" "log" "go.uber.org/zap" "go.uber.org/zap/zapcore" ) var logkey struct{} var logger *zap.SugaredLogger func init() { config := zap.NewProductionConfig() config.Encoding = "console" config.EncoderConfig.EncodeTime = zapcore.RFC3339TimeEncoder _logger, err := config.Build() ...
package mservice import ( "time" "tripod/convert" "tripod/timekit" "webserver/common" "webserver/models" ) type ServiceRecord struct { Id int ServiceType int UserId int CommunityId int OfficebuildingId int SchoolId int HometownId int //IfCommunityAround int...
// 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 datastorage import ( "testing" "fmt" "github.com/pbdekeijzer/GoLangPractice/models" "github.com/stretchr/testify/assert" ) var id = 1 // setup issue object func setUpIssue() models.Issue { issue := models.Issue{IssueContent: "Test issue creation", Status: "Busy", Comments: nil} return CreateIssue(iss...
// 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 shell import ( "fmt" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/utils/migration" "github.com/redhat-openshift-ecosystem/openshift-preflight/cli" ) var _ = Describe("LessThanMaxLayers", func() { var ( lessThan...
//+build wireinject package httpsrv import ( "context" "github.com/google/wire" "gocloud.dev/aws/awscloud" "gocloud.dev/server" ) func SetupAWS(ctx context.Context) (*server.Server, func(), error) { wire.Build( awscloud.AWS, applicationSet, ) return nil, nil, nil }
package main import ( "fmt" "encoding/json" ) type Student struct { Name string `json:"name"` Age uint `json:"age"` Hobby []string `json:"hobby"` } func main() { var slice = []int{2, 3, 4, 5} fmt.Printf("修改之前的slice地址%p\n", slice) slice = append(slice, 6) fmt.Printf("修改之后的slice地址%p\n", slice) var map1 map...
package objectvisitor_test import ( "context" "testing" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" clusterFake "github.com/vmware/octant/internal/cluster/fake" configFake "github.com/vmware/octant/intern...
package main import "fmt" // Person exported type Person struct { First string Last string Age int } // this struct DoubleZero // is getting "promoted" // by inheriting the fields in the person struct // DoubleZero exported type DoubleZero struct { Person LicenseToKill bool } func main() { p1 := DoubleZer...
package main import ( "fmt" "log" "net/http" "github.com/gorilla/mux" ) var ( entryDb EntryDb ) func init() { entryDb = newInMemoryFuelEntryDb() } // TODO how to use a logger // TODO how to use an appError func main() { router := mux.NewRouter() // Catch all handler router.NotFoundHandler = http.Handle...
/* This is a template to how a concrete view should look like, which collects all relevant data from all plugins. A new View e.g. PersonalView should somehow differentiate from general view. You should either trim or extend received data from FetchData Method. Or the plugins should extend a new method (e.g. FetchSpecia...
// File: gpn.go // 5/4/2014 // Edited by Wangdeqin // Get number of pages from []byte of a html doc package gpn import ( "fmt" "os" "regexp" "strconv" ) func checkErr(err error) { if err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) os.Exit(0) } } func GetNumPages(byts []byte) int64 { var max_pn in...
// 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" "fmt" "net/http" "time" arcui "chromiumos/tast/common/android/ui" "chromiumos/tast/common/testexec" "chromiumos/tast/ctxutil" "chromi...
package controllers import ( "strings" "time" "os" "path" "fmt" "image/jpeg" "strconv" "image" "errors" "github.com/astaxie/beego" "github.com/nfnt/resize" models "../models" ) type TireCatalogImageController struct { beego.Controller } func imageResize(filePath, newFilePath string, width, height uint, ...
package prov import ( "fmt" "io" "strings" ) type PathRole struct { RunID int64 Path string PathIndex int64 Role string } var ( roleForPathIndex map[int64]string ) func init() { roleForPathIndex = make(map[int64]string) } func GetPathRoleFacts(config Config, runID int64) []PathRole { var al...
package views import ( "github.com/winded/tyomaa/frontend/js/app" "github.com/winded/tyomaa/frontend/js/dom" "github.com/winded/tyomaa/frontend/js/models" ) // ResettableView represents a View that can be reset to it's original state by calling Reset() type ResettableView interface { View Reset() } type PageMap...
// 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 ttx import ( "encoding/json" "fmt" "net/http" "github.com/prebid/openrtb/v19/adcom1" "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" ...
// Copyright 2016 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 mbt import ( "github.com/buckhx/diglet/geo" "github.com/buckhx/diglet/mbt/mvt" "github.com/buckhx/diglet/util" "github.com/buckhx/mbtiles" "github.com/buckhx/tiles" ) // ClipBuffer is the number of pixels to buffer a tile clipping var ClipBuffer = 10 type Tileset struct { tileset *mbtiles.Tileset args...
/* Simplify Path Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c" click to show corner cases. Corner Cases: Did you consider the case where path = "/../"? In this case, you should return "/". Another corner case is the path might c...