text
stringlengths
11
4.05M
package main import ( "fmt" "time" ) func main() { //START, OMIT for _, v := range []int{1, 2, 3, 4, 5} { go func(i int) { // HLxx //can do anything else fmt.Println(i) }(v) // HLxx } //STOP, OMIT <-time.After(2 * time.Second) }
/* > 2018年4月10日 > 开始抽时间来完成GUI窗口化的szssp信息化设备管理工具 ## 程序流程修改: - 运行程序 - 自动开始获取设备相关信息并设置临时地址 - 由使用者选择硬盘序列号和网卡MAC地址,查询远程数据库中的信息 - 如果查询到信息就显示出来,如果没有信息就提示使用者提交相关信息 - 然后最终设置网络IP地址. */ package main import ( "fmt" "net" "os" "os/exec" "strings" "syscall" "github.com/sciter-sdk/go-sciter" "github.com/sciter-sdk/go-sciter...
package web import ( "github.com/vlad-doru/microhiro/gateway/web/loggers" "fmt" "github.com/Sirupsen/logrus" "github.com/julienschmidt/httprouter" "math/rand" "net" "net/http" "net/url" "sync" "time" ) func init() { rand.Seed(time.Now().Unix()) } type logFn func() // Request encapsulates more data about...
package webservice import ( "net/http" "github.com/gin-gonic/gin" "github.com/rjjatson/bot-kuraifu-chan/internal/webhook/line" ) // SetupRoute add routes to gin router func SetupRoute(basePath string, lineClient *line.Client, router *gin.Engine) { router.GET(basePath+"/ping", func(c *gin.Context) { c.Writer...
package main import ( "bufio" "bytes" "fmt" "io/ioutil" "log" "net/http" "os" "strings" ) func main() { MakeRequest() } func MakeRequest() { reader := bufio.NewReader(os.Stdin) fmt.Println("Enter address you want to connect to") fmt.Println("Example: http://127.0.0.1:8080") Addr, _ := reader.ReadString(...
package configs import ( "os" "github.com/joho/godotenv" ) type Config struct{} func (c *Config) Get(key string) string { err := godotenv.Load(".env") if err != nil { panic(err) } return os.Getenv(key) }
// Copyright (c) 2018/2019 The DevCo developers // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. package xzc import ( "errors" "fmt" rpc "github.com/zcoinofficial/xzcd/rpcclient" "github.com/zcoinofficial/xzcd/txscript" "github.com/zcoinofficial/xzcd/wire" "git...
package openrtb_ext type ExtImpAdView struct { MasterTagID string `json:"placementId"` AccountID string `json:"accountId"` }
// 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 assistant import ( "context" "time" "chromiumos/tast/local/assistant" "chromiumos/tast/local/chrome/uiauto/browser" "chromiumos/tast/local/chrome/uiauto/launch...
// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php package util import ( "encoding/json" "errors" "io/ioutil" "math/big" "sort" "github.com/MatrixAINetwork/go-matrix/core/matrixstate" ...
package main import ( "fmt" "tempconv" ) func main() { fmt.Println(tempconv.CToF(tempconv.BoilingC)) fmt.Println(tempconv.CToK(tempconv.AbsoluteZeroC)) fmt.Println(tempconv.KToF(tempconv.AbsoluteZeroK)) }
// description : Wordcounter // author : Tom Geudens (https://github.com/tomgeudens/) // modified : 2016/07/17 // package main import ( "bufio" "bytes" "fmt" "strconv" ) type WordCounter int // fullfills io.Writer interface contract func (counter *WordCounter) Write(p []byte) (int, error) { var words in...
package main import ( "bufio" "fmt" "log" "os" ) func dec2bin(a uint) string { return fmt.Sprintf("%b", a) } func main() { var a uint data, err := os.Open(os.Args[1]) if err != nil { log.Fatal(err) } defer data.Close() scanner := bufio.NewScanner(data) for scanner.Scan() { if len(scanner.Text()) > 0 ...
package service import ( "bytes" "context" "github.com/hyperjumptech/grule-rule-engine/ast" "github.com/hyperjumptech/grule-rule-engine/builder" engine2 "github.com/hyperjumptech/grule-rule-engine/engine" "github.com/hyperjumptech/grule-rule-engine/pkg" "github.com/kennykarnama/checkout-challenge/cart/entity" ...
package shared import ( "os" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/apigatewaymanagementapi" ) func SendWSMessage(connID, apiID string, data []byte) error { sess, err := session.NewSession(&aws.Config{Region: aws.String(os.Getenv("AWS_REGION"))...
package common import ( "bufio" "fmt" "io" "math" "os" "strings" ) // Graph manage Nodes type Graph struct { Nodes []*Node // vertex from 0~vertexSize vertexSize uint64 } // NewGraph return a empty graph with vertexSize vertex func NewGraph(vertexSize uint64) *Graph { g := Graph{ Nodes: make([]*Node...
package dmsg import ( "context" "net" "testing" "time" "github.com/skycoin/skycoin/src/util/logging" "github.com/stretchr/testify/assert" "github.com/skycoin/dmsg/cipher" ) const ( chanReadThreshold = time.Second * 5 ) type transportWithError struct { tr *Transport err error } func TestClient(t *testin...
package httpmock_test import ( "bytes" "context" "encoding/json" "errors" "net" "net/http" "net/url" "reflect" "regexp" "strings" "testing" "time" . "github.com/jarcoal/httpmock" "github.com/jarcoal/httpmock/internal" ) const testURL = "http://www.example.com/" func TestMockTransport(t *testing.T) { ...
package main import ( "math/big" ) func main() { z := new(big.Int) x := new(big.Int) x = x.SetUint64(2) y := new(big.Int) y = y.SetUint64(4) m := new(big.Int) m = m.SetUint64(0) z = z.Exp(x, y, m) }
// 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 main import ( "log" ) // Object is a func type Object func(int) int // LogDecorator is a decorator func LogDecorator(fn Object) Object { return func(a int) int { log.Println("Start") result := fn(a) log.Println("End") return result } } // Double will calculate double of an integer func Double(n i...
// Copyright (c) 2014-2018 Salsita Software // Copyright (c) 2015 Scott Devoid // Use of this source code is governed by the MIT License. // The license can be found in the LICENSE file. package pivotal import ( "fmt" "net/http" "time" ) // ProjectMembership is the primary data object for the MembershipService. t...
package images import ( "fmt" "github.com/768bit/promethium/lib/cloudconfig" "github.com/768bit/vutils" "io/ioutil" "os" "path/filepath" ) //capstan was managin images before.. we will continue to use capstan for managing these images but we create isntances of these images as required... //these utils a...
package cmd import ( "github.com/spf13/cobra" "fmt" "net/http" "github.com/HotelsDotCom/flyte/flytepath" "io" "os" httputl "net/http/httputil" "github.com/spf13/viper" "bytes" "mime/multipart" "net/textproto" "strings" "path/filepath" ) type dsItem struct { name string description string conten...
// 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...
/* 协议: 用户可以执行命令, 以 %<command> args... 的形式 如: %ls // 查看server中的文件 %exit // 推出客户端 %set-name 姬小野 // 设置用户名 %download 十万个为什么.pdf // 下载文件 %upload test.go // 上传文件 可以直接输入消息, 也就是除合法命令格式以外的消息, 都作为发送到chatroom的消息来发送 由于tcp传输字节流, 因此在发送每个消息之前, 用一个 4字节 的数...
package controllers import ( "encoding/json" "errors" "io/ioutil" "net/http" "strconv" "github.com/gorilla/mux" "github.com/jameslahm/bloggy_backend/api/responses" "github.com/jameslahm/bloggy_backend/models" ) func (server *Server) CreatePost(w http.ResponseWriter, r *http.Request) { authId := r.Context()....
package resources import ( "fmt" "io/ioutil" "log" ) type Resource struct { Name string File []byte } func Fetch(filename string, ext string) (*Resource, error) { file := fmt.Sprintf("app/resources/%s/%s.%s", ext, filename, ext) resource, err := ioutil.ReadFile(file) if err != nil { log.Printf("Couldn't ga...
package fritz import ( "crypto/tls" "crypto/x509" "net/http" "net/url" "github.com/bpicode/fritzctl/config" "github.com/bpicode/fritzctl/logger" ) // HomeAuto is a client for the Home Automation HTTP Interface, // see https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AHA-HTTP-Interface.pdf. ty...
package chapstream import ( "net/http" "path" "strconv" "strings" "text/template" ) func (cs *chapStream) homeHandler(w http.ResponseWriter, r *http.Request) { if r.Method != "GET" { cs.Log.Error("[", r.Method, "] Method not allowed: ", r.URL) http.Error(w, "Method not allowed", 405) return } p := path...
package main import ( "fmt" //"strings" // "container/list" ) type heap struct { back []int } func new(s int) *heap { z := make([]int,s) z = z[0:0] return &heap{z} } func (h *heap) insert(i int){ free := len(h.back) h.back = h.back[0 :free+1] h.back[free] = i h.upHeap(free) } func ...
// Licensed to Elasticsearch B.V. under one or more contributor // license agreements. See the NOTICE file distributed with // this work for additional information regarding copyright // ownership. Elasticsearch B.V. licenses this file to you under // the Apache License, Version 2.0 (the "License"); you may // not use ...
package main import fmt "fmt" func main() { fmt.Println() fmt.Println(" The tree looks like this") fmt.Println(" 3") fmt.Println(" A-----B") fmt.Println(" 2\\ |") fmt.Println(" \\ |") fmt.Println(" C | 4") fmt.Println(" / \\ |") fmt.Println(" 1/ 3\\|") fmt.Println(" E-----...
// 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 main import ( "encoding/json" "fmt" "log" "net/http" "sessions-with-redis/session" "time" ) var ses session.Session type Credentials struct { Password string `json:"password"` Username string `json:"username"` } var users = map[string]string{ "user1": "password1", "user2": "password2", } func ma...
package util import ( "os" "os/signal" "syscall" ) func OnExit(cleanups ...func()) { go onExit(cleanups...) } func onExit(cleanups ...func()) { ch := make(chan os.Signal) signal.Notify(ch, os.Interrupt, syscall.SIGTERM) <-ch for _, cleanup := range cleanups { cleanup() } }
package number import ( "testing" ) // TestCalNumberBase 测试常规的加减乘除 func TestCalNumberBase(t *testing.T) { calNumber := NewCalNumber(0) calNumber.SetValue(100) // value = 100 if !calNumber.Equal(100) { t.Errorf("!calNumber.Equal(%d)", 100) } calNumber.Plus(100) // value = 100 + 100 if !calNumber.Equal(200) {...
// SPDX-FileCopyrightText: 2019 The Go Language Server Authors // SPDX-License-Identifier: BSD-3-Clause //go:build gojay // +build gojay package protocol import ( "github.com/francoispqt/gojay" ) // MarshalJSONObject implements gojay.MarshalerJSONObject. func (v *Position) MarshalJSONObject(enc *gojay.Encoder) { ...
package lantern_cache import ( "bytes" "testing" "time" ) func makeByte(size int) []byte { return make([]byte, size) } func TestBucketPutGet(t *testing.T) { b := newBucket(&bucketConfig{ 64 * 1024 * 2, 0, NewChunkAllocator("heap"), &Stats{}, }) h := newFowlerNollVoHasher() key1 := []byte("key1") val...
package db import ( "log" "time" pg "github.com/go-pg/pg" ) func saveProduct(dbRef *pg.DB){ newProduct := &ProductItem{ Name : "mango", Desc : "sweet fruit", Image : " file path of image ", Price : 23, Features : struct{Name string; Desc string; Imp int} { Name : "F1", Desc : "F1 description", ...
package main import ( "encoding/json" "fmt" "io/ioutil" "net/http" "os" "time" ) type config struct { Addr string `json:"addr"` } func main() { if len(os.Args) < 2 { fmt.Fprintf(os.Stderr, "No config file given\n") fmt.Fprintf(os.Stderr, "Usage: %s <path to config>\n", os.Args[0]) os.Exit(1) } confi...
package provider import ( "strings" "github.com/denverdino/aliyungo/ecs" ) const ( DevicePrefixLocal = "/dev/vd" DevicePrefixAPI = "/dev/xvd" ) // Status of disks type DiskStatus string const ( DiskStatusInUse = DiskStatus("In_use") DiskStatusAvailable = DiskStatus("Available") DiskStatusAttaching = D...
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may ...
package main import ( "flag" "fmt" ) type commandLineOptions struct { configFile string } func parseCommandLine(args []string) (*commandLineOptions, error) { fanFlags := flag.NewFlagSet("fan options", flag.ContinueOnError) cmd := commandLineOptions{} fanFlags.StringVar(&cmd.configFile, "config", "", "config fi...
package util import ( "io" "io/ioutil" "os" "path" "strings" "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) func TestUtils(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Utils Suite") } var _ = Describe("Utils", func() { // GetTempDir() Describe("Get Temp Directory", func() {...
// +build !sgx_enclave package adapters import ( "fmt" "github.com/smartcontractkit/chainlink/store" "github.com/smartcontractkit/chainlink/store/models" ) // Wasm represents a wasm binary encoded as base64 or wasm encoded as text (a lisp like language). type Wasm struct { WasmT string `json:"wasmt"` } // Perf...
/* Copyright 2017-2020 Gravitational, 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,...
package user import ( "context" "encoding/json" "net/url" "strings" kratosClient "github.com/ory/kratos-client-go/client" "github.com/ory/kratos-client-go/client/admin" "github.com/ory/kratos-client-go/models" "github.com/thoas/go-funk" ) type KratosClientV5 interface { GetUserByEmail(email string) (Kratos...
package db import ( "github.com/kapitanov/natandb/pkg/model" "github.com/kapitanov/natandb/pkg/storage" "sort" "strings" ) type transaction struct { Engine *engine ShouldCommit bool } func newTransaction(engine *engine) *transaction { tx := &transaction{ Engine: engine, ShouldCommit: false, }...
package main func main() { //r1 := newRect(1, 2, 3, 4, "zhangsan") //println(r1.area()) //println(r1.Base.name) //p := new(Human) //p.name = "123" //p.int = 12 //fmt.Println(*p) //var a [3]int //for _, v := range a { // fmt.Println(v) //} // //r := [...]int{2: 1} // //for _, v := range r { // fmt.Print...
package handler import ( "encoding/json" "errors" "net" "net/http" "strings" "code.cloudfoundry.org/lager" "github.com/rosenhouse/reflex/peer" ) type PeerList struct { Logger lager.Logger Peers peer.List } func (h *PeerList) ServeHTTP(w http.ResponseWriter, r *http.Request) { logger := h.Logger.Session(...
// Declare and initialize a variable of type int with the value of 20. Display // the _address of_ and _value of_ the variable. // // Declare and initialize a pointer variable of type int that points to the last // variable you just created. Display the _address of_ , _value of_ and the // _value that the pointer poin...
package node import ( "context" "fmt" "log" "math" "net" "net/rpc" "os" "os/signal" "strconv" "syscall" "time" "github.com/labstack/echo/v4" "github.com/xmliszt/e-safe/config" "github.com/xmliszt/e-safe/pkg/message" "github.com/xmliszt/e-safe/pkg/secret" "github.com/xmliszt/e-safe/util" ) // Node con...
// Copyright 2020 New Relic Corporation. All rights reserved. // SPDX-License-Identifier: Apache-2.0 package collect import ( "context" "github.com/newrelic/nri-vsphere/internal/config" "github.com/newrelic/nri-vsphere/internal/performance" "github.com/vmware/govmomi/vim25/mo" "github.com/vmware/govmomi/vim25/ty...
package main import ( context "context" "flag" "fmt" "io" "log" "net" "strconv" "sync" pb "github.com/qapquiz/cheirokmeta/examples/platformer/server/platformer" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) type platformerServ...
package ovs import ( "context" "fmt" "strconv" "strings" "github.com/kubeovn/kube-ovn/pkg/ovsdb/ovnnb" ) func (c *ovnClient) CreateNbGlobal(nbGlobal *ovnnb.NBGlobal) error { op, err := c.ovnNbClient.Create(nbGlobal) if err != nil { return fmt.Errorf("generate operations for creating nb global: %v", err) } ...
// package Handler is a collection of functions that handle requests (endpoints) package main import ( "encoding/json" "fmt" "net/http" ) // HandleRoot is the root handler func HandleRoot(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %s", r.URL.Path[1:]) } // HanldeHome is the home handler fun...
package main import ( "bufio" "fmt" "log" "os" ) func pow3(x int) int { y, ret := 3, 1 for x > 0 { if x&1 > 0 { ret *= y } y *= y x >>= 1 } return ret } func ugly(j int, n []int) bool { var ( k int s int64 c = int64(n[0]) cj = j p = true ) for k < len(n)-1 { ops := cj % 3 cj /...
package common import "sync" type ( Subscriber chan interface{} subscriberFunc func(v interface{}) bool ) // Broadcaster sends events to multiple subscribers. type Broadcaster struct { subs map[Subscriber]subscriberFunc m sync.RWMutex } func NewBroadcaster() *Broadcaster { return &Broadcaster{ subs: m...
package converters import ( "k8s.io/apimachinery/pkg/runtime" clusterv1 "sigs.k8s.io/cluster-api/pkg/apis/cluster/v1alpha1" "sigs.k8s.io/cluster-api-provider-nks/pkg/apis/nks/v1alpha1" "sigs.k8s.io/yaml" ) // ClusterConfigFromProviderSpec unmarshals a provider config into an NKS Cluster type func ClusterConfigFro...
// Copyright © 2021 Cisco Systems, Inc. and its affiliates. // 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 //...
package lib type Buckets struct { } func (slf Buckets) get(name string) { }
// 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 firmware import ( "context" "fmt" "regexp" "strings" "time" "github.com/golang/protobuf/ptypes/empty" "chromiumos/tast/common/servo" "chromiumos/tast/ctxut...
package network import ( "fmt" xctx "github.com/xuperchain/xupercore/kernel/common/xcontext" "testing" "github.com/xuperchain/xupercore/kernel/mock" nctx "github.com/xuperchain/xupercore/kernel/network/context" "github.com/xuperchain/xupercore/kernel/network/p2p" pb "github.com/xuperchain/xupercore/protos" ) ...
package informer import ( "WarpCloud/walm/pkg/k8s/converter" "WarpCloud/walm/pkg/k8s/utils" errorModel "WarpCloud/walm/pkg/models/error" "WarpCloud/walm/pkg/models/k8s" "WarpCloud/walm/pkg/models/release" "errors" tosv1beta1 "github.com/migration/pkg/apis/tos/v1beta1" migrationclientset "github.com/migration/p...
// Package main ... package main import ( "fmt" "net/http" "github.com/go-rod/rod" "github.com/go-rod/rod/lib/utils" ) func main() { go serve() browser := rod.New().MustConnect() defer browser.MustClose() // Creating a Page Object page := browser.MustPage() // Evaluates given script in every frame upon ...
package styles import ( "embed" "io/fs" "sort" "github.com/alecthomas/chroma/v2" ) //go:embed *.xml var embedded embed.FS // Registry of Styles. var Registry = func() map[string]*chroma.Style { registry := map[string]*chroma.Style{} // Register all embedded styles. files, err := fs.ReadDir(embedded, ".") if...
// Copyright (c) 2018 The MATRIX Authors // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php package matrixstate import ( "github.com/MatrixAINetwork/go-matrix/common" "github.com/MatrixAINetwork/go-matrix/core/types" "github.com/...
package ffmpeg //#include <libavutil/frame.h> import "C" import ( "errors" "fmt" "unsafe" ) type AudioFrame C.struct_Frame func NewAudioFrame(samples int, sampleFmt SampleFormat, channelLayout ChannelLayout) (*AudioFrame, error) { f := C.av_frame_alloc() f.nb_samples = C.int(samples) f.format = C.int(sampleFmt...
package main import ( "context" "fmt" "log" "github.com/segmentio/kafka-go" "github.com/segmentio/kafka-go/protocol" ) func main() { //PRODUCER: writer := &kafka.Writer{ Addr: kafka.TCP("localhost:19092"), Topic: "quickstart", } err := writer.WriteMessages(context.Background(), kafka.Message{ Value...
package kubeconfig import ( "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd/api" ) // Loader loads the kubeconfig type Loader interface { NewConfig() clientcmd.ClientConfig LoadConfig() clientcmd.ClientConfig LoadRawConfig() (*api.Config, error) GetCurrentContext() (string, error) SaveCon...
// 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 Licensc. // You may obtain a copy of the License at // // http://www.apachc.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed t...
package lua const ( TAB_1 = "\t" TAB_2 = "\t\t" TAB_10 = "\t\t\t\t\t\t\t\t\t\t" COMMENT = "--" AUTO_FILE_DESC = "-- auto generated, modification is not permitted." ) type result struct { file, content string }
package utils import ( "os" "strconv" ) func getHttpPort() int { env := os.Getenv("HTTP_PORT") if env == "" { return 3000 } value, e := strconv.Atoi(env) if e != nil { return 3000 } return value } var port = getHttpPort() func GetHttpPort() int { return port }
package apm import ( "context" "encoding/binary" "encoding/hex" "errors" "fmt" "math/rand" "strings" "sync" "time" "github.com/junhwong/goost/apm/field" ) // 符合 W3C 规范的 TraceID 或 SpanID. // https://www.w3.org/TR/trace-context/#trace-id type HexID []byte func (id HexID) Bytes() []byte { return id } func (i...
// 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 requests import ( "encoding/json" "fmt" "net/url" "strings" "github.com/google/go-querystring/query" "github.com/atomicjolt/canvasapi" ) // CreateErrorReport Create a new error report documenting an experienced problem // // Performs the same action as when a user uses the "help -> report a problem" /...
package assets import ( "regexp" "sort" "strings" ) // TODO: ignore data: , escaped quotes , spaces between brackets? var cssURLs = regexp.MustCompile(`url\(("[^"]*"|'[^']*'|[^)]*)\)`) var cssImports = regexp.MustCompile(`@import "(.*?)"`) func cssUrlsIndex(css string) [][]int { var idxs [][]int for _, match :...
package main import ( "encoding/json" "github.com/nolka/gooffroadmaster/mvc" "github.com/nolka/gooffroadmaster/mvc/controllers" "github.com/nolka/gooffroadmaster/util" "gopkg.in/telegram-bot-api.v4" "io/ioutil" "log" "os" "os/signal" ) func main() { util.EnsureDirectories() config := getConfig() bot, er...
// 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 func main() { // TODO imgUpload command }
package storage func AddBooking() { }
package main import ( "log" "net/http" "os" "github.com/lichuan0620/logtap/cmd/logtap/option" "github.com/lichuan0620/logtap/pkg/logtap" "github.com/lichuan0620/logtap/pkg/logtap/handler" ) func main() { logTap, err := logtap.NewLogTap(option.Spec, option.Name) if err != nil { os.Exit(1) } go serveHTTP(l...
// 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 main import "fmt" func main() { var stack []int stack = append(stack, 1) stack = append(stack, 2) fmt.Printf("stack: %v\n", stack) top := stack[len(stack)-1] fmt.Printf("Top is: %d\n", top) stack = remove(stack, 1) fmt.Printf("stack: %v\n", stack) stack = append(stack, 3, 4, 5, 6) fmt.Printf("st...
package chconn type ChErrorType int32 const ( ChErrorOk ChErrorType = 0 // OK ChErrorUnsupportedMethod ChErrorType = 1 // UNSUPPORTED_METHOD ChErrorUnsupportedParameter ChErrorType = 2 // UNSUPPORTED_PARAMETER Ch...
package popcount import "testing" var tests = []struct { num uint64 expected int }{ {28867, 7}, {55573, 8}, {10012002, 10}, } func TestPopCount(t *testing.T) { for _, test := range tests { if actual := PopCount(test.num); actual != test.expected { t.Errorf("expected %d but got %d", test.expected, actual) ...
package models import ( "errors" "github.com/jinzhu/gorm" "time" ) type Timeframe struct { ID uint64 `gorm:"primary_key;auto_increment" json:"id"` TaskID uint32 `gorm:"not null" json:"task_id"` FromTime time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"from"` ToTime time.Time `gorm:"default:CUR...
package server import ( "bytes" "io" "io/ioutil" "net/http" "net/http/httptest" "net/url" "testing" ) func TestCORSHandler(t *testing.T) { tests := []struct { given string givenPrefix string wantOrigin string wantCreds string wantHeaders string wantMethods string }{ { "", "", ...
package main import ( "fmt" "github.com/azak-azkaran/cascade/utils" "github.com/stretchr/testify/assert" "os" "strings" "testing" "time" ) func TestChangeMode(t *testing.T) { fmt.Println("Running: TestChangeMode") utils.Init(os.Stdout, os.Stdout, os.Stderr) assert.False(t, Config.OnlineCheck) Config.verbo...
package opsgenie import ( "testing" "time" ) var testargs = OpsArgs{"testKey", "testName", "testDescription", 99, "month", time.Second * 10, true} func TestCreateUrl(t *testing.T) { var requestParams = make(map[string]string) requestParams["apiKey"] = "test" url, err := createURL("/v1/test", requestParams) if ...
// 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 import ( "fmt" "time" ) type workItem struct { quantity int } func main() { workChannel := make(chan workItem) // Make a non buffered channel go worker(1, workChannel) go worker(2, workChannel) go worker(3, workChannel) var quantity int for { fmt.Println("Enter quantity, -1 to exit ") fmt...
package tree import ( "fmt" ) // Item ... type Item interface {} // Node ... type Node struct { Data Item Left *Node Right *Node Parent *Node Reserve1 Item Reserve2 Item Reserve3 Item } func preorderTraverseImpl(node *Node) { if node != nil { fmt.Printf("%v ", node.Data) preorderTraverseImpl(node.Left...
package samplepackage import ( "testing" "github.com/stretchr/testify/assert" ) func Test_bubbleSort(t *testing.T) { tests := []struct { name string array []int64 expectedArray []int64 }{ { name: "Elements are in random order", array: []int64{1, 8, 3, 4, 6, 5, 7, 2...
// Copyright 2020 Copyright (c) 2020 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...
// Copyright 2020 The VectorSQL Authors. // // Code is licensed under Apache License, Version 2.0. package dataformats import ( "datablocks" ) type IDataBlockInputFormat interface { ReadPrefix() error Read() (*datablocks.DataBlock, error) ReadSuffix() error } type IDataBlockOutputFormat interface { WritePrefix...
/* At the first Go / No Go poll, every Elf is Go until the Fuel Counter-Upper. They haven't determined the amount of fuel required yet. Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2. For exa...
package eventsourcing import ( "context" "testing" "github.com/caos/zitadel/internal/api/authz" "github.com/caos/zitadel/internal/crypto" caos_errs "github.com/caos/zitadel/internal/errors" "github.com/caos/zitadel/internal/eventstore/models" proj_model "github.com/caos/zitadel/internal/project/model" "github...
package k8sutil_test import ( "context" "fmt" "strconv" "testing" "github.com/golang/mock/gomock" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" "github.com/kinvolk/flatcar-linux-update-operator/pkg/k8s...