text
stringlengths
11
4.05M
package main import ( "fmt" ) func main() { var count, n, d, m int fmt.Scanf("%d\n", &n) chocolateBar := readLine(n) fmt.Scanf("%d %d\n", &d, &m) for idx := range chocolateBar { sum := 0 if idx+m <= len(chocolateBar) { for _, num := range chocolateBar[idx : idx+m] { sum += num } if sum == d {...
package grpcserver import ( "context" "fmt" "strconv" "time" "github.com/packethost/pkg/log" "github.com/tinkerbell/tink/db" pb "github.com/tinkerbell/tink/protos/workflow" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) var workflowData = make(map[string]int) const ( errInvalidWorkerID ...
package sql import ( "database/sql" "fmt" "strings" "github.com/phogolabs/orm/dialect/sql/scan" ) var _ Procedure = &RoutineQuery{} // RoutineQuery represents a named routine type RoutineQuery struct { name string dialect string args []interface{} stmt *NamedQuery } // Routine create a new routine...
package ds import ( "fmt" "sort" ) type SuffixArray struct { suffix []string n int } func NewSuffixArray(text string) *SuffixArray { sa := new(SuffixArray) sa.n = len(text) sa.suffix = make([]string, sa.n) for i := 0; i < sa.n; i++ { sa.suffix[i] = text[i:] } sort.Strings(sa.suffix) return sa } fu...
package saga import ( "context" "time" "github.com/sirupsen/logrus" "github.com/wework/grabbit/gbus" ) //TimeoutManager manages timeouts for sagas //TODO:Make it persistent type TimeoutManager struct { bus gbus.Bus } //RequestTimeout requests a timeout from the timeout manager func (tm *TimeoutManager) Request...
package draw type Padding struct { Left, Top, Right, Bottom int }
package routes import ( "github.com/kataras/iris/v12" ) func registerHTTPErrorRoute(app *iris.Application) { app.OnErrorCode(iris.StatusNotFound, notFound) app.OnErrorCode(iris.StatusInternalServerError, internalServerError) // to register a handler for all "error" // status codes(kataras/iris/context....
package main import "fmt" func funcTest(msg string) { fmt.Println(msg) } //方法作為參數 func apply(arr []float64, callback func(float64) float64) []float64 { out := make([]float64, len(arr)) for i, v := range arr { out[i] = callback(v) } return out } //閉包 func num() func() int { n := -1 return func() int { ...
//Copyright 2019 Chris Wojno // // 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 rights to use, copy, modify, merge, publish, distribut...
/* Copyright 2019 The xridge kubestone contributors. 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 cloud import ( "context" "fmt" "os" "regexp" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" ) type KubernetesAPIClient func() (kubernetes.Interface, error) var DefaultKubernetesAPIClient = func() (kubernetes.Interface, error) { // creates the in-c...
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved. // This program and the accompanying materials are made available under the terms of the under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. // You may obtain a copy of the Licen...
/* Copyright 2019 Jagadish Nagarajaiah. 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, so...
package utils import ( "encoding/json" "net/http" ) // SendResponse takes care of api response func SendResponse(w http.ResponseWriter, status int, data interface{}) { w.WriteHeader(status) json.NewEncoder(w).Encode(data) }
package main import ( "fmt" "github.com/quin47/live-chatlog/record" ) func main() { fmt.Println("starting ...") roomIds := [...]int{544793, 938306,602,526,48840,12771281} // 我是怪异君,龙傲娇, 性巴莎拉,青衣才不是御姐呢,凉风OvQ,蒲苇冥冥 for _,v := range roomIds { go record.Record(v) } select { } }
// 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 network import ( "context" "reflect" "chromiumos/tast/local/bundles/cros/network/vpn" "chromiumos/tast/local/chrome" "chromiumos/tast/local/network/netconfig" ...
// Copyright 2015 Bowery, Inc. package slack import ( "encoding/json" "errors" "fmt" "net/http" "net/url" ) var ( slackAddr = "https://slack.com/api" ) const ( postMessageURI = "chat.postMessage" ) type slackPostMessageRes struct { Ok bool Error string } type Attachment struct { Fallback string ...
// Copyright 2019 Adobe. All rights reserved. // This file is licensed to you 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 applicab...
package genericerror import ( "testing" ) func TestError(t *testing.T) { e := &GenericError{"Foo"} if e.Error() != "Foo" { t.Error("GenericError method call returns invalid value") } }
package main import ( "fmt" "github.com/azak-azkaran/cascade/utils" "github.com/stretchr/testify/assert" "net/http" "os" "syscall" "testing" "time" ) func TestGetConf(t *testing.T) { fmt.Println("Running: TestGetConf") utils.Init(os.Stdout, os.Stdout, os.Stderr) conf, _ := GetConf("./test/test.yml") ass...
package testutil // ClientConfiguration specifies the username, password, and SSL setting // for test cases. type ClientConfiguration struct { SSL bool Username string Password string }
package main import ( "flag" "log" ) const ( AppName = "coll_server" AppVersion = "0.1" ) // Cmd line flags var cfgFileName = flag.String("c", "", "Config file name to read.") var connectionLimit = flag.Int("l", 0, "Connection limit (0 = unlimited).") func main() { flag.Parse() // config cfg, err := Load...
package lightstep import ( "encoding/json" "fmt" "reflect" "strings" "testing" "time" google_protobuf "github.com/golang/protobuf/ptypes/timestamp" "github.com/lightstep/lightstep-tracer-go/basictracer" cpb "github.com/lightstep/lightstep-tracer-go/collectorpb" "github.com/lightstep/lightstep-tracer-go/thri...
package db import ( "fmt" "log" "github.com/spf13/viper" ) //DBconfig :nodoc: type DBconfig struct { Host string Port string User string DbName string Password string } //ViperConfigVariable read by key viper func ViperConfigVariable(key string) string { viper.SetConfigName(".env") viper.Ad...
package api import ( "net/http" "github.com/kevguy/My-Shitty-Music-Backend/util" ) // GetSongsPlaysEndPoint retrieves the number of plays for every song (from Redis) func GetSongsPlaysEndPoint(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() vals, err := shittyMusicRedisDao.GetPlays() if err != ni...
package composite import "fmt" type Product struct { Name string Price int64 NumOfItem int64 } func (p Product) GetPrice() (totalPrice int64) { fmt.Printf("Item Name: %s\n", p.Name) fmt.Printf("Price: %d\n", p.Price) fmt.Printf("Qty: %d\n", p.NumOfItem) fmt.Println() totalPrice = p.Price * p.NumOfI...
// Copyright (C) 2019-2020 Zilliz. 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 l...
package model import ( "time" ) type AutoID struct { ID uint `gorm:"primary_key;AUTO_INCREMENT" json:"id"` } type Timestamps struct { CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time `sql:"index"` }
// 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 main import ( "fmt" "net/http" "golang.org/x/net/html" ) type edge struct { Depth int Source string Target string } var maxDepth = 3 var visitedLinks = map[string]bool{} var linkMap = map[string]*[]edge{} func main() { performIteration("https://www.youtube.com/", 0) for key, val := range linkMap {...
package clock_test import ( "testing" "time" "github.com/shandysiswandi/echo-service/pkg/clock" "github.com/stretchr/testify/assert" ) func TestNow(t *testing.T) { n := clock.New().Now() assert.NotEqual(t, time.Now(), n) }
package apilifecycle import godd "github.com/pagongamedev/go-dd" // OnPostHandler Type type OnPostHandler = func(context *godd.Context, code int, responseRawIn interface{}, responsePagination *godd.ResponsePagination) (codeOut int, responseRawOut interface{}, responsePaginationOut *godd.ResponsePagination, goddErr *g...
package gorelicwrap import ( "log" "net/http" ) type AppMetaData struct { Applications []struct { ID int `json:"id"` Name string `json:"name"` } `json:"applications"` } type AppInstMetaData struct { ApplicationsInstances []struct { ID int `json:"id"` ApplicationName string `js...
package log import ( "fmt" "io" "sync" "github.com/corioders/gokit/constant" "github.com/logrusorgru/aurora" ) type Logger interface { Info(a ...interface{}) Error(a ...interface{}) Child(prefix string) Logger } type logger struct { output io.Writer outputMu sync.Mutex prefix string } var ( statusE...
package instanceprofile import ( "encoding/json" "fmt" "github.com/nenetto/databricks-sdk-go/client" "github.com/nenetto/databricks-sdk-go/models" ) type Endpoint struct { Client *client.Client } func (c *Endpoint) List() (*models.InstanceprofileListResponse, error) { resp := models.InstanceprofileListResponse...
package controllers import ( "log" "net/http" "path/filepath" ) func SpaHandler(entrypoint string) func(w http.ResponseWriter, r *http.Request) { fn := func(w http.ResponseWriter, r *http.Request) { // get the absolute path to prevent directory traversal path, err := filepath.Abs(r.URL.Path) if err != nil {...
package routes import ( "net/http" "html/template" "github.com/21stio/go-ideahub/routes/templates" "github.com/21stio/go-ideahub/queries" "github.com/21stio/go-ideahub/types" "net/url" "strings" log "github.com/sirupsen/logrus" ) type MeData struct { templates.BaseData Ideas []types.Idea Me type...
package util import ( "github.com/t00mas/pageparser/model" "golang.org/x/net/html" "io" ) func parseHref(tok html.Token) (href string) { for _, a := range tok.Attr { if a.Key == "href" { return a.Val } } return "" } func parseAnchor(tok html.Token) (href string){ isAnchor := tok.Data == "...
// SPDX-License-Identifier: MIT package lang import ( "fmt" "github.com/caixw/apidoc/v7/core" "github.com/caixw/apidoc/v7/internal/lexer" "github.com/caixw/apidoc/v7/internal/locale" ) // Parse 分析 data 的内容并输出到到 blocks func Parse(h *core.MessageHandler, langID string, data core.Block, blocks chan core.Block) { ...
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved. // This program and the accompanying materials are made available under the terms of the under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. // You may obtain a copy of the Licen...
package Metadata import ( "github.com/mkocikowski/libkafka/api" ) func NewRequest(topics []string) *api.Request { return &api.Request{ ApiKey: api.Metadata, ApiVersion: 5, Body: Request{ Topics: topics, AllowAutoTopicCreation: false, }, } } type Request struct { Topics ...
package informPanic func Deal(f func()) func(){ return func() { defer func() { if x := recover(); x!= nil{ // 通知xxx Inform() } }() f() } }
package main import ( "fmt" "net/http" "net/http/httptest" . "testing" ) func TestNumberDumper(t *T) { n := numberDumper(1) r, _ := http.NewRequest("GET", "/one", nil) w := httptest.NewRecorder() n.ServeHTTP(w, r) if w.Code != 200 { t.Fatalf("wrong code returned: %d", w.Code) } body := w.Body.String...
package appender import ( "bufio" "encoding/json" "fmt" "os" "sync" ) // e.g ConsoleAppenderConf //{ // "Type": "ConsoleAppender", // "ConsoleType": "STDOUT" //} type ConsoleType int const ( CONSOLE_STDOUT ConsoleType = 0 CONSOLE_STDERR = 1 ) // ConsoleAppenderConf type ConsoleAppenderConf struc...
package main import ( "math/rand" "time" "github.com/lib/pq" ) // Embed the pq-provided NullTime in our own version, so we can override the // MarshalJSON method to return clean type nullTime struct { pq.NullTime } func toNullTime(t time.Time) nullTime { return nullTime{ pq.NullTime{ Time: t, Valid: ...
// project euler (projecteuler.net) problem 10 // solution by Kevin Retzke (retzkek@gmail.com) // November 2012 package main import ( "./primes" "fmt" ) func sumPrimes(p *primes.Primes, max int) uint64 { sum := uint64(0) for i := 0; p.Primes[i] < max; i++ { sum += uint64(p.Primes[i]) } return sum } func main...
package find_all_anagrams_in_a_string func findAnagrams(s string, p string) []int { countP := make(map[uint8]int) for i := range p { countP[p[i]]++ } countS := make(map[uint8]int) for i := 0; i < len(s) && i < len(p)-1; i++ { countS[s[i]]++ } result := make([]int, 0) for i := len(p) - 1; i < len(s); i++...
package utils import ( "fmt" "testing" ) func TestGenMd5Key(t *testing.T) { got := GenMd5Key("3299005360117810") fmt.Println("!!!!!!!!!!!!!!", got) }
package middleware import ( "net/http" "github.com/winded/tyomaa/backend/db" "github.com/winded/tyomaa/backend/util" "github.com/winded/tyomaa/backend/util/context" "github.com/winded/tyomaa/shared/api" ) // Authentication middleware finds the User from the database // associated with the token claim, if it exi...
package api import ( "context" "encoding/json" "fmt" "github.com/gin-gonic/gin" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo/options" "io/ioutil" "jxc/auth" "jxc/models" "jxc/serializer" "jxc/util" "net/http" "time" ) //用户提交过来能数据 type EmplReq struct { IdMin int `form:"idmin"` //...
package view import ( caos_errs "github.com/caos/zitadel/internal/errors" global_model "github.com/caos/zitadel/internal/model" org_model "github.com/caos/zitadel/internal/org/model" "github.com/caos/zitadel/internal/org/repository/view/model" "github.com/caos/zitadel/internal/view/repository" "github.com/jinzhu...
package main import "fmt" func twoSum(nums []int, target int) []int { for i := 0; i < len(nums); i++ { for j := 0; j < len(nums); j++ { if nums[i]+nums[j] == target { return []int{i,j} } } } return []int{} } func main() { nums := []int{2, 5, 5, 11} target := 10 output := twoSum(nums, target) fmt...
package task import ( v1 "k8s.io/api/core/v1" "strings" ) func getContainerNameIpMapping(pod *v1.Pod)map[string]string{ cStats := map[string]string{} for _,containersSts := range pod.Status.ContainerStatuses{ containerId := strings.Split(containersSts.ContainerID, "//") if len(containerId) != 2 { cStats[co...
package management import ( "context" "github.com/golang/protobuf/ptypes/empty" "github.com/caos/zitadel/pkg/grpc/management" ) func (s *Server) GetProjectMemberRoles(ctx context.Context, _ *empty.Empty) (*management.ProjectMemberRoles, error) { return &management.ProjectMemberRoles{Roles: s.project.GetProjectM...
package util import ( "crypto/md5" "crypto/rand" "encoding/base64" "encoding/json" "fmt" "github.com/upyun/go-sdk/upyun" "math/big" "os" "strconv" "strings" "time" ) // URL = weqijxc.test.upcdn.net // 又拍云异步上传步骤 // signature 和 policy 算法 // signature // 1 .将所需的元信息键值对按照键的字典顺序排列,并连接成为字符串 // 2 将第 1 步中所得字符串与您的...
package daemon import ( . "ftnox.com/common" . "ftnox.com/config" bitcoin "ftnox.com/bitcoin/types" "ftnox.com/treasury" "ftnox.com/exchange" ) // Cache of unconfirmed transaction hashes // TODO: set expiry on items, or use redis. var unconfirmedTxHashes = NewCMap() func init() { Info("DAEMON...
package raws // import "github.com/BenLubar/dfide/raws" import ( "bufio" "io" "strings" ) type Reader struct { r *bufio.Reader name string object string unreadTag []string err error } func NewReader(r io.Reader) *Reader { return &Reader{r: bufio.NewReader(r)} } func (r *Reader) init()...
package main import ( "fmt" "testing" ) // func Compare(t *testing.T, expected RequestResponsePairViewV1, actual RequestResponsePairViewV1) { ar := actual.Response er := expected.Response var ok = true if ar.Body != er.Body { ok = false t.Logf("expected Response.Body (%v) doesn't match actual Response.Body:...
package r import ( "fmt" "github.com/gomodule/redigo/redis" "time" ) type RedisConfig struct { Host string Port string Password string Db int } type R struct { redisPool *redis.Pool client redis.Conn } var r = new(R) func (redisConfig *RedisConfig) Dial() error { address := fmt.Sprintf("...
package logger import ( "log" "os" ) const ( // Color WHITE = "\033[37m" GREEN = "\033[92m" RED = "\033[91m" YELLOW = "\033[33m" HIGHLIGHT_YELLOW = "\033[93m" BLUE = "\033[94m" HIGHLIGHT_WHITE = "\033[97m" ENDC = "\033[0m" // Type STAT...
package nopaste import ( "errors" "io/ioutil" "log" "path" goconfig "github.com/kayac/go-config" "gopkg.in/yaml.v2" ) type Config struct { BaseURL string `yaml:"base_url"` Listen string `yaml:"listen"` DataDir string `yaml:"data_dir"` S3 *S3Config `yaml:"s3"` IRC *IRCCo...
package gomodmultiplies //Multiply funct func Multiply(items1 int, items2 int) int { return items1 * items2 } //Add funct func Add(items1 int, items2 int) int { return items1 + items2 }
package thirdpay import ( "crypto" "crypto/rsa" "crypto/sha1" "crypto/x509" "encoding/base64" "encoding/pem" "fmt" "github.com/astaxie/beego" "io" "net/url" "sort" "webserver/controllers" "webserver/models" "webserver/models/maccount" ) const ( //支付宝公钥 ALIPAY_PUBLIC_KEY = `-----BEGIN PUBLIC KEY----- ...
package main import ( "io" "log" "time" "github.com/davecgh/go-spew/spew" ) type Block struct { Timestamp string BPM int PrevHash string Hash string Nonce string } func NewBlock(w io.Writer, oldBlockHash string, bpm int) *Block { newBlock := &Block{ Timestamp: time.Now().String(), BPM:...
// date: 2019-03-15 package quote import "net/http" type Server struct { ServerN } func (s *Server) Listen() { http.Handle("/", s.newServerHandler()) http.ListenAndServe(":12345", nil) } func New(s ServerN) *Server { return &Server{s} }
/* 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 configuration import ( "testing" "github.com/barchart/common-go/pkg/configuration/database" "github.com/stretchr/testify/assert" ) func TestSetStage(t *testing.T) { expectedStage := "dev" SetStage("dev") stage := GetStage() assert.Equal(t, expectedStage, stage, "stage should be set correctly") } f...
package scan import ( "database/sql" "fmt" "reflect" "github.com/jmoiron/sqlx/reflectx" ) var ( mapper = reflectx.NewMapper("db") namedArgType = reflect.TypeOf(sql.NamedArg{}) ) // IsNil returns true if the value is nil func IsNil(src interface{}) bool { if src == nil { return true } value := refl...
// Copyright 2014 Wandoujia Inc. All Rights Reserved. // Licensed under the MIT (MIT-LICENSE.txt) license. package cmd import ( "bufio" "io/ioutil" "log" "sync" "time" ) import ( "github.com/wandoulabs/codis/ext/redis-port/utils" ) func Sync(ncpu int, from, target string) { log.Printf("[ncpu=%d] sync from '%...
package utils import ( "fmt" "io" "io/ioutil" "os" "path/filepath" "regexp" wio "wio/cmd/wio/utils/io" "wio/cmd/wio/errors" "strings" ) // Checks if path exists and returns true and false based on that func PathExists(path string) bool { if _, err := os.Stat(path); err != nil ...
package influxdb_test import ( "fmt" "net/url" "testing" "github.com/influxdb/influxdb" ) func newDataNodes() []*influxdb.DataNode { nodes := []*influxdb.DataNode{} for i := 1; i <= 2; i++ { u, _ := url.Parse(fmt.Sprintf("http://localhost:999%d", i)) nodes = append(nodes, &influxdb.DataNode{ID: uint64(i), ...
package view import ( caos_errs "github.com/caos/zitadel/internal/errors" "github.com/caos/zitadel/internal/view/repository" "github.com/jinzhu/gorm" global_model "github.com/caos/zitadel/internal/model" usr_model "github.com/caos/zitadel/internal/user/model" "github.com/caos/zitadel/internal/user/repository/vi...
package daemon import ( "syscall" "k8s.io/klog/v2" "github.com/Wifx/gonetworkmanager" "github.com/vishvananda/netlink" ) var routeScopeOrders = [...]netlink.Scope{ netlink.SCOPE_HOST, netlink.SCOPE_LINK, netlink.SCOPE_SITE, netlink.SCOPE_UNIVERSE, } func nmSetManaged(device string, managed bool) error { n...
package global import ( "context" "strconv" "strings" "github.com/go-redis/redis/v8" "shared/utility/errors" "shared/utility/key" ) const keyIntimacy = "Intimacy:guild" type Intimacy struct { *redis.Client } func NewIntimacy(client *redis.Client) *Intimacy { return &Intimacy{ Client: client, } } func ...
package main import ( "context" "fmt" "time" "github.com/micro/go-micro/v2" "github.com/micro/go-micro/v2/util/log" "github.com/google/uuid" proto "go-micro-demos/pubsub/demo1/proto" "github.com/micro/go-micro/v2/metadata" ) func sendMessage(ctx context.Context, topic string, p micro.P...
package messages import ( "bytes" //"io" ) func Encode(msg Message) []byte { return msg.Encode() } // // func EncodeList(msgs []Message) []byte { // } // // func Decode(b []byte) (Message, error) { // return ReadMessage(bytes.NewReader(b)) // } // func DecodeEach(b []byte, callback func(Message)) error { // ...
package test import ( "github.com/go-spring/spring-boot" "github.com/go-spring/spring-web" "github.com/jinzhu/gorm" ) // config func config() { SpringBoot.Config(func(db *gorm.DB) { db.SingularTable(true) db.LogMode(true) }) SpringWeb.Validator = SpringWeb.NewDefaultValidator() }
package typrls import ( "fmt" "os" "strings" "github.com/typical-go/typical-go/pkg/typgo" "github.com/urfave/cli/v2" ) type ( // ReleaseProject release command ReleaseProject struct { Before typgo.Action GenerateTagFn func(c *typgo.Context, alpha bool) string GenerateSummaryFn func(c *typ...
package main import ( "fmt" "net" "encoding/gob" "strconv" ) var puerto int var arregloG []string var msjs []string func MandarMensaje(s string, x string){ c, err := net.Dial("tcp", s) if err != nil { fmt.Println(err) return } err = gob.NewEncoder(c).Encode(x) if err != nil { fmt.Println(err) } } fu...
// 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" "path/filepath" "strconv" "time" "chromiumos/tast/common/media/caps" "chromiumos/tast/common/perf" "chromiumos/tast/ctxutil" "chromiu...
package main import ( "api1" "testing" ) func TestStruct(t *testing.T) { ft := api1.FixType(4) r := &api1.Location{12, 88, &ft} t.Log(r) } // ======================================================== // Create a simple implementation of APISample, and test a call // to a function that only accepts implementation...
package main import ( "flag" "fmt" "io/ioutil" "os" "os/exec" "path/filepath" "strings" "syscall" ) func main() { var rootfs string var hostname string var process string flag.StringVar(&rootfs, "f", "", "文件系统") flag.StringVar(&hostname, "h", "hello_world", "主机名称") flag.StringVar(&process, "p", "/bin/s...
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("documents", func() { Context("raw documents", func() { It("should parse empty document", func() { ...
package majiangserver import ( // gp "code.google.com/p/goprotobuf/proto" // "code.google.com/p/snappy-go/snappy" // "github.com/garyburd/redigo/redis" "logger" //"math/rand" "net" "proto" "rpc" "rpcplus" "runtime/debug" // "strconv" //"sync" // "time" //conn "centerclient" "common" ) type MaJiangServe...
package trace import ( "bytes" "fmt" "io" "math" "github.com/pgavlin/warp/wasm" "github.com/pgavlin/warp/wasm/code" ) func printValues(w io.Writer, values []uint64, types []wasm.ValueType) error { var b bytes.Buffer fmt.Fprint(&b, " [") if len(types) != len(values) { for i, v := range values { if i !=...
/* 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, software distributed under the License...
// Copyright 2019 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 (03_transactions) demonstrates how to enumerate all of an // accounts transactions. As with the second example, you need to set the // MONDO_ACCESS_TOKEN environment variable. package main import ( "encoding/json" "fmt" "github.com/icio/mondo" "github.com/icio/mondo/mondodomain" "github.com/icio/m...
// Copyright 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 to in...
package tests //gojay:json type MapStringInt map[string]int
package dist import ( "errors" "math" ) type ExponentialDistribution struct { DistributionType string } // Generate random numbers that fit the // exponential distribution // Parameters: a = Scale parameter and a > 0 // Inverse transformation func (d ExponentialDistribution) RandVar(a float64) (float64, error)...
/** 两个有序数组合并为一个有序数组 */ package array func mergeTwoOrder(arr1, arr2 []int, m, n int) []int { // m 是 arr1 的长度,n 是 arr2 的长度 var rs = make([]int, m+n) var k int // 指向 rs 的指针 var i, j int // i 指向 arr1,j 指向 arr2 for { if i >= m || j >= n { break } if arr1[i] < arr2[j] { rs[k] = arr1[i] i += 1 } el...
// 181. Errors with info // 02 +01 多加一個容器儲存 方便使用 // https://golang.org/pkg/errors/#example_New // https://golang.org/src/errors/errors.go // 查看錯誤的使用。標準庫中的新增功能: // http://golang.org/src/pkg/bufio/bufio.go // http://golang.org/src/pkg/io/io.go package main import ( "errors" "fmt" "log" ) var ErrNorgateMath = error...
/* Copyright 2019 Baidu, 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 to in writing, software dis...
/* 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 //1380. 矩阵中的幸运数 //给你一个 m * n 的矩阵,矩阵中的数字 各不相同 。请你按 任意 顺序返回矩阵中的所有幸运数。 // //幸运数是指矩阵中满足同时下列两个条件的元素: // //在同一行的所有元素中最小 //在同一列的所有元素中最大 // // //示例 1: // //输入:matrix = [[3,7,8],[9,11,13],[15,16,17]] //输出:[15] //解释:15 是唯一的幸运数,因为它是其所在行中的最小值,也是所在列中的最大值。 //示例 2: // //输入:matrix = [[1,10,4,2],[9,3,8,7],[15,16,17,12]] /...
package controllers import ( "encoding/json" "errors" "github.com/astaxie/beego" "base_service/models" "strconv" "strings" ) // CategoriesController operations for Categories type CategoriesController struct { baseController } // URLMapping ... func (c *CategoriesController) URLMapping() { beego.Debug("URLMa...
package scenes // SceneType enumerates the types of scenes type SceneType int // Scene enum values const ( TimerScene SceneType = iota SettingsScene )
/* * Copyright 2021 American Express * * 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...
package main import ( "crypto/rand" "fmt" "io/ioutil" "log" "net/http" "os" "time" "github.com/ThreeDotsLabs/watermill" "github.com/ThreeDotsLabs/watermill/message" "github.com/ThreeDotsLabs/watermill/message/infrastructure/nats" "github.com/nats-io/go-nats-streaming" "github.com/oklog/ulid" ) func main(...