text
stringlengths
11
4.05M
package main //58. 最后一个单词的长度 //给你一个字符串 s,由若干单词组成,单词前后用一些空格字符隔开。返回字符串中最后一个单词的长度。 // //单词 是指仅由字母组成、不包含任何空格字符的最大子字符串。 // // // //示例 1: // //输入:s = "Hello World" //输出:5 //示例 2: // //输入:s = " fly me to the moon " //输出:4 //示例 3: // //输入:s = "luffy is still joyboy" //输出:6 // // //提示: // //1 <= s.length <= 104 //s 仅有英文...
package indexer import ( "fmt" "os" "unsafe" "github.com/edsrzf/mmap-go" "github.com/gdbu/atoms" "github.com/hatchify/errors" ) // New will return a new Indexer func New(filename string) (ip *Indexer, err error) { var i Indexer if i.f, err = os.OpenFile(filename, os.O_CREATE|os.O_RDWR, 0744); err != nil { ...
package BLC import ( "bytes" "encoding/hex" "fmt" ) type PHBTXInput struct { PHBTxHash []byte //交易的Hash PHBVout int //存储TXOutput在Vout里面的索引 PHBSignature []byte //数字签名 PHBPublicKey []byte //公钥,钱包里面 } func (txInput *PHBTXInput) PHBPrintInfo() { fmt.Printf("txHash:%s\n", hex.EncodeToString(txInput.PHB...
/* Package handlers : handle MQTT message and deploy object to kubernetes. license: Apache license 2.0 copyright: Nobuyuki Matsui <nobuyuki.matsui@gmail.com> */ package handlers import ( "fmt" "go.uber.org/zap" apiv1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/api...
// Copyright 2020 The VectorSQL Authors. // // Code is licensed under Apache License, Version 2.0. package executors import ( "databases" "planners" ) type InsertExecutor struct { ctx *ExecutorContext plan *planners.InsertPlan } func NewInsertExecutor(ctx *ExecutorContext, plan planners.IPlan) IExecutor { ret...
package lemon import ( "flag" "fmt" "io/ioutil" "regexp" "time" "github.com/mitchellh/go-homedir" "github.com/monochromegane/conflag" ) func (c *CLI) FlagParse(args []string, skip bool) error { style, err := c.getCommandType(args) if err != nil { return err } if style == SUBCOMMAND { args = args[:len(...
// 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, ...
// 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...
// Copyright 2019 Liquidata, 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...
package steps import ( "errors" s "github.com/pganalyze/collector/setup/state" ) var CheckReplicationStatus = &s.Step{ ID: "check_replication_status", Description: "Check whether the database is a replica, which is currently unsupported by pganalyze guided setup", Check: func(state *s.SetupState) (bool...
package heapsort // i -> это индекс рута поддерева, а не самого дерева // To heapify a SUBtree (arr) rooted with node i which is // an index in arr[]. Size for 'deleting' prev root // i -> индекс root'a (не max, a того что с ним поменяли) func heapify(arr []int, size, i int) { l, r := 2*i+1, 2*i+2 // дочерние элемент...
package cmd import ( "fmt" "os" "github.com/kairen/kubeconfig-generator/pkg/client" "github.com/spf13/cobra" ) var ldapCmd = &cobra.Command{ Use: "ldap", Short: "Generate the Kubernetes config for LDAP user token.", Run: func(cmd *cobra.Command, args []string) { c := client.NewClient(flags) if err := c....
package model import "time" type UserConfigState struct { ArgsChangeTime time.Time Args []string } func NewUserConfigState(args []string) UserConfigState { return UserConfigState{Args: args} } func (ucs UserConfigState) WithArgs(args []string) UserConfigState { ucs.Args = args ucs.ArgsChangeTime = ti...
package snmp import ( "fmt" "net" "os" "os/exec" "strings" "sync" "testing" "time" "github.com/influxdata/telegraf/internal" "github.com/influxdata/telegraf/testutil" "github.com/influxdata/toml" "github.com/soniah/gosnmp" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) fun...
// +build darwin package main // commands used by the compilation process might have different file names on macOS than those used on Linux. var commands = map[string]string{ "ar": "llvm-ar", "clang": "clang-7", "ld.lld": "ld.lld-7", "wasm-ld": "wasm-ld-7", }
package stormpathweb import ( "fmt" "html/template" "net/http" "net/http/httptest" "net/url" "os/exec" "strings" "testing" "github.com/jarias/stormpath-sdk-go" ) var mainTemplate = ` <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge">...
package web import "github.com/junhwong/goost/security" type AuthenticationFilter interface { // 处理认证 Filter(Context) (security.Authentication, error) }
package bidscube import ( "encoding/json" "errors" "fmt" "net/http" "strconv" "github.com/buger/jsonparser" "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-ser...
package pkg import ( "github.com/gin-gonic/gin" "snippetBox-microservice/news/pkg/domain" ) func SetupRoutes(controller domain.NewsController) *gin.Engine { r := gin.New() r.Use(gin.Logger(), gin.Recovery(), SecureHeaders()) r.GET("/", controller.Home) r.GET("/news/:id", controller.ShowNews) return r }
package main import ( "bufio" "fmt" "os" "strconv" ) func main() { scanner := bufio.NewScanner(os.Stdin) var input string for input != "EXIT" { fmt.Print("What integer would you like to convert to a hex value? (Type 'EXIT' to leave)") scanner.Scan() input = scanner.Text() if input != "EXIT" { inte...
// Copyright 2020 Ye Zi Jie. 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 ...
package plex import ( "net/http" ) type StatusService service // TranscodeSessionsResponse is the result for transcode session endpoint /transcode/sessions type TranscodeSessionsResponse struct { Children []struct { ElementType string `json:"_elementType"` AudioChannels int `json:"audioChannels"` Audi...
package config import ( "errors" "io/ioutil" "gopkg.in/yaml.v2" ) // Values of the configuration type Values struct { Stripe struct { PublicKey string `yaml:"public_key"` SecretKey string `yaml:"secret_key"` WebhookSecret string `yaml:"webhook_secret"` } `yaml:"stripe"` } // Read the configuratio...
// 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" "encoding/json" "strconv" "strings" "time" "chromiumos/tast/common/android/ui" "chromiumos/tast/common/perf" "chromiumos/tast/errors"...
package main import ( "bufio" "fmt" "net" "os" ) func main() { conn, err := net.Dial("tcp", ":8080") if err != nil { fmt.Printf("net.Dial error:%s", err) os.Exit(1) } defer conn.Close() inputReader := bufio.NewReader(os.Stdin) go readConn(conn) for { input, err := inputReader.ReadString('\n') if er...
package metricstore_client_test import ( "bytes" "context" "io/ioutil" "net" "net/http" "net/http/httptest" "net/url" "sync" "testing" "time" metricstore_client "github.com/cloudfoundry/metric-store-release/src/pkg/client" rpc "github.com/cloudfoundry/metric-store-release/src/pkg/rpc/metricstore_v1" "goo...
package mappy import ( "encoding/json" "fmt" ) type innerJsonObject struct { innerMap map[string]interface{} innerValue interface{} } func (i innerJsonObject) Contains(key string) bool { _, contains := i.innerMap[key] return contains } func (i innerJsonObject) Int(key string) (int, error) { if !i.Contains(ke...
package model type ( Response struct { Result string Error error } )
package common import ( "context" "encoding/json" "fmt" "log" "net/http" "strconv" "strings" "time" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/adal" "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure/auth" "github.com/golang-jwt/...
/* * Copyright 2020 Kaiserpfalz EDV-Service, Roland T. Lichti. * * 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 ...
package main import ( "os" cli "github.com/openshift/oc-mirror/v2/pkg/cli" clog "github.com/openshift/oc-mirror/v2/pkg/log" ) func main() { // setup pluggable logger // feel free to plugin you own logger // just use the PluggableLoggerInterface // in the file pkg/log/logger.go log := clog.New("info") roo...
// Sample program to show how to unmarshal a JSON document into // a user defined struct type. package main import ( "encoding/json" "fmt" ) // document contains a JSON document. var document = `{ "workshop": { "college_name": "Maharaja Institute of Technology Mysore", "company_name": "Qwinix" }, "user":{ ...
package flog_test import ( "testing" . "github.com/coder/flog" ) func TestLogger(t *testing.T) { // Short-hand Infof("something happened") Errorf("something bad happened") Successf("something good happened") }
package main import "fmt" func main() { slice := make([]int, 5, 10) // 长度为5,容量为10 slice[2] = 2 // 索引为2的元素赋值为2 fmt.Println(slice) }
// 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-present Datadog, Inc. package debug import ( "net/http" "net/http/pprof" ) // Options used ...
package generator import ( "fmt" "html/template" "io/ioutil" "os" "strings" "github.com/RomanosTrechlis/blog-generator/config" "github.com/RomanosTrechlis/blog-generator/util/fs" ) // staticsGenerator object type staticsGenerator struct { fileToDestination map[string]string templateToFile map[string]stri...
package main import "sync" type relayAccessor interface { getRelay(id string) *streamRelay deleteRelay(id string) createRelay(id string) *streamRelay } type relayManager struct { store sync.Map } func newRelayManager() *relayManager { return &relayManager{} } func (m *relayManager) getRelay(id string) *stream...
package main import ( "bufio" "fmt" "os" "regexp" "strconv" "strings" "time" "github.com/AcalephStorage/go_check/Godeps/_workspace/src/github.com/newrelic/go_nagios" "github.com/AcalephStorage/go_check/Godeps/_workspace/src/gopkg.in/alecthomas/kingpin.v1" ) var ( warnLevel = kingpin.Flag("warn-level", "war...
// 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 dlp import ( "context" "fmt" "net/http" "net/http/httptest" "strings" "time" "chromiumos/tast/common/fixture" "chromiumos/tast/common/policy" "chromiumos/t...
package function import ( "encoding/json" "github.com/hecatoncheir/Storage" "io" "io/ioutil" "net/http" "net/http/httptest" "testing" ) func TestFAASFunctions_ReadCitiesByName(t *testing.T) { LanguageForTest := "ru" CityNameForTest := "TestCityName" DatabaseGatewayForTest := "http://TestDatabaseGateway" ...
// Copyright (c) KwanJunWen // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. package estemplate import "encoding/json" // MetaFieldMeta Other Meta-Field which sets application specific metadata. // A mapping type can have custom meta data a...
// Copyright (c) 2020 - for information on the respective copyright owner // see the NOTICE file and/or the repository at // https://github.com/hyperledger-labs/perun-node // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may...
package problem import "fmt" type LinkNode struct { Value int Next *LinkNode } func LinkSort(head *LinkNode) { if head == nil || head.Next == nil { return } end := head.Next for { if end.Next != nil { end = end.Next } else { break } } linkSort(head, end) } func linkSort(head, end *LinkNode)...
// Copyright 2020-2021 Clastix Labs // SPDX-License-Identifier: Apache-2.0 package tenant import ( "sigs.k8s.io/controller-runtime/pkg/client" capsulev1beta1 "github.com/clastix/capsule/api/v1beta1" ) type IngressHostnames struct { } func (IngressHostnames) Object() client.Object { return &capsulev1beta1.Tenant...
package frontend import ( "net/http" "time" "github.com/gorilla/mux" "services" "models" "controllers" "repository" "controllers/viewmodels" ) type ArticlesController struct { r *mux.Router service *services.ArticleService } type Author struct { FullName string Website string Bio string } ...
package monitor import ( "yunion.io/x/jsonutils" "yunion.io/x/onecloud/pkg/mcclient/options" ) type CommonAlertListOptions struct { options.BaseListOptions // 报警类型 AlertType string `help:"common alert type" choices:"normal|system"` Level string `help:"common alert notify level" choices:"normal|important|fa...
package batch import "time" // Config configuration for a batch type Config struct { maxItems int maxAge time.Duration consumers int }
package main import ( "net/http" ) func main() { objectlist.MakeList() //去登陆 http.HandleFunc("/hello", handler) http.HandleFunc("/regis", regis) http.HandleFunc("/login", login) http.HandleFunc("/sign", sign) //创建路由 http.ListenAndServe(":8080", nil) }
package errors import ( "bytes" "errors" "fmt" "runtime" "strconv" "strings" ) var prefix string type erx struct { pc uintptr error error parent *erx } // Implementation of the error interface. func (e erx) Error() string { x, flat := &e, make([]*erx, 0, 16) for { flat = append(flat, x) if x.par...
package app import ( "github.com/alidevjimmy/go-echo-train/controllers" "github.com/alidevjimmy/go-echo-train/middlewares" ) func router() { e.GET("/", controllers.Index) e.GET("/product/:id", controllers.GetProductById, middlewares.OnlyUsers) }
package main import ( "test-spider/engine" "test-spider/parse" "test-spider/scheduler" ) func main(){ //一下是多通道模式 e:= engine.ConcurrentEngine{ &scheduler.QueueScheduler{}, 2, } e.Run(engine.Request_q{ Url: "https://book.douban.com", //Url:"http://www.zhenai.com/zhenghun", //ParseFunc:zhengai.Pa...
package utils // AddStringBytes 拼接字符串, 返回 bytes from bytes.Join() func AddStringBytes(s ...string) []byte { switch len(s) { case 0: return []byte{} case 1: return []byte(s[0]) } n := 0 for _, v := range s { n += len(v) } b := make([]byte, n) bp := copy(b, s[0]) for _, v := range s[1:] { bp += copy(...
package main import ( "context" "fmt" "net" "net/http" "reflect" "strings" "github.com/bradleyfalzon/ghinstallation" v1 "github.com/csweichel/werft/pkg/api/v1" plugin "github.com/csweichel/werft/pkg/plugin/client" "github.com/google/go-github/v35/github" log "github.com/sirupsen/logrus" ) var ( werftGith...
// 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...
/* B1 Yönetim Sistemleri Yazılım ve Danışmanlık Ltd. Şti. User : ICI Name : Ibrahim ÇOBANİ Date : 25.07.2019 11:47 Notes : */ package models type Sources struct { DataType string `json:"DataType,omitempty"` Source string `json:"Source,omitempty"` SourceId int32 `json:"SourceId,omitempt...
package cmd import ( e "github.com/cloudposse/atmos/internal/exec" u "github.com/cloudposse/atmos/pkg/utils" "github.com/spf13/cobra" ) // awsEksCmdUpdateKubeconfigCmd executes 'aws eks update-kubeconfig' command var awsEksCmdUpdateKubeconfigCmd = &cobra.Command{ Use: "update-kubeconfig", Short: "Execute 'aws ...
package main type Group struct { ID string `json:"groupid"` Name string `json:"name"` }
package query import ( "reflect" "testing" "github.com/golang/protobuf/descriptor" test "github.com/osechet/go-datastore/_proto/osechet/test" datastore "google.golang.org/genproto/googleapis/datastore/v1" ) func TestApply(t *testing.T) { data := []descriptor.Message{ &test.Tested{Int32Value: 55, Int64Value: ...
package gbytes_test import ( "os/exec" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" "github.com/pivotal-cf/on-demand-service-broker/system_tests/test_helpers/gbytes" ) var _ = Describe("gbytes.AnySay", func() { var ( session *gexec.Session ) Context("passing som...
package main import ( "encoding/json" "errors" "fmt" "github.com/fatih/color" "github.com/go-ini/ini" "github.com/urfave/cli" "io/ioutil" "math" "net/http" "os" "path" "path/filepath" "regexp" "strings" "time" ) // Application name var APPNAME = "gitlab-ci-linter" // Version of the program var VERSION...
package main func main() { start:= StartState{} game := GameContext{Next:&start} for game.Next.executeState(&game) {} }
var nodes [][] int func reverse(a []int) []int{ b := make([]int, len(a)) copy(b, a) for i := len(a)/2-1; i >= 0; i-- { opp := len(a)-1-i b[i], b[opp] = a[opp], a[i] } return b } func max(vals ...int) int { max := 0 for _, val := range vals { if val >= max{ max = val } ...
package offheapstorage import ( "bytes" "testing" ) func BenchmarkOffheapAPI(b *testing.B){ // addrs := make([]uint64, 0, 1024) data1 := make([]byte, 32767) for i:=0; i<len(data1); i++ { data1[i] = byte(i % 256) } data2 := make([]byte, 32768) for i:=0; i<len(data2); i++ { data2[i] = byte(i % 256) } da...
package users import ( "fmt" "reflect" "regexp" "testing" "github.com/DATA-DOG/go-sqlmock" ) // TestGetByID is a test function for the Mysqlstore's GetByID func TestGetByID(t *testing.T) { // Create a slice of test cases cases := []struct { name string expectedUser *User idToGet int64 exp...
/* * Copyright 2018 The NATS 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...
package apir import ( "encoding/json" "fmt" "net/http" ) // Result contains require data type Result struct { w http.ResponseWriter r *http.Request message string } // New build a Result Instance func New(w http.ResponseWriter, r *http.Request) Result { return Result{w, r, "OK"} } // Throw will r...
package main import ( "os" "fmt" "log" "bufio" "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sqs" ) func main() { session, err := session.NewSession(&aws.Config{ Region: aws.String("us-west-2"), }) if err != nil { log...
package individualparsers import ( "encoding/base64" ) type ReverseBase64MZHeader struct{} func (b ReverseBase64MZHeader) Match(content []byte) (bool, error) { // PE header base64 encoded normalizedContent := reverse(string(content)) if len(normalizedContent) < 4 { return false, nil } headerContents := norm...
// Copyright © 2018 moooofly <centos.sf@gmail.com> // // 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, ...
package moxings type Yinpinmimajius struct { Id int Xuliehao string `gorm:"not null;DEFAULT:0"` Yinpinmima string `gorm:"not null;DEFAULT:0"` } func (Yinpinmimajius) TableName() string { return "Yinpinmimajius" }
// // cloud@txthinking.com package main import ( "strconv" "net" "fmt" "bufio" "io" "strings" "regexp" "crypto/tls" ) func main(){ var userName string = "" var password string = "" var i int = 0; var t string = "TX" var tag string var nc net.Conn //interface type var err error var in string var ou...
package bindings import ( "bytes" "path/filepath" "reflect" "os" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" ) func (d *DockerClient) PullImage(nameOrID string) (*PullImageReport, error) { reader, err := d.Client.ImagePull(d.Context, nameOrID, types.ImagePullOptions{})...
// Copyright 2014 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 http import ( "bytes" "encoding/json" "io" "log" "net/http" "net/url" "github.com/BestPrice/backend/bp" "github.com/gorilla/mux" ) type handlerFunc func(rw http.ResponseWriter, req *http.Request) error type statusError struct { error status int } type errorHandler handlerFunc func (h errorHandle...
package main import ( "errors" "fmt" "os" "path/filepath" "github.com/768bit/promethium/lib/config" "github.com/768bit/vutils" "github.com/urfave/cli/v2" ) var InstallCommand = cli.Command{ Name: "install", Aliases: []string{"ls"}, Usage: "Install promethium to your system", Flags: []cli.Flag{ &cli...
package solutions import ( "strings" ) func wordPattern(pattern string, str string) bool { list := strings.Split(str, " ") firstDict, secondDict := make(map[byte]string), make(map[string]byte) if len(pattern) != len(list) { return false } for i := 0; i < len(pattern); i++ { i...
// 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 feedback import ( "context" "time" "chromiumos/tast/ctxutil" "chromiumos/tast/local/chrome" "chromiumos/tast/local/chrome/uiauto" "chromiumos/tast/local/chrom...
package leetcode func findClosest(words []string, word1, word2 string) int { const max = 666666 ans, idx1, idx2 := max, max, -max for idx, word := range words { if word == word1 { idx1 = idx } else if word == word2 { idx2 = idx } ans = min(ans, abs(idx1-idx2)) } return ans } func abs(a int) int {...
// 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" "strings" ) type StringHandler interface { SetNext(h StringHandler) Process(s string) string } type LowerCaseHandler struct { next StringHandler } func (l *LowerCaseHandler) SetNext(h StringHandler) { l.next = h } func (l *LowerCaseHandler) Process(s string) string { s = strings....
package utils // // crypto.go // Copyright (C) 2020 light <light@1870499383@qq.com> // // Distributed under terms of the MIT license. // import ( "bytes" "crypto" "crypto/aes" "crypto/cipher" "crypto/rand" "crypto/rsa" "crypto/sha256" "crypto/x509" "encoding/base64" "encoding/pem" "errors" ) // PKCS5Paddi...
package xconnect import ( "fmt" "io/ioutil" "os" "strings" "gopkg.in/yaml.v2" ) const extraPathSeparator = "/" // XConnect represents the xconnect data section of a YAML document. // See spec-xconnect.yaml. type XConnect struct { Meta MetaProperties `yaml:"meta" json:"meta"` Listen map[s...
package migrations import ( "github.com/jmoiron/sqlx" ) func CreateAdminTable(tx *sqlx.Tx) error { tx.MustExec("CREATE TABLE `admin` (`username` varchar(255) NOT NULL,`notes` varchar(255), PRIMARY KEY(`username`))") return nil }
package main import ( "context" "echo-crud/internal/config" "echo-crud/internal/handler/http" "echo-crud/internal/repository" "echo-crud/internal/service" "fmt" nethttp "net/http" "os" "os/signal" "syscall" "time" "github.com/rs/zerolog/log" "gorm.io/driver/postgres" "gorm.io/gorm" ) func main() { lo...
package main import ( "bytes" "encoding/base64" "encoding/json" "flag" "fmt" "io" "io/ioutil" "net/textproto" "os" "strings" "github.com/sthulb/mime/multipart" ) var quoteEscaper = strings.NewReplacer("\\", "\\\\", `"`, "\\\"") func escapeQuotes(s string) string { return quoteEscaper.Replace(s) } type ...
package performance import ( "context" logrus "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "io/ioutil" "os" "testing" "github.com/vmware/govmomi" "github.com/vmware/govmomi/performance" "github.com/vmware/govmomi/simulator" "github.com/vmware/gov...
package aoc2019 import ( "reflect" "testing" ) func TestDay16TestPatternForElement(t *testing.T) { for idx, expPattern := range [][]int64{ {0, 1, 0, -1}, {0, 0, 1, 1, 0, 0, -1, -1}, {0, 0, 0, 1, 1, 1, 0, 0, 0, -1, -1, -1}, } { if p := day16PatternForElement(idx); !reflect.DeepEqual(expPattern, p.pattern) ...
package main import ( "net" "time" countdownpb "github.com/Sadham-Hussian/go-gRPC/stream/server-streaming/countDown/proto" "google.golang.org/grpc" ) type server struct{} func main() { listener, err := net.Listen("tcp", "localhost:4000") if err != nil { panic(err) } srv := grpc.NewServer() countdownpb.R...
package server import ( "net/http" "net/http/httptest" "testing" "github.com/robinjoseph08/hello/pkg/application" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func TestNew(t *testing.T) { app := application.New() srv, err := New(app) require.NoError(t, err) req, err := http...
package logs import ( "encoding/json" "fmt" "github.com/sirupsen/logrus" "github.com/spf13/viper" "lhc.go.game.user/utitls/https" "net/url" ) type HttpHook struct { } func NewHttpHook() *HttpHook { return &HttpHook{} } func (l *HttpHook) Levels() []logrus.Level { return logrus.AllLevels } func (l *HttpHook...
package boot import ( "github.com/gogf/gf/os/glog" "golang-coding/app/service" "time" ) func bootTime() { service.BootTime = time.Now().Format("2006-01-02 15:04:05") glog.Info("application boot time :" + service.BootTime) }
package gowalletsafrica import ( "net/http" "time" ) type ( Currency string TransactionType int base struct { HTTPClient *http.Client APIURL string secretKey string publicKey string } self struct { *base } wallets struct { *base } payouts struct { *base } airtime struct { ...
package e const ( SUCCESS = 200 InvalidParams = 400 ERROR = 500 ErrorAuthCheckTokenFail = 30001 ErrorAuthCheckTokenTimeout = 30002 ErrorAuthInsufficientAuthority = 30003 ErrorUploadFile = 40001 ErrorFavorExist = 40002 ErrorLikeExist = 40003 )
package gol import ( "fmt" "time" "github.com/mediaFORGE/gol/fields" field_severity "github.com/mediaFORGE/gol/fields/severity" field_timestamp "github.com/mediaFORGE/gol/fields/timestamp" ) // LogMessage is a log message. type LogMessage map[string]interface{} // FieldLength returns the number of fields in th...
//go:build !nostores // +build !nostores /* Copyright 2015 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 ap...
// 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 perfutil import ( "context" "fmt" "path/filepath" "time" "chromiumos/tast/common/perf" "chromiumos/tast/ctxutil" "chromiumos/tast/errors" "chromiumos/tast/l...
package main import ( "fmt" "github.com/peterfraedrich/consulmq" ) func main() { mq, err := consulmq.Connect(consulmq.Config{ Address: "172.17.0.2:8500", Datacenter: "dc1", Token: "", MQName: "cmq", }) if err != nil { panic(err) } i := 0 for i <= 100 { // Put and item on the queue ...
package operations // This file was generated by the swagger tool. // Editing this file might prove futile when you re-run the swagger generate command import ( "time" "github.com/go-openapi/errors" "github.com/go-openapi/runtime" cr "github.com/go-openapi/runtime/client" strfmt "github.com/go-openapi/strfmt" ...
package mdproc import ( "bytes" "regexp" "github.com/n0x1m/md2gmi/pipe" ) func FormatHeadings(in chan pipe.StreamItem) chan pipe.StreamItem { out := make(chan pipe.StreamItem) go func() { re := regexp.MustCompile(`^[#]{4,}`) re2 := regexp.MustCompile(`^(#+)[^# ]`) for b := range in { // fix up more t...
package main // // Reference // // https://echo.labstack.com/recipes/websocket // // import ( "github.com/labstack/echo" "fmt" "net/http" "io" "html/template" "github.com/labstack/echo/middleware" ) type EchoRenderer struct { } func(r *EchoRenderer) Render(w io.Writer, name string, data inte...