text stringlengths 11 4.05M |
|---|
package govid
// Stores covid data about any country
type CountryData struct {
Country string `json:"country"`
Cases int `json:"cases"`
TodayCases int `json:"todayCases"`
Deaths int `json:"deaths"`
TodayDeaths int `json:"todayDeaths"`
Recovered ... |
//
// June 2016, cisco
//
// Copyright (c) 2016 by cisco Systems, Inc.
// All rights reserved.
//
//
package main
import (
"github.com/dlintw/goconf"
"testing"
)
func TestMetricsInfluxConfigure(t *testing.T) {
var nc nodeConfig
var err error
nc.config, err = goconf.ReadConfigFile("pipeline_test.conf")
if err... |
package memorystorage
import (
"time"
storage "github.com/ezhk/golang-learning/hw12_13_14_15_calendar/internal/storage"
utils "github.com/ezhk/golang-learning/hw12_13_14_15_calendar/internal/utils"
)
type MemoryDatabase storage.MemoryDatabase
func NewDatatabase() storage.ClientInterface {
return &MemoryDatabase... |
package lcache
import (
"errors"
"time"
)
type Params struct {
Loader Loader
MaximumEntries uint32
ExpireAfterWrite time.Duration
ExpireAfterRead time.Duration
GracefulRefresh bool
}
type Cache struct {
Params
entries map[string]*cacheEntry
refreshes chan string
}
func NewCache(params Params) (*Cache... |
package main
import (
"encoding/json"
"fmt"
"os"
)
type responseOne struct {
Page int
Fruits []string
}
type responseTwo struct {
Page int `json:"page"`
Fruits []string `json:"fruits"`
}
func main() {
booleanB, _ := json.Marshal(true)
fmt.Println(string(booleanB))
integerB, _ := json.Marshal(1)
... |
package provider
import "strings"
func ensureLabel(labels string, key string, value string) string {
if key == "" {
return labels
}
if value == "" {
return labels
}
var split []string
if labels != "" {
split = strings.Split(labels, ",")
}
var found bool
for i, l := range split {
if !strings.HasPref... |
// 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 fingerprint
import "testing"
func TestRollbackStateEctoolUnmarshaler(t *testing.T) {
// Note that the following test string is not exactly what ectool would
// em... |
// 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 eventcollection
import (
rbacv1 "k8s.io/api/rbac/v1"
"github.... |
// 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 ui
import (
"context"
"fmt"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/bundles/cros/ui/notification"
uiperf "chromiumos... |
package netutil
import (
"net"
"testing"
)
func TestIP4ToInt(t *testing.T) {
t.Parallel()
if IP4ToInt(net.ParseIP("0.0.1.0")) != 256 {
t.Error(`0.0.1.0 != 256`)
}
if IP4ToInt(net.ParseIP("0.0.1.1")) != 257 {
t.Error(`0.0.1.0 != 257`)
}
}
func TestIntToIP4(t *testing.T) {
t.Parallel()
if !IntToIP4(256... |
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package model
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestHeaders(t *testing.T) {
headerValue := "bar"
t.Run("value", func(t *testing.T) {
testCases := []struct {
inpu... |
package server
import (
"github.com/gorilla/websocket"
"github.com/qaisjp/studenthackv-go-gameserver/game"
"log"
"net/http"
)
type Server struct {
Options *Options
Games []*game.Game
newGameChan (chan *game.Game)
}
func NewServer(options *Options) *Server {
return &Server{
Options: options,
}
}
var u... |
package wxapi
//请求微信网页授权access_token 返回值
type AuthResp struct {
Access_token string
Expires_in string
Refresh_token string
Openid string
Scope string
}
type BaseResp struct {
Errcode string
Errmsg string
*JsonResponse
}
//网页授权返回用户结构体
type AuthuserResp struct {
Openid string //用户的唯一标识
... |
package twosum
import (
"reflect"
"testing"
)
func TestTwoSum(t *testing.T) {
tests := []struct {
in1 []int
in2 int
want []int
}{
{
in1: []int{2, 7, 11, 15},
in2: 9,
want: []int{1, 2},
},
{
in1: []int{2, 7, 11, 15},
in2: 17,
want: []int{1, 4},
},
{
in1: []int{2, 7, 11, ... |
package api_tweet_controller
import (
"context"
"encoding/json"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/aws/aws-sdk-go-v2/service/dynamodb/types"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"log"
awsCommon "mytweet/middlewares/aws"
"mytwee... |
// create a file
package main
import (
"fmt"
"os"
)
// create a file
func proverbs(name string) error {
f, err := os.Create(name)
if err != nil {
return err
}
// from here the file is opened, now we can write in the file
// close the file
_, err = fmt.Fprintln(f, "Errors are values.")
// here we checking ... |
package imagemap
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/types"
apierrors "k8s.io/apimachinery/pkg/api/errors"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
"github.com/tilt-dev/tilt/pkg/model"
)
// Inject completed ImageMaps into the envi... |
package dockplugin
import (
"fmt"
"github.com/contiv/netplugin/core"
"github.com/contiv/netplugin/netmaster/docknet"
"github.com/contiv/netplugin/netmaster/mastercfg"
"github.com/contiv/netplugin/state"
"github.com/contiv/netplugin/utils"
"testing"
)
var stateDriver *state.FakeStateDriver
// initStateDriver i... |
package main
import "fmt"
func main() {
var x int
var y int
fmt.Println("Digite um numero para dividi-lo: ")
fmt.Scanf("%d", &x)
fmt.Println("digite o divisor: ")
fmt.Scanf("%d", &y)
z := x % y
fmt.Println("o remainder e: ", z)
}
|
package handlers
import (
"github.com/credo-science/credo-metadata-server/event"
"log"
"net/http"
"github.com/gin-gonic/gin"
"github.com/credo-science/credo-metadata-server/db"
)
func GetPing(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"msg": "pong"})
}
func GetEventAll(c *gin.Context) {
eventType, ok := ... |
package openrtb_ext
import "encoding/json"
// ExtImpPubmatic defines the contract for bidrequest.imp[i].ext.prebid.bidder.pubmatic
// PublisherId is mandatory parameters, others are optional parameters
// AdSlot is identifier for specific ad placement or ad tag
// Keywords is bid specific parameter,
// WrapExt needs ... |
package events
// Event dispatch event
type Event string
// Events
const (
Unknown Event = ""
Confirmed Event = "confirmed"
Login Event = "login"
Logout Event = "logout"
Signup Event = "signup"
All Event = "all" // must be last
)
|
package main
import (
"fmt"
"testing"
)
func TestGetvalueFizz(t *testing.T) {
fb := FizzBuzz{3, 100}
actual := fb.GetValue()
expected := "Fizz"
if actual != expected {
t.Errorf("got: %v\nwant: %v", actual, expected)
}
}
func TestGetvalueBuzz(t *testing.T) {
fb := FizzBuzz{5, 100}
actual ... |
package models
import (
"github.com/astaxie/beego"
)
func init() {
// beego.AppConfigPath = ""
// beego.AppConfig("ini", "/opt/local/go/src/edwardhey.com/football/wx/conf/app.conf")
beego.AppConfigPath = "../conf/app.conf"
beego.ParseConfig()
// fmt.Println(beego.AppConfig.String("appname"))
InitManual()
}
|
package service
import (
"bytes"
"crypto/x509"
"encoding/base64"
"encoding/json"
"encoding/xml"
"fmt"
"html/template"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
log "github.com/Sirupsen/logrus"
"github.com/crewjam/saml"
"github.com/dgrijalva/jwt-go"
"github.com/rancher/go-rancher/api"
"gith... |
package main
import (
"log"
"net/http"
"os"
"github.com/natezyz/midget/handlers"
"github.com/natezyz/midget/storage"
)
func main() {
s := &storage.Map{}
s.Init()
http.Handle("/", handlers.Redirect(s))
http.Handle("/encode", handlers.Encode(s))
http.Handle("/decode/", handlers.Decode(s))
port := os.Geten... |
package set3
import (
"cryptopals/set1"
"cryptopals/utils"
)
func truncateCipherTextsToCommonLength(cipherTexts [][]byte, length int) [][]byte {
var truncated [][]byte
for _, cipherText := range cipherTexts {
truncated = append(truncated, cipherText[:length])
}
return truncated
}
func breakFixedNonceCTRSta... |
package main
import (
"fmt"
"os"
"regexp"
"time"
"math/rand"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"github.com/dghubble/go-twitter/twitter"
"github.com/dghubble/oauth1"
"github.com/op/go-logging"
)
var log = logging.MustGetLogger("example")
var (
// DefaultFormatter is the default formatter ... |
package middleware
import (
"github.com/KashEight/not/consts"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
)
func SetUUIDKey() gin.HandlerFunc {
return func(ctx *gin.Context) {
v := ctx.Param("uuid")
uuid.MustParse(v)
ctx.Set(consts.UUIDKeyName, v)
ctx.Next()
}
}
|
package pipe
//Pipe for handling movement through pipeline. 3 use cases
//1. Source has only an out because it just sends messages
//2. Sink has only an in because it just receieves messages
//3. Transformer will have an in, and an out.
//Not sure about the types right now.
type Pipe struct {
In chan interface{}
O... |
package fyndiqv1
import (
"bytes"
"encoding/json"
"github.com/aquilax/gocommerce/transport"
"strconv"
)
type API struct {
tr transport.Transport
}
// MetaData holds the generic meta data response header
type MetaData struct {
Limit int `json: "limit"`
Next string `json: "next"`
Offset int ... |
package main
import (
"time"
"github.com/mattermost/mattermost-plugin-api/cluster"
"github.com/pkg/errors"
)
// OnActivate register the plugin command
func (p *Plugin) OnActivate() error {
p.router = p.InitAPI()
job, cronErr := cluster.Schedule(
p.API,
"BackgroundJob",
cluster.MakeWaitForRoundedInterval(1... |
/**
* All Rights Reserved
* This software is proprietary information of Akurey
* Use is subject to license terms.
* Filename: common.go
*
* Author: rnavarro@akurey.com
* Description: Common functions used in several places
*/
package common
import (
"strconv"
"net/url"
"errors"
)
/**
* Takes URL params and assign... |
package palindrome
import (
"errors"
"math"
)
// Product structure
type Product struct {
Product int // palindromic, of course
Factorizations [][2]int //list of all possible two-factor factorizations of Product, within given limits, in order
}
func reverseNumber(x int) int {
res := 0
for x > 0 {
... |
package problem0003
func lengthOfLongestSubstring(s string) int {
table := [128]int{}
start, maxLen := 0, 0
for i := range table {
table[i] = -1
}
for i, c := range s {
if table[c] >= start {
start = table[c] + 1
}
table[c] = i
maxLen = maxInt(maxLen, i-start+1)
}
return maxLen
}
func maxInt(a, ... |
package main
import (
"encoding/json"
"flag"
"fmt"
"github.com/futurehomeno/fimpgo"
log "github.com/sirupsen/logrus"
"github.com/thingsplex/tpflow"
fapi "github.com/thingsplex/tpflow/api"
"github.com/thingsplex/tpflow/flow"
"github.com/thingsplex/tpflow/registry/integration/fimpcore"
"github.com/thingsplex/t... |
package controller
import (
"database/sql"
"fmt"
"strconv"
"local.packages/models"
"local.packages/service"
"net/http"
"github.com/gin-gonic/gin"
)
type OutputForm struct {
CategoryIds []string `json:"category_ids"`
Achievement models.OutputAchievement `json:"achievement"`
}
func FindOutp... |
package main
import (
"bufio"
"fmt"
"io"
"net"
"os"
"strings"
)
func main() {
//addr := os.Args[1]
addr := "localhost:8088"
conn, err := net.Dial("tcp", addr)
if err != nil {
fmt.Errorf("%v", err)
os.Exit(1)
}
defer conn.Close()
info := bufio.NewScanner(conn)
info.Scan()
pwd := info.Text()
fmt.Pri... |
package t1time
// Copyright 2016-2017 MediaMath
//
// 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 _2_Null_Object_Pattern
//步骤 1
//创建一个抽象类。
type AbstractCustomer interface {
isNil() bool
getName() string
}
//步骤 2
//创建扩展了上述类的实体类。
type RealCustomer struct {
name string
}
func (receiver *RealCustomer) isNil() bool {
return false
}
func (receiver *RealCustomer) getName() string {
return receiver.name
}... |
package repositories
import (
"countdown/countdown-api/requests"
"fmt"
"log"
"os"
"time"
_ "github.com/jinzhu/gorm/dialects/postgres"
"github.com/jinzhu/gorm"
)
var DB *gorm.DB
var err error
func init() {
DB, err = DBInit()
if err != nil {
log.Fatal(err)
}
}
func DBInit() (*gorm.DB, error) {
dbinfo ... |
// 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 typec
import (
"context"
"io/ioutil"
"os"
"path/filepath"
"regexp"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/audio"
... |
//Go 语言循环语句
// 循环控制语句
//循环控制语句可以控制循环体内语句的执行过程。
//
//GO 语言支持以下几种循环控制语句:
//
//控制语句 描述
//break 语句 经常用于中断当前 for 循环或跳出 switch 语句
//continue 语句 跳过当前循环的剩余语句,然后继续进行下一轮循环。
//goto 语句 将控制转移到被标记的语句。
package main
import "fmt"
func main() {
var num int = 1
for true {
fmt.Printf("%d test \n", num)
num += 1
}
}
|
package store
// Provider creates a Persister for given string key
type Provider func(string) Store
// Store can load and store data
type Store interface {
Load(any) error
Save(any) error
}
|
package ravendb
import (
"bytes"
"crypto/md5"
"encoding/binary"
"fmt"
"io"
"reflect"
"sort"
"time"
)
type HashCalculator struct {
_buffer bytes.Buffer
}
func (h *HashCalculator) getHash() string {
data := h._buffer.Bytes()
return fmt.Sprintf("%x", md5.Sum(data))
}
func (h *HashCalculator) write(v interfa... |
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/spf13/viper"
"xiamiToLastfm/app"
"xiamiToLastfm/lastfm"
"xiamiToLastfm/xiami"
)
var debug bool
var frequency = time.Minute
var config string
func main() {
if f, _ := app.Logger(debug); f != nil {
defer f.Close()
}
... |
package main
import (
"fmt"
"reflect"
)
type Person struct {
FirstName string
LastName string
Sex string
Age int
}
type Lawer struct {
Person
hasOAB bool
OABnumber int
}
type Medic struct {
Person
CrmNumber int
Field string
}
type Programmer struct {
Person
StackOverFlow ... |
package db
import (
"errors"
"fmt"
"os"
"bitbucket.org/bridce/go_exercise2/config"
"github.com/jinzhu/gorm"
"github.com/qor/validations"
)
// DB Global DB connection
var DB *gorm.DB
func init() {
if DB != nil {
return
}
var err error
dbConfig := config.Config.DB
if dbConfig.Adapter == "mysql" {
DB,... |
package main
// Best: O(n^2) time | O(1) space
// Average: O(n^2) time | O(1) space
// Worst: O(n^2) time | O(1) space
func SelectionSort(array []int) []int {
currentIndex := 0
for currentIndex < len(array)-1 {
smallestIndex := currentIndex
for i := currentIndex + 1; i < len(array); i++ {
if array[smallestInd... |
package routes
import (
"log-collector/app/entity"
"log-collector/config"
"log-collector/middleware"
"github.com/gin-gonic/contrib/gzip"
"github.com/gin-gonic/gin"
)
var (
eventEntity entity.EventInterface
)
type Router struct {
}
func GetEngine() *gin.Engine {
eventEntity = entity.NewEventEntity()
// Set... |
package certifacte
import (
"bytes"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"errors"
"math/big"
"os"
"time"
"crypto/sha256"
"github.com/Sirupsen/logrus"
)
var log = logrus.New()
type ecdsaGen struct {
curve elliptic.Curve
}
func (e *ecdsaGen) Key... |
package main
import (
"bufio"
"bytes"
"fmt"
"os"
"unicode"
"unicode/utf8"
)
func main() {
reader := bufio.NewReader(os.Stdin)
line, err := reader.ReadBytes('\n')
if err != nil {
panic(err)
}
line = bytes.TrimRight(line, "\r\n")
input := string(line)
// fmt.Println(input)
fmt.Println("number of byte... |
package main
import (
"fmt"
"strconv"
)
func main() {
data := "Golang"
sv, err := strconv.Atoi(data)
if err == nil {
fmt.Printf("%T, %v", sv, sv)
} else {
fmt.Println(err)
}
}
|
package resolv
import (
"testing"
"github.com/miekg/dns"
)
func TestDo(t *testing.T) {
r := New()
rrs, _, dnssec, err := r.Do("example.org.", dns.TypeSOA)
if err != nil {
t.Fatal(err)
}
if len(rrs) != 1 {
t.Errorf("expected 1 SOA RR, got %d", len(rrs))
}
soa := rrs[0]
if _, ok := soa.(*dns.SOA); !ok {... |
package cmd
import (
"fmt"
"generate/version"
"github.com/spf13/cobra"
"os"
)
var rootCmd = &cobra.Command{
Use: "generate",
Short: "generate is a very fast code generator for webtable",
Long: `generate is a very fast code generator for webtable`,
Run: func(cmd *cobra.Command, args []string) {
... |
package messages
import (
"encoding/json"
"fmt"
log "github.com/sirupsen/logrus"
"net/http"
"strconv"
"time"
)
type MessageSender interface {
SendMessage(title string, message string) error
}
type CountsReceiver interface {
GetCountsByTimeFrame(from time.Time, to time.Time) ([]StatusCount, error)
}
type Mes... |
package aliyunfcgoruntime
import (
"encoding/json"
"fmt"
"net/http"
"strconv"
)
type Credentials struct {
AccessKeyID string
AccessKeySecret string
SecurityToken string
}
type FunctionMeta struct {
Name string
Handler string
Memory int
Timeout ... |
package goforce
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
type Requester interface {
URL() string
RequestBody() map[string]interface{}
}
type Response struct {
Status string
ErrorCode string
Message string
Data interface{}
}
type ResponseError struct {
ErrorCod... |
package anagrams
import (
"fmt"
"sort"
"strings"
)
// Sherlock finds all pairs of substrings in the string that are anagrams of each other
// string is between 2 and 100 chars
func Sherlock(s string) int32 {
// Naive approach:
// Find all substrings of s
// if this substring exists in the map already, increase ... |
package main
import (
"io"
"log"
"net"
"os"
)
// net包提供了可移植的网络I/O接口,包括TCP/IP、UDP、域名解析和Unix域socket
// 虽然本包提供了对网络原语的访问,大部分使用者只需要Dial、Listen和Accept函数提供的基本接口;以及相关的Conn和Listener接口
// crypto/tls包提供了相同的接口和类似的Dial和Listen函数
func main() {
// 创建服务
exampleServer()
// 客户端请求
exampleClient()
}
func exampleServer() {
//... |
package main
import (
"github.com/thesephist/xin/cmd"
)
// Xin CLI
func main() {
cmd.Execute()
}
|
package app
import (
"github.com/Unknwon/com"
"gopkg.in/ini.v1"
"os"
)
const CONFIG_FILE = "config.ini"
type Config struct {
Name string
Version string
Date string
Http ConfigHttp
Db ConfigDb
IsNew bool `ini:"-"`
}
type ConfigHttp struct {
Host string
Port string
Protocol string
}
typ... |
package timer
import (
"strings"
"fmt"
"strconv"
"math"
"time"
)
// Field name | Mandatory? | Allowed values | Allowed special characters
// ---------- | ---------- | -------------- | --------------------------
// Seconds | No | 0-59 | * / , -
// Minutes | Yes | 0-59 ... |
// Copyright (C) 2015 Miquel Sabaté Solà <mikisabate@gmail.com>
// This file is licensed under the MIT license.
// See the LICENSE file.
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestHighlightSvn(t *testing.T) {
// Empty.
s := svn{}
r := s.highlight("")
assert.Empty(t, r)
/... |
// 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 diframeworks
import (
_ "github.com/google/wire/cmd/wire"
)
|
package main
type Weight struct {
val int
cur int
}
type SmoothWeightedRoundRobin struct {
weights []*Weight
}
func NewSmoothWeightedRoundRobin(ws []int) *SmoothWeightedRoundRobin {
var weights []*Weight
for _, w := range ws {
weights = append(weights, &Weight{
val: w,
})
}
return &SmoothWeightedRound... |
package xmodel
import "github.com/ionous/sashimi/util/ident"
type EnumProperty struct {
Id ident.Id `json:"id"` // property id
Name string `json:"name"` // property name
Enumeration
}
func (enum EnumProperty) GetId() ident.Id {
return enum.Id
}
func (enum EnumProperty) GetName() string {
return enum.Name... |
package controllers
import (
"encoding/json"
"github.com/gorilla/mux"
"go-contacts/models"
utility "go-contacts/utils"
"log"
"net/http"
"strconv"
)
var CreateContact = func(w http.ResponseWriter, r *http.Request) {
user := r.Context().Value("user").(uint) //getting value from interface{} type
contact := &mo... |
package ds
import (
"testing"
)
func TestQueue(t *testing.T) {
q := NewQueue()
if q == nil {
t.Fatal("can't create a queue")
}
for i := 0; i < 1000000; i++ {
q.Put(i)
if q.Size() != 1 {
t.Fatalf("Size() failed with error:%v, expected=%v", q.Size(), 1)
}
el, err := q.Get()
if err != nil {
t.F... |
package main
import (
"fmt"
"time"
"./resources/product"
"./server"
)
func main() {
fmt.Println(time.Now(), "Shopping Manager api start")
loadResourceHandler()
server.Start()
}
// loadResourceHandler is unexported function
// which includes all resources
func loadResourceHandler() {
fmt.Println(time.Now()... |
package files
import (
"fmt"
"github.com/go-on/app"
"net/http"
"os"
"path/filepath"
"strings"
)
func noDirListing(h http.Handler) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, "/") {
http.NotFound(w, r)
return
}
h.ServeHTT... |
package main
import "fmt"
func main() {
var key_tmp = []string{"4", "5", "6", "7"}
add(key_tmp)
key_temp2 := key_tmp
key_temp2[0] = "1"
//key_temp2 =append(key_temp2,"456")
key_temp3 := key_tmp[2:]
fmt.Print(key_tmp, key_temp2, key_temp3)
key := []int{1, 2, 3, 4}
fmt.Println(key[len(key)-1])
//验证make 二维... |
package helm
import (
"github.com/spf13/cobra"
)
var HelmCmds = &cobra.Command{
Use: "helm",
Aliases: []string{"h"},
Short: "helm command start",
Run: Helm,
}
func Helm(_ *cobra.Command, _ []string) {}
|
package main
import (
"log"
"os"
"os/exec"
"time"
"github.com/meyskens/k8s-openresty-ingress/controller/configgenerate"
"github.com/meyskens/k8s-openresty-ingress/controller/connector"
)
type retryableFunc func(*connector.Client) error
func main() {
log.Println("Starting OpenResty Ingress Controller...")
c... |
package main
import "fmt"
//panic触发后之后的执行流不执行
//defer压栈处理
//panic和defer在同一个流程中,panic最后执行
func callPanic() {
defer func() {
fmt.Println("1")
}()
defer func() {
fmt.Println("2")
}()
defer func() {
fmt.Println("3")
}()
panic("call panic")
}
func main() {
defer func() {
fmt.Println("main")
}()
callPa... |
package main
import(
"flag"
"fmt"
"sync"
"runtime"
)
// Variables that are set by CLI options
var(prefixFile string)
var(maxOutputSize int)
var(outputFile string)
var(threadedMode bool)
var(numCoreThread int)
// Terminate all threads if magic file found
var(foundMagicFile bool)
var checkmtx s... |
/*
Copyright © 2019 NAME HERE <EMAIL ADDRESS>
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... |
/*
Copyright 2021.
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 un... |
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
//go:build !race
// +build !race
package testcontext
const raceEnabled = false
|
// 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 v2alpha1
import (
"fmt"
"github.com/DataDog/datadog-operator/... |
package cmd
import (
"context"
"github.com/loft-sh/devspace/cmd/flags"
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
"github.com/loft-sh/devspace/pkg/devspace/hook"
"github.com/loft-sh/devspace/pkg/devspace/kubectl"
"github.com/loft-sh/devspace/pkg/devspace/plugin"
"github.com/loft-sh/devsp... |
package channel
import (
"fmt"
"testing"
"time"
)
func service() string {
time.Sleep(50 * time.Millisecond)
return "Done 3333"
}
func otherTask() {
fmt.Println("working on someting else 2222")
time.Sleep(100 * time.Millisecond)
fmt.Println("Task is done 2222")
}
func TestService(t *testing.T) {
fm... |
package app
import (
"net/http"
"html/template"
"google.golang.org/appengine"
"google.golang.org/appengine/urlfetch"
)
func init() {
http.HandleFunc("/", handleStationName)
}
func handleStationName(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=ut... |
package demo
import (
"github.com/fncodr/remento"
)
func InitDb(cx *remento.Cx) error {
db := cx.Db().(*remento.Db)
systemName, err := cx.Settings.SystemName();
if err != nil {
return err
}
if _, err := systemName.SetVal(cx, "reservo demo"); err != nil {
return err
}
user := remento.NewUser(cx)
db.Nam... |
package main
import (
"server/application/usercase"
"server/infrastructure/auth"
"server/infrastructure/store/mysql"
"server/interfaces/api"
)
//func getProjectId() string {
// PROJECT_ID := os.Getenv("GOOGLE_CLOUD_PROJECT")
// if PROJECT_ID == "" {
// log.Fatalln("Failed to Get PROJECT_ID 'GOOGLE_CLOUD_PROJECT'... |
package main
//862. 和至少为 K 的最短子数组
//给你一个整数数组 nums 和一个整数 k ,找出 nums 中和至少为 k 的 最短非空子数组 ,并返回该子数组的长度。如果不存在这样的 子数组 ,返回 -1 。
//
//子数组 是数组中 连续 的一部分。
//
//
//
//示例 1:
//
//输入:nums = [1], k = 1
//输出:1
//示例 2:
//
//输入:nums = [1,2], k = 4
//输出:-1
//示例 3:
//
//输入:nums = [2,-1,2], k = 3
//输出:3
//
//
//提示:
//
//1 <= nums.length <= ... |
package main
import "fmt"
func main() {
var input int
fmt.Print("Please enter an integer: ")
fmt.Scan(&input)
div2, oddOrEven := half(input)
fmt.Printf("half(%d) returns (%d, %t)", input, div2, oddOrEven)
}
func half(z int) (int, bool) {
return z / 2, z%2 == 0
}
|
package convert
import (
"bytes"
"encoding/binary"
"log"
"math/rand"
"net"
"puck-server/db-server/user"
"puck-server/reward-server/rating"
"puck-server/shared-server"
"unsafe"
)
// #include "../../../laidoff/src/puckgamepacket.h"
import "C"
///////////////////////////////////////////////////////////////////... |
package sonobi
import (
"encoding/json"
"fmt"
"net/http"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/errortypes"
"github.com/prebid/prebid-server/openrtb_ext"
)
// SonobiAdapter - Sonobi SonobiAd... |
package main
const (
_ = 1 << (10 * iota)
KiB
MiB
GiB
TiB
PiB
)
|
//
// DISCLAIMER
//
// Copyright 2020-2021 ArangoDB GmbH, Cologne, Germany
//
// 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 re... |
// 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 input
import (
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/inpututil"
)
const (
// TODO: This is duplicated with draw package's definitions.
ScreenWidth = 320
ScreenHeight = 240
)
var theInput = &Input{
pressed: map[ebiten.Key]struct{}{},
prevPressed: map[ebiten.Key]struct{}{},... |
package main
import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"math/rand"
"reflect"
"regexp"
"runtime"
"testing"
proto "github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/chaincode/shim"
IOTRegistryTX "github.com/Trusted-IoT-Alliance/IOTRegistry/IOTRegistryTX"
"github.com... |
package leetcode
import "sort"
func findKthNumber(m int, n int, k int) int {
// 给定一个数x,求矩阵中 <=x 的数的个数,利用右上角二分
lessEqual := func(x int) int {
i := 0
j := n - 1
count := 0
for i < m && j >= 0 {
num := (i + 1) * (j + 1)
if num <= x {
count += j + 1
i++
} else {
j--
}
}
return count
... |
package orderbook
import (
"math/rand"
)
// OrderID is an order id.
type OrderID int
// Side is a side.
type Side bool
// Bid means you are buying.
const Bid Side = false
// Ask means you are selling.
const Ask Side = true
// order is a single order in the book.
type order struct {
id OrderID
side Side
pr... |
package db
import (
"github.com/jmoiron/sqlx"
_ "github.com/lib/pq"
"log"
)
var db *sqlx.DB
func init() {
var err error
db, err = sqlx.Open("postgres", "dbname=govhack user=postgres password=iamagopher host=103.241.200.20 sslmode=disable")
if err != nil {
log.Fatal(err)
}
}
func Client() *sqlx.DB {
retur... |
package url_translater
type URL struct {
Id int
LongUrl string
ShortURL string
}
type ShortURL struct {
Id int `json:"-" db:"id"`
LinkUrl string `json:"url" db:"short_url" binding:"required"`
}
type LongURL struct {
Id int `json:"-" db:"id"`
LinkUrl string `json:"url" db:"long_url" bind... |
package maccount
import (
"time"
"webserver/lib/jsonlib"
"webserver/models"
)
type Selection struct {
//RecordBase
Id int
UserId int
Type int
Value int
Info string
Image string
Extra string
Status int
CreatedAt time.Time //string
UpdatedAt time.Time //string
extra ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.