text
stringlengths
11
4.05M
// 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 todotxt import ( "fmt" "regexp" "sort" "strings" "time" ) var ( // DateLayout is used for formatting time.Time into todo.txt date format and vice-versa. DateLayout = "2006-01-02" priorityRx = regexp.MustCompile(`^(x|x \d{4}-\d{2}-\d{2}|)\s*\(([A-Z])\)\s+`) // Match priority: '(A) ...' or 'x (A) ...' ...
package biz import ( "github.com/go-telegram-bot-api/telegram-bot-api" ) const ( CallbackTypeRefresh = "Refresh" CallbackTypePassThrough = "PassThrough" ) var inlineKeyboard = tgbotapi.NewInlineKeyboardMarkup( []tgbotapi.InlineKeyboardButton{ tgbotapi.NewInlineKeyboardButtonData("刷新", CallbackTypeRefresh),...
package handler import ( "net/http" ) func Health(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) w.Write([]byte("{foo:bar}")) }
// 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 dbusutil import ( "context" "strings" "github.com/godbus/dbus/v5" "chromiumos/tast/errors" ) // SetProperty sets a DBus property on an object. The property na...
package gateway import ( "bufio" "encoding/binary" "github.com/gogo/protobuf/proto" "io" "log" "net" "zpush/gateway/cmd" msg "zpush/gateway/message" "zpush/utils" ) type Session struct { conn net.Conn userId int sessionID int reader *bufio.Reader outPacketCh chan []byte connCloseCh c...
package main var structUnmarshalTpl = templateList{ "def": &genTpl{ strTpl: "\n// UnmarshalJSONObject implements gojay's UnmarshalerJSONObject" + "\nfunc (v *{{.StructName}}) UnmarshalJSONObject(dec *gojay.Decoder, k string) error {\n", }, "nKeys": &genTpl{ strTpl: ` // NKeys returns the number of keys to un...
package models import( "encoding/json" ) /** * Type definition for DataDiskTypeEnum enum */ type DataDiskTypeEnum int /** * Value collection for DataDiskTypeEnum enum */ const ( DataDiskType_KPREMIUMSSD DataDiskTypeEnum = 1 + iota DataDiskType_KSTANDARDSSD DataDiskType_KSTANDARDH...
// 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 node import ( "fmt" "io" "io/ioutil" "net" "path" "strconv" "github.com/bramvdbogaerde/go-scp" "github.com/tinyzimmer/k3p/pkg/log" "github.com/tinyzimmer/k3p/pkg/types" "golang.org/x/crypto/ssh" ) // Connect will connect to a node over SSH with the given options. func Connect(opts *types.NodeConne...
package main import ( "bufio" "encoding/json" "flag" "fmt" "io" "io/ioutil" "log" "os" "strings" "syscall" "github.com/NHAS/StatsCollector/internal/theia" "github.com/NHAS/StatsCollector/models" "github.com/NHAS/StatsCollector/utils" "github.com/jinzhu/gorm" "golang.org/x/crypto/ssh/terminal" ) func m...
package main import "fmt" func main() { a := 5 p := &a fmt.Printf("p type=%T,p=%v,*p=%v,&p=%v\n", p, p, *p, &p) p2 := &p fmt.Printf("p2 type=%T,p2=%v,*p2=%v,&p2=%v\n", p2, p2, *p2, &p2) }
package handlers import ( "net/http" log "github.com/sirupsen/logrus" "github.com/el10savio/GoCrawler/GoSupervisor/spider" ) // Publish is the http handler for /spider/crawl to process // the given spider crawl request and publish the URL // to RabbitMQ for the GoCrawler nodes to process func Publish(w http.Resp...
package commands import ( "flag" "fmt" appConfig "k8s-pv-provisioner/cmd/provisioner/config" "k8s-pv-provisioner/cmd/provisioner/controllers" "k8s-pv-provisioner/cmd/provisioner/controllers/pv" "k8s-pv-provisioner/cmd/provisioner/controllers/pvc" "os" "strconv" "strings" "github.com/spf13/cobra" storage_v1...
// https://stackoverflow.com/questions/39147446/return-reference-to-struct-in-go-lang package main import ( "fmt" promotions "github.com/benhawker/checkout-go/promotions" products "github.com/benhawker/checkout-go/products" co "github.com/benhawker/checkout-go/checkout" pc "github.com/benhawker/checkout-go/...
// Copyright 2020 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" func bubbleSort(arr []int, size int) { for i := 0; i < size; i++ { for j := 0; j < size-i; j++ { if arr[j] > arr[j+1] { arr[j], arr[j+1] = arr[j+1], arr[j] } } } } func main() { nums := []int{8, 3, 2, 6, 3, 5, 1} fmt.Println(nums) bubbleSort(nums, len(nums)-1) fmt.Printl...
// Copyright 2019 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 models import ( "time" ) type ( CheckerLogModel struct { ID int `json:"id"` TopicName string `json:"topic_name"` QueueName string `json:"queue_name"` Message string `json:"message"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } )
package health import ( "testing" "github.com/jrapoport/gothic/test/tconf" "github.com/stretchr/testify/assert" ) func TestCheck(t *testing.T) { t.Parallel() c := tconf.Config(t) h := Check(c) assert.Equal(t, h.Name, c.Name) assert.Equal(t, h.Version, c.Version()) assert.NotEmpty(t, h.Status) }
package main import ( "bufio" "log" "os" "strings" ) func main() { s := [...]int{1,2,3,4,5,6,7,8,9,10} //ex. 4.3 reverse(&s) log.Println(s) //2018/09/24 11:20:07 [10 9 8 7 6 5 4 3 2 1] reverse(&s) log.Println(s) //2018/09/24 11:20:07 [1 2 3 4 5 6 7 8 9 10] //ex. 4.4 rotate(s[:], 2) log.Println(s) //20...
package main import ( "strconv" "syscall/js" ) type TokenType int const ( EQUAL TokenType = iota ADD SUB MUL DIV EXP NOP LPAREN RPAREN DECIMAL NUMBER ) type Token struct { Symbol string T TokenType } func matchToken(s string) (*Token, error) { switch s { case "=": return &Token{Symbol: s, T...
package unique_paths func uniquePaths(m int, n int) int { area := make([][]int, m) for i := range area { area[i] = make([]int, n) } for i := 0; i < m; i++ { for j := 0; j < n; j++ { if i == 0 || j == 0 { area[i][j] = 1 } else { area[i][j] = area[i-1][j] + area[i][j-1] } } } return area[...
package entity //Currency Валюта type Currency struct { Meta *Meta `json:"meta,omitempty"` // Метаданные Id string `json:"id,omitempty"` // ID валюты Name string `json:"name,omitempty"` // Наименование валюты FullName strin...
package model type PreRechargeParam struct { Money float64 `json:"money" form:"money"` Uniacid int `json:"uniacid" form:"uniacid"` Openid string `json:"openid" form:"openid"` } type PreRechargeResponse struct { Uniacid int `json:"uniacid"` Openid string `json:"openid"` Logno string `json:"logno"` ...
// 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 ( "data_collector/client" "data_collector/etherplorer_data" "data_collector/models" "data_collector/models/etherplorer" "data_collector/utils" "fmt" "github.com/astaxie/beego/logs" "github.com/gocarina/gocsv" "github.com/joho/godotenv" "net/http" "os" "sync" "time" ) func main() { ut...
package quark import ( "net/http" "net/url" "sort" "strconv" "strings" ) type Header http.Header func NewHeader() Header { return make(Header) } func NewHeaderWith(k, v string) Header { return NewHeader().Set(k, v) } func (h Header) Sets(hs ...Header) Header { for _, sh := range hs { for k, vals := range...
// +build windows package main import "github.com/fatih/color" // main.goのメソッドtrace.NewLoggerの引数として使われる。 var Writer = color.Output
package controller import ( "go-api/model" "net/http" "strconv" "github.com/labstack/echo/v4" ) //Home é a pagina inicial da minha aplicacao func Home(c echo.Context) error { return c.String(http.StatusOK, "Hello World!!") } func InserirUsuario(c echo.Context) error { nome := c.FormValue("nome") email := c.F...
package api import ( "database/sql" "elnewsAPI/loads" "encoding/json" "github.com/jackc/pgx" "log" "net/http" ) type SayingToday struct { ID int Title string Author sql.NullString Description sql.NullString ResetDatetime string `db:"reset_datetime" json:"reset_datetime"` OriginID int `db:"origin_id" json...
//To check for all identifiers package main var ahzddihif377943 int var _ float64 var _ int = 0 var _ int = 0 var int int var float64 float64 var rune rune var string string
// Unless explicitly stated otherwise all files in this repository are licensed // under the Apache License Version 2.0. // This product includes software developed at Datadog (https://www.datadoghq.com/). // Copyright 2016-2021 Datadog, Inc. package config import ( "errors" "os" "sync" "time" "github.com/DataD...
package adapter import ( "errors" "fmt" "github.com/dustin/go-humanize" "github.com/tidwall/gjson" "github.com/zcong1993/badge-service/cache" "github.com/zcong1993/badge-service/utils" "os" "time" ) // GITHUB_TOKEN is our github api token cause v4 need it var GITHUB_TOKEN = os.Getenv("GITHUB_TOKEN") // GITHU...
// Copyright 2020 Insolar Network Ltd. // All rights reserved. // This material is licensed under the Insolar License version 1.0, // available at https://github.com/insolar/block-explorer/blob/master/LICENSE.md. package controller import ( "github.com/prometheus/client_golang/prometheus" "github.com/insolar/block...
package repository import ( "github.com/porter-dev/porter/internal/models" ) // SessionRepository represents the set of queries on the Session model type SessionRepository interface { CreateSession(session *models.Session) (*models.Session, error) UpdateSession(session *models.Session) (*models.Session, error) De...
package main type Profile struct { Name string `json: name` Username string `json: username` Password string `json: password` Nick string `json: nick` }
// Package main Demo Web Server based on Gin // // This documentation describes a demo web server based on Gin APIs and code will be found under https://github.com/VeinFu/go-gin-ws // // Schemes: http // BasePath: // Version: 1.0.0 // License: MIT http://opensource.org/licenses/MIT // Contact: vien....
package main import ( "log" "net/http" "github.com/yashjjw/apiMeetings/main/models" "github.com/yashjjw/apiMeetings/main/routes" ) func main() { client := models.ConnectDatabase("mongodb://localhost:27017") router := routes.NewRouteHandler(client.Database("Test").Collection("meetings")) http.HandleFunc("/", ...
package main func isAnagram(s string, t string) bool { if len(s) != len(t) { return false } cnt := [26]int{} for _, c := range s { cnt[byte(c)-'a']++ } for _, c := range t { cnt[byte(c)-'a']-- } for i := 0; i < 26; i++ { if cnt[i] != 0 { return false } } return true } func main() { }
package rtime import ( "encoding/binary" "encoding/hex" "fmt" "io" "math" "math/rand" "time" "github.com/boltdb/bolt" "github.com/juju/errors" ) var ( boltdb *bolt.DB ErrNotFound = errors.New("not found") ) const ( TFormat = "2006-01-02T15:04:05.999999" ) func MustInitWriter(pth string) { var err...
package library import ( "fmt" "io" "net/http" "os" ) func handleUpload(w http.ResponseWriter, r *http.Request) (upload Upload, err error) { file, handler, err := r.FormFile("uploadfile") if err != nil { fmt.Println(err) return } defer file.Close() f, err := os.OpenFile("./fileUpload/"+handler.Filename...
package sexp import ( "github.com/bmizerany/assert" "testing" ) func TestBytes(t *testing.T) { assert.Equal(t, true, true) }
package uuid import ( "log" "strings" "github.com/google/uuid" ) func UUID4() string { out, err := uuid.NewRandom() if err != nil { log.Println(err) } return strings.ToLower(strings.Join(strings.Split(out.String(), "-"), "")) }
package handler_test import ( "encoding/json" "errors" "net/http" "net/url" "time" "github.com/Lunchr/luncher-api/db" "github.com/Lunchr/luncher-api/db/model" "github.com/Lunchr/luncher-api/geo" . "github.com/Lunchr/luncher-api/handler" "github.com/Lunchr/luncher-api/handler/mocks" "github.com/Lunchr/lunch...
package nano import ( "github.com/shibukawa/nanovgo" "github.com/waybeams/waybeams/pkg/helpers" ) const fakePixelRatio = float32(1.0) type Surface struct { context *nanovgo.Context flags []nanovgo.CreateFlags width float64 height float64 fonts map[string]*Font } func (s *Surface) Init() { context, er...
package console import ( "fmt" "github.com/jasosa/football_scoring_dashboard/pkg/dashboard" "sort" "strconv" "strings" ) //Adapter Adapter between a MatchDashboard and the console type Adapter struct { match dashboard.ScoringMatch Message chan string } //NewAdapter New creates a new instance of Adapter func...
package how_to_release_my_package import "fmt" //github.com/dengjiawen8955/how_to_release_my_package // Hi says Hi Here , my first package.. func Hi() { fmt.Printf("%s\n", "Hi Here , my first package.") }
package benchs import ( "database/sql" r "github.com/efectn/go-orm-benchmarks/benchs/reform" _ "github.com/jackc/pgx/v4/stdlib" "gopkg.in/reform.v1/dialects/postgresql" reformware "gopkg.in/reform.v1" ) var reform *reformware.DB func NewReformModel() *r.ReformModels { m := new(r.ReformModels) m.Name = "Orm ...
package e7 import ( "bytes" "encoding/json" "errors" ) // Attribute represents an Epic Seven hero's attribute. type Attribute int // Hero attribute. const ( None = -1 Fire Attribute = iota Ice Earth Light Dark ) var attributeStrings = map[Attribute]string{ None: "none", Fire: "fire", Ice: ...
package protocol import fuzz "github.com/jamieabc/gofuzz" const ( bitmarksCreateRPCMethod string = "Bitmarks.Create" ) type BitmarksCreateRpc struct { ID string `json:"id"` Method string `json:"method"` Params []BitmarksCreate `json:"params"` } type BitmarksCreate struct { Assets []Asse...
package config import ( "github.com/openshift/oc-mirror/pkg/api/v1alpha2" ) // Complete set default values in the ImageSetConfiguration // when applicable func Complete(cfg *v1alpha2.ImageSetConfiguration) { completeReleaseArchitectures(cfg) } func completeReleaseArchitectures(cfg *v1alpha2.ImageSetConfiguration) ...
package main import ( "encoding/json" "errors" "fmt" "net/http" ) type AdminService struct { Hub *Hub Repository UserRepository BanHistory BanHistoryRepository Publisher *Publisher } type BanParams struct { Email string `json:"email"` Reason string `json:"reason"` } type UnbanParams struct { Email...
package run import ( "../lib" "fmt" "io/ioutil" "os" ) func BinToGpp(binFolderPath string,gppFolderPath string,reBinFolderPath string,config *lib.ConfigInfo) error{ _, err := os.Stat(gppFolderPath) if err != nil { err:=os.MkdirAll(gppFolderPath,os.ModePerm) if err!=nil{ return err } } for i:=1;;i+=co...
package main import ( "fmt" "strings" ) // if we've gotten here, we already know that the strings are the same length func similarChars(s1 string, s2 string) string { var simChars strings.Builder for i := 0; i < len(s1); i++ { if s1[i] == s2[i] { fmt.Fprint(&simChars, string(s1[i])) } } return simChars.S...
package faq import "time" type Faq struct { ID int `json:"id" pg:",pk"` Title string `json:"title"` Author string `json:"author"` LastEdit string `json:"last_edit"` Content string `json:"content"` Tag string `json:"tag"` Color string `json:"color"` CreatedAt ...
package routes import ( "net/http" "github.com/21stio/go-ideahub/routes/templates" "github.com/21stio/go-ideahub/queries" "github.com/gorilla/mux" "github.com/21stio/go-ideahub/types" "strconv" "strings" sess "github.com/21stio/go-ideahub/session" "github.com/gorilla/sessions" log "github.com/sirupsen/logrus...
package gofastcgi import ( "time" ) type TimeIt struct { start int64; } func (t *TimeIt) Start() { t.start = time.Nanoseconds(); } func (t *TimeIt) End() int64{ return time.Nanoseconds() - t.start; }
package main import ( "github.com/astaxie/beego/orm" _ "github.com/go-sql-driver/mysql" "fmt" ) type User struct { Id int `orm:"auto"` Name string `orm:"size(100)"` } func t1() { orm.RegisterModel(new(User)) orm.RegisterDataBase("default", "mysql", "root:123@tcp(ali:3306)/gorm_test?charset=utf8", 30) // cr...
package metadata import ( "context" "database/sql" "strconv" "time" dynatracev1beta1 "github.com/Dynatrace/dynatrace-operator/src/api/v1beta1" "github.com/mattn/go-sqlite3" "github.com/pkg/errors" ) var ( dynakubesAlterStatementMaxFailedMountAttempts = ` ALTER TABLE dynakubes ADD COLUMN MaxFailedMountAttem...
package post import ( "context" "database/sql" "hackerRank-Golang-test/models" pRepo "hackerRank-Golang-test/repository" ) // NewSQLPostRepo retunrs implement of post repository interface func NewSQLPostRepo(Conn *sql.DB) pRepo.PostRepo { return &mysqlPostRepo{ Conn: Conn, } } type mysqlPostRepo struct { C...
package types import ( "RBStask/app/models/entity" "RBStask/app/models/mappers" "database/sql" "fmt" ) type TypeProvider struct { db *sql.DB types *mappers.TypeMapper } func (p *TypeProvider) Init() error { db, err := sql.Open("postgres", "host=localhost port=5432 user=postgres password=1...
package config // Status status JSON struct type Status struct { Current string `json:"current"` Queue []int `json:"queue"` Recent []int `json:"recent"` } // Config config JSON strust type Config struct { ApiId string `json:"api_id"` ApiHash string `json:"api_hash"` BotToken string `json:"b...
package timerscene import ( "fmt" "strings" "time" "github.com/coreyog/rubikstimer/config" "github.com/coreyog/rubikstimer/scenes" "github.com/coreyog/rubikstimer/util" "github.com/faiface/pixel" "github.com/faiface/pixel/imdraw" "github.com/faiface/pixel/pixelgl" "github.com/faiface/pixel/text" "golang.o...
package server // versi baru untuk iso server import ( "bufio" "errors" "fmt" "io" "log" "net" "strconv" "github.com/iyusa/shared/iso" ) // ExecuteHandler interface type ExecuteHandler interface { Execute(msg *iso.Message) error } // IsoServer server handler type IsoServer struct { Handler ExecuteHandler...
package usecase_test import ( "context" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/sesha04/test_kumparan/article/usecase" "github.com/sesha04/test_kumparan/domain" "github.com/sesha04/test_kumparan/mocks" ) func TestCreate(t *testing.T) { mockArticleRepo :=...
// Copyright 2022 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 agree...
package buyer53 import ( "encoding/json" "io/ioutil" "testing" ) func TestBidRequest_Other(t *testing.T) { fileNames := []string{ "./testdata/bid_request_banner.json", "./testdata/bid_request_video.json", "./testdata/bid_request_inapp.json", "./testdata/bid_request_private_deal.json", "./testdata/bid_re...
package main import "fmt" func subsets(nums []int) [][]int { ans := [][]int{} for i := int(1<<uint(len(nums))) - 1; i >= 0; i = i - 1 { res := []int{} for j := 0; j < len(nums); j = j + 1 { if i&(1<<uint(j)) != 0 { res = append(res, nums[j]) } } ans = append(ans, res) } return ans } func main()...
package user import( "time" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" "github.com/YanshuoH/douban-reading-stat/models" ) func Get(userId string, con *mgo.Database) (*models.User, error) { user := &models.User{} // Try to get user by id err := con.C(models.CollectionUser).Find(bson.M{"userId": userId})...
package main import ( "testing" "k8s.io/client-go/kubernetes/fake" ) func TestGetConfigMaps(t *testing.T) { client := fake.NewSimpleClientset() names, err := getConfigMaps(client.CoreV1(), "default") expected := 0 if err != nil { t.Errorf("Unexpected error: %s", err) } if len(names) != expected { t.Err...
package redis type Options struct { Host string Port int User string Pass string } type Option func (opts *Options) func WithHost (host string) Option { return func (opts *Options) { opts.Host = host } } func WithPort (port int) Option { return func (opts *Options) { opts.Port = por...
package exec import ( "fmt" "github.com/mitchellh/mapstructure" "github.com/pkg/errors" "github.com/spf13/cobra" "os" "path" cfg "github.com/cloudposse/atmos/pkg/config" "github.com/cloudposse/atmos/pkg/schema" u "github.com/cloudposse/atmos/pkg/utils" ) // ExecuteValidateComponentCmd executes `validate com...
package main import ( "bufio" "fmt" "math" "os" "strconv" ) func requiredFuel(mass float64) float64 { return math.Max(math.Floor(mass/3)-2, 0) } func main() { var total, totalWithFuelForFuel float64 scanner := bufio.NewScanner(os.Stdin) scanner.Split(bufio.ScanLines) for scanner.Scan() { mass, _ := strco...
// 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...
/* * Copyright 2020 The Dragonfly 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 la...
package models type InventoryItem struct { ID int `json:"ID"` Category string `json:"Category"` Product string `json:"Product"` Quantity int `json:"Quantity"` } type Inventory struct { ID int `gorm:"column:ID;primary_key"` Category string `gorm:"column:Category"` Product string `gorm:"co...
package main import ( "fmt" "time" ) func After(i int,ch chan bool){ now:=time.Now().Second() if 60-time.Now().Second()>i{ for { if time.Now().Second()-now==i{ break } } }else{for{ if time.Now().Second()==now+i-60{ break } } } ch<-true } func MySleep(i int){ ch1:=make(chan bool) go After...
// Copyright 2019 The ChromiumOS Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. package dbusutil import ( "context" "github.com/godbus/dbus/v5" ) // DBusObject wraps a D-Bus interface, object and connection. type DBusObject struct { iface string o...
package conn_pool // type ETCDConnPool map[string]
package scheduler import ( "errors" "fmt" ) const ( RUNNING_STATUS_UNPREPARED int8 = iota RUNNING_STATUS_PREPARING RUNNING_STATUS_PREPARED RUNNING_STATUS_STARTING RUNNING_STATUS_STARTED RUNNING_STATUS_PAUSING RUNNING_STATUS_PAUSED RUNNING_STATUS_STOPPING RUNNING_STATUS_STOPPED RUNNING_STATUS_UNPREPARED_D...
/* Copyright © 2021 Author : mehtaarn000 Email : arnavm834@gmail.com */ // This module is used for small utility functions // Not core functions such as `hashobject` package utils import ( "sort" "fmt" "os" ) func Find(a []string, x string) int { for i, n := range a { if x == n { return i } } return le...
package api import ( "log" "math" "net/http" "sort" "time" "github.com/TwiN/gatus/v5/storage/store" "github.com/TwiN/gatus/v5/storage/store/common" "github.com/gofiber/fiber/v2" "github.com/wcharczuk/go-chart/v2" "github.com/wcharczuk/go-chart/v2/drawing" ) const timeFormat = "3:04PM" var ( gridStyle = c...
package main import ( "bytes" "encoding/json" "testing" ) var mapInstance = func() map[string]interface{} { v := make(map[string]interface{}) if err := json.Unmarshal(exapmePayloadB, &v); err != nil { panic(err) } return v }() func BenchmarkDeserializeStruct(b *testing.B) { reader := bytes.NewBuffer(exapme...
package __SimpleType func Reverse(slice []_SimpleType) (res []_SimpleType) { res = make([]_SimpleType, len(slice)) for index, entry := range slice { res[len(slice)-1-index] = entry } return } func (c *chain) Reverse() *chain { return &chain{value: Reverse(c.value)} }
package dataloader import ( "bytes" "text/template" "github.com/pkg/errors" "github.com/EGT-Ukraine/go2gql/generator/plugins/graphql" ) type fieldsRenderer struct { dataLoader *DataLoader } func (r *fieldsRenderer) RenderFields(o graphql.OutputObject, ctx graphql.BodyContext) (string, error) { templateFuncs ...
package miner import ( "btcnetwork/common" "sync" ) var wg sync.WaitGroup func Start(cfg *common.Config) { log.Info("start miner service") minerConfig = InitConfig(cfg) minerStop = make(chan bool, 1) wg.Add(1) go mineMonitor(&wg) } func Stop() { log.Info("stop miner service") common.MinerCmd <- common.StopM...
package util import ( "k8s.io/api/admission/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "multidim-pod-autoscaler/pkg/util/patch" ) // Handler 描述了对 admission server 中资源的操作 type Handler interface { // GroupResource 返回 Handler 可处理的 Group 和 Resource GroupResource() metav1.GroupResource // AdmissionResour...
package main import ( "flag" "net" "github.com/jinzhu/gorm" "github.com/sirupsen/logrus" "fmt" "net/http" "time" "database/sql" "github.com/infobloxopen/atlas-app-toolkit/gateway" "github.com/infobloxopen/atlas-app-toolkit/health" "github.com/infobloxopen/atlas-app-toolkit/server" "github.com/infobloxo...
package main import "fmt" func main() { fmt.Println("hello") _ = 99 _ = 78 _ = 7999 _ = 8999000 _ = 9 }
/* Copyright 2019 Adobe All Rights Reserved. NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms of the Adobe license agreement accompanying it. If you have received this file from a source other than Adobe, then your use, modification, or distribution of it requires the pri...
package db import ( "database/sql" mydb "filestore-server/db/mysql" "fmt" ) func OnFileUploadFinished(filehash string, filename string, filesize int64, fileaddr string) bool { stmt, err := mydb.DBConn().Prepare( "insert ignore into tbl_file(file_sha1, file_name, file_size, file_addr, status) values (?,?,?,?,1)...
// 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...
// 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 main import "fmt" type Moto interface { View() } type Honda struct{} func (h *Honda) View() { fmt.Println("HONDA") } type Yamaha struct{} func (y *Yamaha) View() { fmt.Println("YAMAHA") } type Suzuki struct{} func (s *Suzuki) View() { fmt.Println("SUZUKI") } func NewMoto (name string) Moto { if nam...
package test import ( "testing" "fmt" "sort" "ss/sssj/src/github.com/name5566/leaf/log" ) type testRank struct { rank int } type RankDataSlice []*testRank func (p RankDataSlice) Len() int { return len(p) } func (p RankDataSlice) Less(i, j int) bool { return p[i].rank < p[j].rank } func (p RankDataSli...
package column import ( "encoding/binary" "fmt" "io" "strings" "github.com/vahid-sohrabloo/chconn/v2/internal/helper" "github.com/vahid-sohrabloo/chconn/v2/internal/readerwriter" ) // Map is a column of Map(K,V) ClickHouse data type // Map in clickhouse actually is a array of pair(K,V) // // MapBase is a base ...
package main import ( "fmt" "log" "sync" "time" "github.com/y3sh/violet/rplidar" ) const ( usbAddr = "/dev/tty.usbserial-0001" ) func main() { lidar := rplidar.NewRPLidar(usbAddr, 115200) err := lidar.Connect() if err != nil { log.Fatal(err) } defer func() { err := lidar.Disconnect() if err != nil ...
package find_my_ip import ( "errors" "io/ioutil" "log" "net/http" ) // MyIP retrieves your current IP address func MyIP() (string, error) { ipFindSource := "http://myip.dnsomatic.com" resp, err := http.Get(ipFindSource) if err != nil { return "", errors.New("Can't get own ip from " + ipFindSource) } defer ...
package images import ( "crypto/rand" "encoding/json" "errors" "fmt" "io" "io/ioutil" "math" "os" "os/exec" "regexp" "strconv" "strings" "github.com/768bit/promethium/lib/common" "github.com/768bit/promethium/lib/images/diskfs/disk" "github.com/768bit/promethium/lib/images/diskfs/partition" "github.co...