text stringlengths 11 4.05M |
|---|
package utils
import "encoding/base64"
// basic64 解码
func DecodeBasic64(s string) ([]byte, error) {
var (
b []byte
err error
)
b, err = base64.StdEncoding.DecodeString(s)
return b, err
}
|
package main
import (
"bufio"
"fmt"
"os"
"runtime/pprof"
"sort"
)
var stdin *bufio.Reader
var stdout *bufio.Writer
func init() {
stdin = bufio.NewReader(os.Stdin)
stdout = bufio.NewWriter(os.Stdout)
}
func scan(args ...interface{}) (int, error) {
return fmt.Fscan(stdin, args...)
}
func printf(format string... |
package insert_sort
func InsertSort(a []int) {
var length = len(a)
for i := 1; i < length; i++ {
if a[i] < a[i-1] {
x := i
for j := i - 1; j >= 0; j-- {
if a[x] < a[j] {
a[x], a[j] = a[j], a[x]
x = j
}
}
}
}
}
|
package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"net/url"
"os"
"github.com/NYTimes/gziphandler"
"github.com/gorilla/mux"
)
func healthCheckHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "UI server up and running!")
}
func main() {
// Use default API url or read from envi... |
package main
import (
"bytes"
"os"
"testing"
)
func TestTokenizer_HasMoreTokens(t *testing.T) {
tk := NewTokenizer(bytes.NewBufferString(`
// comment1
/* Foo class */
class Foo {
function void main() {
var int i;
var String s;
let i = 100;
let s = "hello world";
}
}
`))
for tk.HasM... |
// print random 10 numbers
package main
import (
"fmt"
"math/rand"
)
func main() {
var count = 0
for count < 10 {
var num = rand.Intn(10) + 1
fmt.Println(num, "->", count)
count++
}
}
// 2 -> 0
// 8 -> 1
// 8 -> 2
// 10 -> 3
// 2 -> 4
// 9 -> 5
// 6 -> 6
// 1 -> 7
// 7 -> 8
// 1 -> 9
|
package controllers
import (
"errors"
"github.com/google/uuid"
"github.com/labstack/echo/v4"
"gorm.io/gorm"
"log"
"net/http"
"strings"
"telego/app/limiters"
"telego/app/models"
"telego/app/services"
"telego/app/utils"
"telego/app/validators"
)
var GetCollaboratorsByProjectId = func(c echo.Context) error {... |
package main
import (
"fmt"
"sort"
)
type Node struct {
id int
weight int
visited bool
children []*Node
}
func main() {
var q int // number of queries
fmt.Scanln(&q)
for i := 0; i < q; i++ {
var nodes = make(map[int]*Node)
var n int // number of nodes
var m int // number of edges
fmt.Scan... |
// Package worker implements the function to handle different jobs concurrently.
package worker
import (
"fmt"
"sync"
"sync/atomic"
)
// JobFunc is a func that makes some job and returns an error if it's failed.
type JobFunc func() error
// Handle handles concurrently the jobFuncs at the same time, depending on p... |
package main
import "fmt"
// Multiple Aggregation: Bird & Lizard types with Age fields combine into a Dragon; Introduce Aged interface
// Decorator: Shape interface with Render method; Circle & Square types; Make them have color as well; Introduce ColoredShape and OpacityShape type
func greetingPrinter(printFn func(... |
package smartling
import (
"fmt"
"io"
)
const (
endpointDownloadTranslation = "/files-api/v2/projects/%s/locales/%s/file"
)
// DownloadTranslation downloads specified translated file for specified
// locale. Check FileDownloadRequest for more options.
func (client *Client) DownloadTranslation(
projectID string,... |
package injector
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"time"
"k8s.io/api/admission/v1beta1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/kubernete... |
package netxmocks
import (
"crypto/tls"
"errors"
"reflect"
"testing"
)
func TestTLSConnConnectionState(t *testing.T) {
state := tls.ConnectionState{Version: tls.VersionTLS12}
c := &TLSConn{
MockConnectionState: func() tls.ConnectionState {
return state
},
}
out := c.ConnectionState()
if !reflect.DeepE... |
// Generated by ntoolkit/futures
package cparser
import "ntoolkit/futures"
import "ntoolkit/commands"
type DeferredCommand struct {
DeferredValue futures.Promise
}
func (promise *DeferredCommand) init() {
if promise.DeferredValue == nil {
promise.DeferredValue = &futures.DeferredValue{}
}
}
func (promise *D... |
// 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 power
import (
"bufio"
"context"
"os"
"strconv"
"time"
"chromiumos/tast/common/action"
"chromiumos/tast/errors"
)
// readFirstLine reads the first line from... |
package main
import (
"fmt"
"net/http"
"os"
"sync"
"github.com/gorilla/handlers"
)
func main() {
mux := http.NewServeMux()
newHandler := func(rw http.ResponseWriter, r *http.Request) {
rw.Write([]byte("hello world!"))
}
mux.HandleFunc("/hello", newHandler)
fs := http.FileServer(http.Dir("./static"))
m... |
package main
import (
"log"
"net/http"
"github.com/gorilla/mux" // Trying Gorilla Mux
)
func YourHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Gorilla!\n"))
}
func main() {
r := mux.NewRouter()
r.HandleFunc("/", YourHandler)
log.Printf("Serving on port 8080")
err := http.ListenAndServ... |
package main
import (
"fmt"
"github.com/slasyz/wundercli/api"
"github.com/slasyz/wundercli/config"
"os"
)
// Gets parameters from command-line arguments or set them empty if not present.
func getParams(count int) (result []string) {
result = make([]string, count)
// From command-line arguments
for i := 0; i <... |
package domainbinding
import (
catalog "catalog-controller/pkg/apis/catalogcontroller/v1alpha1"
catalogClient "catalog-controller/pkg/client/clientset/versioned"
goErrors "errors"
"alauda.io/diablo/src/backend/api"
"alauda.io/diablo/src/backend/errors"
"alauda.io/diablo/src/backend/resource/dataselect"
)
// Do... |
package main
import (
"github.com/sodhigagan/MyPractice/I/Constants"
"github.com/sodhigagan/MyPractice/I/Variables"
)
func main() {
Constants.Myname()
Constants.DOB()
Variables.Old()
//fmt.Println("so that makes me .... years old") //will add calulation using package variables once I figure out how to calculate... |
// 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-2020 Datadog, Inc.
package main
import (
"os"
"github.com/DataDog/datadog-operator/cmd/kube... |
/*
Copyright 2020 The Tilt Dev Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, sof... |
package main
import (
"database/sql"
"log"
"os"
"github.com/FrankYang0529/geekbang-golang-training-week2/storage"
)
func main() {
// init db
mysqlURL := os.Getenv("mysql")
db, err := sql.Open("mysql", mysqlURL)
if err != nil {
log.Fatalf("main: can't connect mysql, err: %+v", err)
}
defer db.Close()
//... |
package main
import (
"bufio"
"errors"
"fmt"
"log"
"net"
"os"
"os/exec"
"os/signal"
"regexp"
"syscall"
"text/template"
"time"
"github.com/appcelerator/amp/pkg/docker"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/spf13/cobra"
"golang.org/x/net/context"
... |
package templates
var CustomInfrastructure = `
terraform {
required_version = ">= 0.8.7"
}
provider "aws" {
access_key = "${var.AWS_ACCESS_KEY_ID}"
secret_key = "${var.AWS_SECRET_ACCESS_KEY}"
region = "${var.AWS_DEFAULT_REGION}"
}
data "aws_availability_zones" "available" {}
/*
* Calling modules who... |
package pattern
import (
"fmt"
"github.com/layer5io/meshery/mesheryctl/pkg/utils"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
var (
availableSubcommands []*cobra.Command
file string
tokenPath string
)
// PatternCmd represents the root command for pattern commands
var Pattern... |
package User
import (
"encoding/json"
"io/ioutil"
"log"
"os"
)
type User struct {
Username string
Password string
Email string
SponsorMeeting []string
ParticipantMeeting []string
}
//register an user with name, password, email
func RegisterAnUser(user *User) {
AllUserI... |
package presto
import (
"errors"
)
// ErrNoMore no more error
var ErrNoMore = errors.New("no more")
// ErrNoData no data when parse rows data
var ErrNoData = errors.New("no data")
// Error presto error
type Error struct {
line int
column int
msg string
}
func newError(line, column int, msg string) *Error ... |
package plugins
import (
"testing"
)
func TestNewMultiPlugin(t *testing.T) {
if _, ok := NewMultiPlugin().(*MultiPlugin); !ok {
t.Fail()
}
}
func TestMultiPluginConfigure(t *testing.T) {
m := NewMultiPlugin().(*MultiPlugin)
m.Configure("test", nil)
if m.name != "test" {
t.Fail()
}
}
|
package template
import "gorm.io/gorm"
type templateRepository struct {
db *gorm.DB
}
func NewTemplateRepository(db *gorm.DB) TemplateRepository {
return &templateRepository{
db: db,
}
}
|
package node
import (
"context"
"fmt"
"time"
"github.com/zdnscloud/cement/log"
"github.com/zdnscloud/cluster-agent/monitor/event"
"github.com/zdnscloud/gok8s/client"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/labels"
metricsapi "k8s.io/metrics/pkg/apis/metrics"
)
type Monitor struct {
cli cli... |
package app
import (
"conflict-template/internal/app/hello"
"conflict-template/internal/service/log"
)
func Init() {
hello.Init()
log.Info("appService init successfully")
}
|
// Copyright 2020 SEQSENSE, 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 pkg2
//
type SA struct {
num int
}
func (sa *SA) Get() int {
return sa.num
}
func (sa *SA) Set(n int) {
sa.num = n
}
type ISA interface {
Get() int
Set(int)
}
|
// 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... |
package application
import (
"fmt"
"net/http"
"github.com/Sirikon/Unfollowers2/domain"
goTwitter "github.com/dghubble/go-twitter/twitter"
"github.com/dghubble/oauth1"
"github.com/dghubble/oauth1/twitter"
)
// UnfollowersApplication .
type UnfollowersApplication struct {
Config domain.Config
WebServer doma... |
// 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 "fmt"
// SimilarityLMJelinekMercer similarity that uses the LM Jelinek Mercer. The algorithm attempts to
// capture important patterns in... |
package distinct
import "testing"
func TestDistinct(t *testing.T) {
entries := []struct {
input []int
result int
}{
{[]int{1, 3, 5, 6, 1, 2, 3, 2, 4, 5, 5, 1}, 6},
}
for _, entry := range entries {
result := Distinct(entry.input)
// check if result and expected result are same
if entry.result != ... |
// 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 wilco
import (
"context"
"chromiumos/tast/errors"
"chromiumos/tast/local/bundles/cros/wilco/pre"
"chromiumos/tast/local/wilco"
"chromiumos/tast/testing"
dtcpb... |
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License... |
package main
import (
"fmt"
"net/http"
"time"
)
// When we create a program, one 'Go routine' is automatically created (Main Routine), when there is a blocking call (like http request), it will wait
// By default Go use only one CPU core and Go Scheduler runs one thread on each 'logical' core
// Concurency is not ... |
package main
import (
"fmt"
"github.com/daischio/daischeme/codemodel"
"io/ioutil"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
// Generate a model from a schema
m := codemodel.New("main", "MyModel", "./assets/json_example_schema.json")
// Obtain the mapped model code
code := m.GetCode... |
package values
var (
Name = "myapp"
Namespace = "csip-dns"
Replicas int32 = 1
Labels = map[string]string{
"app": "myapp",
}
Image = "nginx:latest"
)
|
package config
import (
"gin-proyek/models"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres"
)
var DB *gorm.DB
func InitDB() {
var err error
DB, err = gorm.Open("postgres", "host=127.0.0.1 port=5432 user=priantikonuradipratama password=admin dbname=gorm sslmode=disable")
if err != nil {
... |
package v1
import (
"github.com/shiv3/slackube/app/controller/api/v1/slack"
"go.uber.org/zap"
"github.com/brpaz/echozap"
"github.com/labstack/echo/v4"
"github.com/shiv3/slackube/app/controller/api/v1/ping"
)
const (
V1Prefix = "/v1"
)
type Router interface {
Dispatch(e *echo.Echo) error
}
// RouterImpl v1パス... |
package engine
import (
"time"
)
// Engine Game engine
// Only 1 should be initialised
type Engine struct {
Managers []IManager
running bool
simulationSpeed float64
}
// Initialise the engine, and attached managers
func (engine *Engine) Initialise() {
}
// Run the engine
func (engine *Engine) Run... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
/*
LetterReplacer replaces the google language letters to translate words to English
*/
var LetterReplacer = strings.NewReplacer(
"a", "y",
"b", "h",
"c", "e",
"d", "s",
"e", "o",
"f", "c",
"g", "v",
"h", "x",
"i", "d",... |
// 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, ... |
// Sia uses Reed-Solomon coding for error correction. This package has no
// method for error detection however, so error detection must be performed
// elsewhere.
//
// We use the repository 'Siacoin/longhair' to handle the erasure coding.
// As far as I'm aware, it's the fastest library that's open source.
// It is a... |
// 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 policy
import (
"context"
"time"
"chromiumos/tast/common/fixture"
"chromiumos/tast/common/pci"
"chromiumos/tast/common/policy"
"chromiumos/tast/common/policy/... |
package main
import (
"encoding/json"
"net/http"
"github.com/google/uuid"
"github.com/nats-io/nats.go"
"github.com/sirupsen/logrus"
)
// publisher
type publisher interface {
Publish(string, []byte) error
}
// Service represent еру service structure.
type Service struct {
publisher publisher
}
// User repres... |
package main
import "fmt"
func sum(numbers ...int) int {
ret := 0
for _, num := range numbers {
ret += num
}
return ret
}
func nameStudents(names ...string) {
for _, name := range names {
fmt.Println(name)
}
}
func main() {
nameStudents("maria", "Carlos", "Jose", "Diego", "Joana", "Bianca", "Brendon")
f... |
package colorable_wrapper
import (
"fmt"
"github.com/mattn/go-colorable"
"io"
)
var coloredOut = colorable.NewColorableStdout()
func ColorPrint(a ...interface{}) {
_, err := io.WriteString(coloredOut, fmt.Sprint(a...))
if err != nil {
fmt.Print(a...)
}
}
func ColorPrintln(a ...interface{}) {
_, err := io.W... |
package rock
import (
"bytes"
"io/ioutil"
"log"
"net/http"
"time"
)
func init() {
if IsClient {
Addr = DefaultClientAddr
} else {
Addr = DefaultServerAddr
}
}
func getAndOrPostIfServer() {
if IsClient {
return
}
// consider commenting out? idk
http.Handle("/", http.FileServer(http.Dir("www")))
h... |
package hamming
import (
"errors"
"strings"
)
func Distance(a, b string) (int, error) {
i,err := diff(strings.Split(strings.ToLower(a), ""), strings.Split(strings.ToLower(b), ""))
return i, err
}
func diff(a []string, b []string) (int, error) {
if len(a) != len(b) {
return 0, errors.New("different lengths"... |
package go_micro_srv_user
import (
"github.com/jinzhu/gorm"
"github.com/pborman/uuid"
)
func (model *User) BeforeCreate(scope *gorm.Scope) error {
u := uuid.NewRandom()
return scope.SetColumn("Id", u.String())
}
|
package main
import (
"net/http"
"fmt"
)
func handler(){
fmt.Println("df")
}
func main() {
http.ListenAndServe(":80",http.HandlerFunc(handler))
}
|
package main
import "fmt"
func change(s ...int) {
s = append(s, 3)
}
func main() {
slice := make([]int, 5, 5)
slice[0] = 1
slice[1] = 2
change(slice...)
fmt.Println(slice) //[1,2,0,0,0]
change(slice[0:2]...)
fmt.Println(slice) //[1,2,3,0,0]
}
|
/**
*
* By So http://sooo.site
* -----
* Don't panic.
* -----
*
*/
package models
import (
"github.com/wonderivan/logger"
)
// Link 友情链接
type Link struct {
ID uint
URI string
AvatarURI string
Nickname string
Title string
}
// Info 友链详情
func (lk *Link) Info() (err error) {
return d... |
package scraper_test
import (
"fmt"
"strings"
"github.com/mh-orange/scraper"
)
func ExampleUnmarshal() {
// Parse and unmarshal an HTML document into a very basic Go struct
document := `<html><body><h1 id="name">Hello Scraper!</h1><a href="https://github.org/mh-orange/scraper">Scraper</a> is Grrrrrreat!</body><... |
package main
const color_bold = "\x1b[1m"
const color_green = "\x1b[32m"
const color_normal = "\x1b[0m"
func Green(s string) string {
return color_green + s + color_normal
}
func Bold(s string) string {
return color_bold + s + color_normal
}
func Paint(str string, indexes [][]int, color func(s string) string) str... |
package requests
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"github.com/google/go-querystring/query"
"github.com/atomicjolt/canvasapi"
"github.com/atomicjolt/canvasapi/models"
"github.com/atomicjolt/string_utils"
)
// ListModules A paginated list of the modules in a course
/... |
package printer
import (
"fmt"
"github.com/pterm/pterm"
)
const (
dfcBGHeader = pterm.BgBlue
)
type CLIPrinter interface {
PrintInfo(text string)
PrintDebug(text string)
PrintError(text string)
PrintSummary(data [][]string)
IntroScreen()
}
type CLIPrinterConfigs struct {
}
func NewCLIPrinter() CLIPrinter ... |
package main
import (
"fmt"
"github.com/bwmarrin/discordgo"
"noah/idc-bot/util"
"strings"
)
var (
componentHandlers = map[string]func(s *discordgo.Session, i *discordgo.InteractionCreate){
"status_restore": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
guild, _ := client.Guild(i.GuildID)
i... |
package main
import (
"fmt"
)
// 简单的一个函数,实现了参数+1的操作
func add1(a *int)int{
*a=*a+1 // 修改了a的值
return *a // 返回新值
}
func main(){
x:=3
fmt.Println("x = ",x) // 应该输出 “x=3”
x1 := add1(&x) // 调用 add1(&x) 传x的地址
fmt.Println("x+1 = ", x1) // 应该输出 "x+1 = 4"
fmt.Println("x = ", x) // 应该输出 "x = 4"
}
/**
PS D... |
// Copyright 2020 The VectorSQL Authors.
//
// Code is licensed under Apache License, Version 2.0.
package executors
import (
"databases"
"planners"
)
type CreateTableExecutor struct {
ctx *ExecutorContext
plan *planners.CreateTablePlan
}
func NewCreateTableExecutor(ctx *ExecutorContext, plan planners.IPlan) I... |
package main
import (
"fmt"
"gitee.com/jntse/gotoolkit/log"
"gitee.com/jntse/gotoolkit/net"
"gitee.com/jntse/gotoolkit/redis"
"gitee.com/jntse/gotoolkit/util"
"gitee.com/jntse/gotoolkit/eventqueue"
"gitee.com/jntse/minehero/pbmsg"
"gitee.com/jntse/minehero/server/tbl"
_"gitee.com/jntse/minehero/server/def"
p... |
package actions
import "log"
import "cointhink/mailer"
import "cointhink/proto"
import "cointhink/model/account"
import gproto "github.com/golang/protobuf/proto"
func DoNotify(notify *proto.Notify, accountId string) []gproto.Message {
resp := []gproto.Message{}
account_, err := account.Find(accountId)
if err !=... |
package routes
import (
"context"
"encoding/json"
"log"
"net/http"
"strconv"
"time"
"strings"
"math/rand"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"github.com/yashjjw/apiMeetings/main/models"
)
type RouteHandler struct {
Meeting *mongo.Collection
}
func NewRouteHandler(Meet... |
package dto
type ToDoList struct {
Id int `json:"Id"`
Task string `json:"Task"`
Status bool `json:"Status"`
}
|
package notificationqueue_test
import (
"strconv"
"sync"
"testing"
"github.com/herb-go/notification"
)
type testDraft struct {
locker sync.Mutex
data []*notification.Notification
}
func (d *testDraft) Open() error {
return nil
}
func (d *testDraft) Close() error {
return nil
}
func (d *testDraft) Save(not... |
package tyVpnProtocol
import (
"github.com/tachyon-protocol/udw/udwErr"
"github.com/tachyon-protocol/udw/udwFile"
"github.com/tachyon-protocol/udw/udwRand"
"github.com/tachyon-protocol/udw/udwStrconv"
"strconv"
)
const Debug = false
const (
overheadEncrypt = 0
overheadVpnHeader = 1
overheadIpHeader ... |
package main
import cgo_help_dir "go_demo/for_c_lang/cross_package/cgo_helper_dir"
//static const char* cs = "hello";
import "C"
func main() {
//运行将会报错,因为C.cs是*main.C.char,而方法接受*cgo_helper_dir.C.char
cgo_help_dir.PrintCString(C.cs)
}
|
package bufferpool
import (
"log"
"time"
"unsafe"
)
var gbp *bufferpool
var locker uint32
func init() {
gbp = New()
}
func Alloc(length int) []byte {
b, e := gbp.Alloc(length)
if e != nil {
log.Println(e)
}
return b
}
func Realloc(src []byte, length int) []byte {
dst := Alloc(length)
copy(dst, src)
Fr... |
// 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... |
package geoip2
import (
"archive/tar"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"os"
"path/filepath"
"strings"
"sync"
"time"
backoff "github.com/cenkalti/backoff/v4"
geoip2_golang "github.com/oschwald/geoip2-golang"
maxminddb "github.com/oschwald/maxminddb-golang"
)
type fileReader stru... |
//table 映射器
package service
import (
"dc/models"
"github.com/mitchellh/mapstructure"
)
//table - model的映射
var TableBindToModel = map[string]func(args Args)interface{}{
tablePrefix+"thread": BindThread,
tablePrefix+"thread_roadbook": BindThreadRoadbook,
tablePrefix+"2handcar_apply": Bind2handcarApply,
table... |
package main
import (
"errors"
"github.com/sirupsen/logrus"
"github.com/snwfdhmp/errlog"
)
var (
debug = errlog.NewLogger(&errlog.Config{
PrintFunc: logrus.Errorf,
LinesBefore: 6,
LinesAfter: 3,
PrintError: true,
PrintSource: true,
PrintStack: true,
Ex... |
package cmd
import (
"context"
"fmt"
"net/http"
"net/url"
"os"
"reflect"
"time"
"github.com/Azure/azure-pipeline-go/pipeline"
"github.com/Azure/azure-storage-azcopy/azbfs"
"github.com/Azure/azure-storage-blob-go/2016-05-31/azblob"
"github.com/Azure/azure-storage-file-go/2017-07-29/azfile"
"github.com/Jeff... |
package main
import (
"encoding/json"
"errors"
"flag"
"net/http"
"os"
"reflect"
"sort"
"time"
"github.com/unixpickle/essentials"
"github.com/unixpickle/pecunia/pecunia"
)
type Server struct {
Storage pecunia.Storage
}
func main() {
var addr string
var assets string
var dataDir string
flag.StringVar(&... |
// 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... |
package directmessages
import (
"encoding/json"
"io/ioutil"
"testing"
)
func TestItUnmarchalsAEventsJson(t *testing.T) {
data, err := ioutil.ReadFile("testdata/events.json")
if err != nil {
t.Error("Failed to parse attachment.json", err)
}
var events Events
json.Unmarshal(data, &events)
if events.NextC... |
// 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 ui
import (
"context"
"chromiumos/tast/local/bundles/cros/ui/chromecrash"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/crash"
"chromiumos/tast/testing... |
package tools
import (
"divsperf/script/parse"
"sync"
)
func RstoInt(rs []rune) (int, error) {
res := 0
for _, c := range rs {
res = res * 10 + (int(c) - 48)
}
return res, nil
}
func TKtoInt(tk parse.Token, name string, idx int) (int, error) {
if tk.Ctype != parse.INT {
return 0, parse.UnmatchError_parame... |
// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2020 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package rpccalls
import (
"github.com/bitmark-inc/bitmarkd/rpc/node"
)
// BlockDecodeData - the parameters for a blockDecode request
type BlockDe... |
// 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 course
import(
//"github.com/codebuff95/uafm"
//"github.com/codebuff95/uafm/usersession"
"github.com/codebuff95/uafm/formsession"
"feedback-admin/user"
"feedback-admin/database"
"feedback-admin/templates"
"feedback-admin/college"
"net/http"
"time"
"log"
"errors"
"html/template"
"gopkg... |
package command
import (
"github.com/continuul/random-names/pkg/stream"
"io"
)
// Cli represents the command line client.
type Cli interface {
Out() *stream.OutStream
Err() io.Writer
In() *stream.InStream
SetIn(in *stream.InStream)
}
// CliInstance is an instance the command line client.
// Instances of the cl... |
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":8080", nil))
}
const eventString = `_e{16,24}:Request handled|Received an HTTP request|p:low|#tag1:value,tag2,origin:master`
const counterString = `page.views:1|c`
const gaugeString = `cool... |
// 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 ui
import (
"context"
"time"
"github.com/golang/protobuf/ptypes/empty"
"google.golang.org/grpc"
"chromiumos/tast/errors"
"chromiumos/tast/local/audio"
"chro... |
package parser
import (
"encoding/json"
"fmt"
"goassignment/record"
"strconv"
)
func GetJsonFromRecordObjects(records []record.Record) string {
jsonString, err := json.Marshal(records)
if err != nil {
fmt.Println(err)
}
return string(jsonString)
}
func convertRecordToObject(csvRecords []string) record.Reco... |
// Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
package main
import (
"bytes"
"flag"
"fmt"
"go/format"
"io/ioutil"
"os"
"strings"
)
var flagType = flag.String("t", "", "default argu... |
package main
import (
"github.com/gragas/woobloo-frontend/config"
"html/template"
"io/ioutil"
"net/http"
)
var templates map[string]*template.Template
func main() {
// load the config file
config := config.LoadConfig("config.json")
// initialize maps, etc.
templates = make(map[string]*template.Template)
/... |
package udid_service
import (
"fmt"
uuid "github.com/satori/go.uuid"
"go.uber.org/zap"
"os"
"super-signature/model"
"super-signature/util/ali"
"super-signature/util/apple"
"super-signature/util/conf"
"super-signature/util/errno"
"super-signature/util/tools"
)
func AnalyzeUDID(udid, id string) (string, error... |
package cacheutil
import (
"fmt"
"testing"
)
func TestNewLRUCache(t *testing.T) {
lru := NewLRUCache(3)
lru.Set(10, "value1")
lru.Set(20, "value2")
lru.Set(30, "value3")
lru.Set(10, "value4")
lru.Set(50, "value5")
fmt.Println("LRU Size:", lru.Size())
v, ret, _ := lru.Get(30)
if ret {
fmt.Println("Get(3... |
package main
import (
"fmt"
)
var afl = [4]float64{1, 2, 3, 4}
//8 characters long using starting at -1 and going to -8
func squareroot(x float64) float64 {
z := 1.0
con := false
var eplace int
for index := 0; con != true; index++ {
z -= (z*z - x) / (2 * z)
afl[eplace] = z
count := 0
for i := range afl... |
package Week_02
func inorderTraversal(root *TreeNode) []int {
res := []int{}
if root == nil {
return res
}
resRight := inorderTraversal(root.Right)
resLeft := inorderTraversal(root.Left)
return append(append(resLeft, root.Val), resRight...)
}
|
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 webgl3d
import "github.com/go4orward/gowebgl/wcommon"
type Scene struct {
bkgcolor [3]float32 // background color of the scene
objects []*SceneObject // SceneObjects in the scene
overlays []Overlay // list of Overlay (interface) layers
}
func NewScene(bkg_color string) *Scene {
var scene Scene
... |
package leypaPractUtil
import ()
const AddUrl = "http://127.0.0.1:5001/api/v0/add"
const AddCode = 0
const CatUrl = "http://127.0.0.1:5001/api/v0/cat"
const CatCode = 1
const ListUrl = "http://127.0.0.1:5001/api/v0/files/ls"
const ListCode = 2
const MkdirUrl = "http://127.0.0.1:5001/api/v0/files/mkdir"
const MkdirCod... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.