text stringlengths 11 4.05M |
|---|
package stream
import (
"io"
)
// Offset returns the current offset of the reader.
func Offset(seeker io.Seeker) (offset int64, err error) {
return seeker.Seek(0, io.SeekCurrent)
}
// Skip skips the given number of bytes and returns the new offset.
func Skip(seeker io.Seeker, offset int64) (newOffset int64, err er... |
package dao
import (
"github.com/jinzhu/gorm"
//financeClient "mall/app/api/web/finance/server/http/client"
"mall/app/api/web/account/conf"
"mall/lib/database/orm"
redigo "mall/lib/database/redis"
"github.com/gomodule/redigo/redis"
)
type Dao struct {
orm *gorm.DB
redigo *redis.Pool
// fc *financeClient... |
// Copyright 2019 SpotHero
//
// 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 wri... |
package main
import (
"bytes"
"crypto/rand"
"crypto/tls"
"encoding/hex"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
"net/http/httputil"
"net/url"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"github.com/godbus/dbus"
"github.com/serge-v/stv/channel"
)
var (
debug = ... |
package ptx
import (
"context"
"net"
sflib "git.torproject.org/pluggable-transports/snowflake.git/client/lib"
)
// SnowflakeDialer is a dialer for snowflake. When optional fields are
// not specified, we use defaults from the snowflake repository.
type SnowflakeDialer struct {
// BrokerURL is the optional broker... |
package main
import (
"bytes"
"database/sql"
"encoding/json"
"fmt"
"os"
"github.com/mactsouk/handlers"
_ "github.com/mattn/go-sqlite3"
)
const (
empty = ""
tab = "\t"
)
// PrettyJSON beautifies the printing of JSON records
func PrettyJSON(data interface{}) (string, error) {
buffer := new(bytes.Buffer)
... |
// 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 network
import (
"context"
"chromiumos/tast/local/chrome"
"chromiumos/tast/testing"
)
func init() {
testing.AddFixture(&testing.Fixture{
Name: "chromeLoggedI... |
package main
import (
"bufio"
"fmt"
"os"
"regexp"
"strings"
"github.com/emirpasic/gods/sets"
"github.com/emirpasic/gods/stacks/arraystack"
)
func parseSaveFile(fname string, keywords *sets.Set) {
s := arraystack.New()
f, err := os.Open(fname)
if err != nil {
panic(err.Error())
}
defer f.Close()
scan... |
package kata
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestNumUniqueEmails(t *testing.T) {
assert.Equal(t, 2, NumUniqueEmails([]string{
"test.email+alex@leetcode.com",
"test.e.mail+bob.cathy@leetcode.com",
"testemail+david@lee.tcode.com",
}))
}
|
package main
import (
"cekirdek/controller"
"cekirdek/model"
"fmt"
"github.com/gin-gonic/gin"
"github.com/golang-migrate/migrate/v4"
_ "github.com/golang-migrate/migrate/v4/database/postgres"
_ "github.com/golang-migrate/migrate/v4/source/file"
"go.uber.org/zap"
"gopkg.in/yaml.v2"
"io/ioutil"
)
var logger *... |
package main
import "fmt"
/*
按位置零操作符: &^
z = x &^ y 表示如果y中的bit为1,则z对应的bit为0,否则z对应的bit等于x中的bit位的值
z = x | y 或操作符可以理解为y的bit为1,则z也为1, 否则z与x的bit位相同
*/
func main() {
var a int8 = 3
var b int8 = 5 //00001001
z := a &^ b
fmt.Printf("z: %08b\n", z)
conversePosition()
}
/*
按位取反之后返回一个每个 bit 位都取反的数,
对于有符号的整... |
package terminfo
import (
"bytes"
"testing"
"github.com/nhooyr/terminfo/caps"
)
// TODO look at unibillium tests
func TestOpen(t *testing.T) {
ti, err := LoadEnv()
if err != nil {
t.Fatal(err)
}
t.Logf("%q", ti.ExtStrings["kUP7"])
t.Logf("%q", ti.Strings[caps.FlashScreen])
b := bytes.NewBuffer(nil)
ti.St... |
package oauth
import (
"errors"
"log"
"strings"
. "github.com/jsl0820/wechat"
)
const OAUTH_URL = "/connect/oauth2/authorize?appid={{APPID}}&redirect_uri={{REDIRECT_URI}}&response_type=code&scope={{SCOPE}}&state=STATE#wechat_redirect"
const OATH_TOKEN_URL = "/sns/oauth2/access_token?appid={{APPID}}&secret={{SECR... |
package mysql
import (
"database/sql"
"errors"
"reflect"
)
type transaction struct {
Tx *sql.Tx
success bool
}
func (this *transaction) Close() {
if this.success {
this.Tx.Commit()
} else {
this.Tx.Rollback()
}
}
func (this *transaction) Fail() {
this.success = false
}
func (this *transaction) Ex... |
package model
import (
xtime "mall/lib/time"
)
type EweiShopGroupsBuyer struct {
Openid string
Avatar string
Name string
Payedat xtime.Time
Price float64
}
|
package svc
// This file contains methods to make individual endpoints from services,
// request and response types to serve those endpoints, as well as encoders and
// decoders for those types, for all of our supported transport serialization
// formats. It also includes endpoint middlewares.
import (
"golang.org/x... |
package streamer
import (
"sync"
)
/**
The base collector is the orchestrator of the collector execution and handles the concurrency aspects.
*/
type Collector struct {
name string
cfg Config
collect CollectFunction
}
type CollectFunction func(name string, cfg Config, out chan Message)
/**
The base execu... |
package main
import (
"net/url"
"github.com/google/uuid"
)
type Downloader interface {
Download(fileURL *url.URL) (uuid.UUID, error)
Pause(downloadID uuid.UUID) error
Resume(downloadID uuid.UUID) error
Cancel(downloadID uuid.UUID) error
}
type TorrentDownloader interface {
Downloader
HealthCheckPeer(peerID... |
package main
import (
"net"
"time"
"log"
"os"
"fmt"
"strings"
"net/http"
)
var (
hostname string
graphiteConnection *net.Conn
connectionBackoff int
pointchannel chan GraphitePoint
)
type GraphitePoint struct {
Key string
Value interface{}
Timestamp int64
}
func... |
package docker
import "github.com/google/wire"
func ProvideLocalAsDefault(cli LocalClient) Client {
return Client(cli)
}
func ProvideClusterAsDefault(cli ClusterClient) Client {
return Client(cli)
}
var ClientCreatorWireSet = wire.NewSet(
wire.Value(RealClientCreator{}),
wire.Bind(new(ClientCreator), new(RealCli... |
// Copyright 2020 The Operator-SDK 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 ... |
package timeutil
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestPrecisionTicker(t *testing.T) {
maxIterations := 100
duration := 1 * time.Second
start := time.Now()
executions := 0
ticker := NewPrecisionTicker(func() {
executions++
}, duration/time.Duration(maxIterations), With... |
package main
import (
"database/sql"
"fmt"
"log"
"net/http"
uuid "github.com/satori/go.uuid"
_ "github.com/mattn/go-sqlite3"
)
func main() {
var err error
const dbname = "test.db"
var db *sql.DB
if db, err = sql.Open("sqlite3", dbname); err != nil {
log.Fatal(err)
}
defer func() {
if err = db.Clos... |
package cryptopasta
import (
"bytes"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"encoding/hex"
"testing"
)
var (
// https://groups.google.com/d/msg/sci.crypt/OolWgsgQD-8/jHciyWkaL0gJ
HMACKey = []byte("Jefe")
HMACMessage = []byte("what do ya want for nothing?")
HMACDigest = "6df7b24630d5ccb2ee335407... |
package utilservice
import (
"rz/restfulapi"
"github.com/gin-gonic/gin"
)
type Country struct {
Zone string `json:"zone"`
Name string `json:"name"`
}
func Countrys() []*Country {
return []*Country{
&Country{
Zone: "0086",
Name: "中国",
},
&Country{
Zone: "001",
Name: "美国",
},
&Country{
... |
// 撮合模塊.
//
// 根據訂單tick_data進行匹配訂單.
// 由於是模擬的交易,本模塊沒有實質的作用,
// 訂單匹配部分代碼已經移動到定序模塊中處理了.
//
// @author: bedewong
// @create at:
// @update at: 2019年4月20日
// @ change log:
package match
import (
"github.com/gpmgo/gopm/modules/log"
manager "github.com/BedeWong/iStock/service"
"github.com/BedeWong/iStock/model"
)
func... |
package main
import (
"bufio"
"fmt"
"io"
"os"
"unicode"
)
func main() {
characters := map[string]map[rune]int{
"letter": make(map[rune]int),
"number": make(map[rune]int),
"symbol": make(map[rune]int),
"space": make(map[rune]int)}
in := bufio.NewReader(os.Stdin)
for {
r, num, err := in.ReadRune()
... |
package main
import (
"fmt"
)
func main() {
s := sum(1,2,3,4,5,6,7)
fmt.Println(s)
ii := []int{1,2,3,4,5,6,7,8,9,10, 11,12,13,14,14,15,16}
t := sum(ii...)
fmt.Println("All numbers",t)
s2 := even(sum,ii...)
fmt.Println("even numbers", s2)
s3 := odd(sum, ii...)
fmt.Println("odd numbers", s3)
} //END main
f... |
package lbclient
import (
"encoding/json"
)
// RegexOptions is a structure used to construct regular expression search predicates using additional options.
type RegexOptions struct {
// CaseInsensitive=true means regex comparison is case insensitive, otherwise, comparison is case sensitive
CaseInsensitive bool
//... |
package server
import (
"testing"
"github.com/benbjohnson/clock"
"github.com/evcc-io/evcc/util"
inf2 "github.com/influxdata/influxdb-client-go/v2"
"github.com/influxdata/influxdb-client-go/v2/api/write"
"github.com/stretchr/testify/assert"
)
type influxWriter struct {
t *testing.T
p []*write.Point
idx i... |
// 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 main
import (
"fmt"
"time"
barv1alpha1 "github.com/tcontro/pkg/apis/bar/v1alpha1"
clientset "github.com/tcontro/pkg/generated/clientset/versioned"
"github.com/tcontro/pkg/generated/clientset/versioned/scheme"
barscheme "github.com/tcontro/pkg/generated/clientset/versioned/scheme"
informers "github.com/... |
package handler
import (
"encoding/json"
"net/http"
"hackerRank-Golang-test/driver"
repository "hackerRank-Golang-test/repository"
post "hackerRank-Golang-test/repository/post"
)
// NewPostHandler ...
func NewPostHandler(db *driver.DB) *Post {
return &Post{
repo: post.NewSQLPostRepo(db.SQL),
}
}
// Post ..... |
package actions
//goland:noinspection GoSnakeCaseUsage
const (
PLAYER_HEALTH = 100
MONSTER_HEALTH = 100
)
//goland:noinspection GoSnakeCaseUsage
const (
PLAYER_ATTACK_MIN_DMG_GENERAL = 10
PLAYER_ATTACK_MAX_DMG_GENERAL = 15
PLAYER_ATTACK_MIN_DMG_SPECIAL = 18
PLAYER_ATTACK_MAX_DMG_SPECIAL = 25
)
//goland:noinsp... |
package types
import (
coretypes "github.com/irisnet/core-sdk-go/common/codec/types"
sdk "github.com/irisnet/core-sdk-go/types"
)
// UnpackHeader unpacks an Any into a Header. It returns an error if the
// consensus state can't be unpacked into a Header.
func UnpackHeader(any *coretypes.Any) (Header, error) {
if a... |
// Copyright (C) 2018 Satoshi Konno. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package echonet
import "github.com/cybergarage/uecho-go/net/echonet/encoding"
const (
NodeProfileObject = 0x0EF001
NodeProfileObjec... |
package v2
import (
"context"
"errors"
"fmt"
"io"
"net/url"
"time"
"github.com/h2non/filetype"
"github.com/h2non/filetype/matchers"
"github.com/traPtitech/trap-collection-server/src/domain"
"github.com/traPtitech/trap-collection-server/src/domain/values"
"github.com/traPtitech/trap-collection-server/src/re... |
package handlers
import (
"bytes"
"context"
"encoding/json"
"log"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/Shopify/sarama"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"github.com/spatiumsocialis/infra/configs/services/circle/config"
"github.com/spatiumsocialis/infra/pkg/common"
"github.co... |
package terminfo
import (
"os"
"testing"
)
type testCase struct {
filename string
names []string
boolCaps map[string]bool
numCaps map[string]int
strCaps map[string]string
}
var testCases = []testCase{
{
filename: "./_data/xterm-256color",
names: []string{"xterm-256color", "xterm with 256 colors"}... |
// 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 crostini
import (
"context"
"fmt"
"regexp"
"strconv"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromiumos/t... |
package main
import (
"encoding/json"
"fmt"
)
type person struct {
parameter1 int
Parameter2 int
parameter3 string
parameter4 bool
}
func main() {
p1 := person{77, 88, "Hello", true}
p2, _ := json.Marshal(p1)
// p3 := string(p1) <-- impossible to change the whole of p1 into string
p4 := string(p2)
fmt.Pri... |
package k8snginx
// GroupName is the used group name in this package
const (
GroupName = "k8s.nginx.org"
)
|
package trade
import (
"encoding/json"
"net/http"
"github.com/skycoin/getsky.org/src/util/httputil"
)
// APIInfoResponse holds basic API information
type APIInfoResponse struct {
Name string `json:"name"`
Description string `json:"description"`
Version int `json:"version"`
}
// APIInfoHandler re... |
package syncer
import (
"fmt"
"k8s.io/api/certificates/v1beta1"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"
"k8s.io/klog"
"github.com/baidu/ote-stack/pkg/util"
)
// CSRSyncer is responsible for synchronizing csr from apiserver.
type CSRSyncer struct {
ctx *SyncContext
Informer cache.... |
// Package num2words implements numbers to words converter.
package num2words
import (
"math"
"strconv"
"strings"
)
// how many digit's groups to process
const groupsNumber int = 4
var _smallNumbers = []string{
"nol", "satu", "dua", "tiga", "empat",
"lima", "enam", "tujuh", "delapan", "sembilan",
"sepuluh", "s... |
package vehicle
import (
"fmt"
"time"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/vehicle/ford"
)
// https://github.com/d4v3y0rk/ffpass-module
// https://github.com/ianjwhite99/connected-car-node-sdk
// https://github.com/TA2k/ioBroker.ford
// Ford is an api.Vehicle im... |
package pbevents
import "github.com/hyperledger/burrow/execution/events"
func (br *BlockRange) Bounds(latestBlockHeight uint64) (startKey, endKey events.Key, streaming bool) {
return br.GetStart().Key(latestBlockHeight), br.GetEnd().Key(latestBlockHeight),
br.GetEnd().GetType() == Bound_STREAM
}
func (b *Bound) K... |
package http
import (
bm "github.com/go-kratos/kratos/pkg/net/http/blademaster"
)
func showMail(ctx *bm.Context) {
ctx.JSON(nil,nil)
}
|
// Copyright 2014-2016 The Zurichess Authors. Violent|Quiet rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package engine
import (
"testing"
. "bitbucket.org/zurichess/board"
. "bitbucket.org/zurichess/zurichess/internal/testdata"
)
func s... |
// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
package useragent
import (
"fmt"
"strings"
)
// EncodeEntries encodes all entries.
func EncodeEntries(entries []Entry) ([]byte, error) {
parts := make([]string, len(entries))
for i, entry := range entries {
if entry.Product != "" {
... |
package main
import (
"JsGo/JsHttp"
. "JsGo/JsLogger"
"JunSie/com"
"fmt"
)
func InitLogin() {
JsHttp.WhiteHttps("/login", Login) //登录密码账号
JsHttp.Https("/exchange", Exchange)
}
func Login(s *JsHttp.Session) {
type Para struct {
Name string
Password string
}
para := &Para{}
e := s.GetPara(para)
if e... |
package main
import (
"log"
"./database"
"github.com/icrowley/fake"
"./models"
)
// GenerateInfo describes structure of generating db i.e Number of entities
type GenerateInfo struct {
UsersCount int
DriversCount int
CarsCount int
DrivesCount int
}
func generate(db *database.DB, info GenerateInfo) {
... |
// Copyright 2022 Saferwall. All rights reserved.
// Use of this source code is governed by Apache v2 license
// license that can be found in the LICENSE file.
package packer
import (
"strings"
"github.com/saferwall/saferwall/internal/utils"
)
const (
// cmd to invoke exiftool scanner
cmd = "/opt/die/diec.sh"
)... |
package response
import (
"github.com/gin-gonic/gin"
"net/http"
)
// Response
func Response(ctx *gin.Context, httpStatus int, code int, data gin.H, msg string) {
ctx.JSON(httpStatus, gin.H{
"code": code,
"data": data,
"msg": msg,
})
}
// Success
func Success(ctx *gin.Context, data gin.H, msg string) {
ct... |
package models
import (
"log"
u "../utils"
"github.com/jinzhu/gorm"
)
type Post struct {
gorm.Model
Title string `json:"title"`
ImagePath string `json:"image_path"`
UserID uint `json:"user_id"`
User Account `gorm:"foreignkey:UserID"`
SectionID uint `json:"section_id"`... |
package air
import (
"bytes"
"encoding/json"
"errors"
"net/http"
"net/http/httptest"
"os"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestServer(t *testing.T) {
assert.NotNil(t, TheServer)
assert.NotNil(t, TheServer.Server)
}
func TestServerServe(t *testing.T) {
assert.False(t, DebugMod... |
package tools
import "fmt"
func PanicError(err error) {
if err != nil {
fmt.Println(err)
panic(err)
recover()
fmt.Println("recover")
}
}
|
// Copyright 2021 Comcast Cable Communications Management, LLC
//
// 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 ... |
// Copyright 2014 Matthias Zenger. 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 appl... |
package lib
import (
"encoding/json"
"os"
)
func Load(file string) (*Config, error) {
cfg := &Config{}
fd, err := os.Open(file)
if err != nil {
return cfg, err
}
defer fd.Close()
dec := json.NewDecoder(fd)
err = dec.Decode(cfg)
return cfg, err
}
|
package main
import "fmt"
func main() {
s := []int{100,34,3,5,56,676,87,4,1}
fmt.Println(s)
sort(s, 0, len(s) -1)
fmt.Println(s)
}
func sort(s []int, begin int, end int) {
left := begin
right := end
pivot := s[(left+right)/2]
for left <=right {
for s[right] > pivot {
right--
}
for s[left] < piv... |
package main
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"runtime"
"strings"
"time"
)
func main() {
log.SetFlags(log.LstdFlags | log.Lmicroseconds | log.Lmsgprefix)
log.SetPrefix("[loadgen] ")
defer func() {
if err := recover(); err != nil {
_, file, line, ok := runtime.Caller(2)
if !ok {
... |
package web
// NilResponse 空响应
type NilResponse struct {
response Responsor
}
func (resp *NilResponse) Code() int {
return resp.response.GetCode()
}
// NewNilResponse create a RawResponse
func NewNilResponse(response Responsor) *NilResponse {
return &NilResponse{response: response}
}
// response get real respons... |
package _5_IslandOfKnowledge
import (
"fmt"
"math"
)
func main() {
arr := []int{2, 4, 1, 0}
result := arrayMaximalAdjacentDifference(arr)
fmt.Println(result)
}
func arrayMaximalAdjacentDifference(inputArray []int) int {
result, delta := 0, 0
for i := 1; i < len(inputArray); i++ {
delta = int(math.Abs(float... |
package sharedobj
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestChecksumVerifier(t *testing.T) {
t.Run("Checksum verifier", func(t *testing.T) {
t.Run("Doesn't error if there's no plugins to check", func(t *testing.T) {
})
t.Run("Doesn't error if checksums match", func(t *testing.T) {
... |
package tools
import (
"reflect"
"testing"
)
func TestSubstr(t *testing.T) {
type args struct {
str string
start int
length int
}
tests := []struct {
name string
args args
want string
}{
// TODO: Add test cases.
{"iamlinet", args{"iamlinet", 3, 2}, "li"},
{"heisyeelle", args{"heisyeelle", ... |
package server
import (
"database/sql"
"fmt"
"strings"
"time"
_ "github.com/lib/pq"
log "github.com/sirupsen/logrus"
)
func openDBConnection(config Config) (*sql.DB, error) {
maskedPassword := strings.Repeat("*", len(config.DB.Password))
psqlInfo := fmt.Sprintf("host=%s port=%v user=%s password=%s dbname=%s... |
package udwNetTestV2
import (
"github.com/tachyon-protocol/udw/udwErr"
"github.com/tachyon-protocol/udw/udwTest"
"sync"
"testing"
)
func TestTcpPipe(t *testing.T) {
c1, c2, err := TcpPipe()
udwErr.PanicIfError(err)
defer c1.Close()
defer c2.Close()
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
buf := make... |
package com
//评论(统计评论数量)
import (
"JsGo/JsBench/JsComments"
"JsGo/JsHttp"
"JsGo/JsLogger"
"JsGo/JsStore/JsRedis"
"JunSie/constant"
"JunSie/util"
"fmt"
)
type XMComment struct {
JsComments.Comments
}
func Init_comment() {
JsHttp.WhiteHttps("/newcomment", NewComment) //新建评论
JsHttp.WhiteHttp("/ge... |
//go:build e2e_testing
// +build e2e_testing
package router
import (
"context"
"fmt"
"net"
"os"
"path/filepath"
"reflect"
"sort"
"strconv"
"strings"
"sync"
"testing"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/slackhq/nebula"
"github.com/slackhq/nebula/header"
... |
package m2go
import (
"strconv"
)
type MAttributeSet struct {
Route string
AttributeSet *AttributeSet
AttributeSetGroups []Group
AttributeSetAttributes *[]Attribute
APIClient *Client
}
func CreateAttributeSet(a AttributeSet, skeletonID int, apiClient *Client) (*MAttr... |
package Pigeon
type IMessage interface {
Send()
}
type Message struct {
IMessage
sender string
receiver string
channel Channel
body string
} |
package main
import (
. "./controller"
. "./config"
. "./mapper"
)
var config = Config{}
var dao = BookDAO{}
func init() {
config.Read()
dao.Server = config.Server
dao.Database = config.Database
dao.Connect()
}
func main() {
Route()
}
|
// Copyright 2020 The VectorSQL Authors.
//
// Code is licensed under Apache License, Version 2.0.
package transforms
import (
"sync"
"time"
"datablocks"
"expressions"
"planners"
"processors"
"sessions"
"github.com/gammazero/workerpool"
)
type AggregateSelectionTransform struct {
ctx *Transform... |
package shutdown
import (
"container/list"
"log"
"os"
"os/signal"
"sync"
)
// 被关闭者要实现的接口
// the only interface that need to be implemented
type GracefulClose interface {
OnShutdown()
}
// 如果无法让被关闭的对象实现接口,可以通过类型转换一个func()形式的闭包函数,来简单地实现GracefulClose接口
// if the shutdown logic is just a function but not a struct,... |
package web
import (
"github.com/Miniand/venditio/asset"
"github.com/Miniand/venditio/cmd"
"github.com/Miniand/venditio/config"
"github.com/Miniand/venditio/core"
"github.com/Miniand/venditio/inject"
"github.com/gorilla/mux"
"log"
"net/http"
"path"
)
const (
DEP_ROUTER = "httpRouter"
CONFIG_BIND_A... |
// Copyright 2018 Google LLC
//
// 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 w... |
// 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 monocular
import (
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
"time"
"github.com/cloudfoundry-incubator/stratos/src/jetstream/repository/interfaces"
"github.com/helm/monocular/chartrepo/common"
"github.com/labstack/echo"
log "github.com/sirupsen/logrus"
"k8s.io/apimachinery/pkg/util/wait"
)
t... |
package service
import (
"net/url"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/vehicle/vag"
"github.com/evcc-io/evcc/vehicle/vag/tokenrefreshservice"
"github.com/evcc-io/evcc/vehicle/vag/vwidentity"
)
func TokenRefreshServiceTokenSource(log *util.Logger, data, q url.Values, user, password string) (v... |
package apm
import (
"bytes"
)
// Formatter 表示一个格式化器。
type Formatter interface {
// Format 格式化一条日志。
//
// 注意:不要缓存 `entry`, `dest` 对象,因为它们可能是池化对象。
Format(entry Entry, dest *bytes.Buffer) (err error)
}
|
package main
import "fmt"
func main() {
a := 5
b := &a
fmt.Println("a: ",a,", b: ",b)
fmt.Printf("type of b: %T\n", b)
*b = 10
fmt.Println("a: ", a)
} |
package main
import "fmt"
import GT "hjpark.com/greetingModule"
func main() {
fmt.Println("Test")
GT.SayHello()
}
|
// 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 a11y provides functions to assist with interacting with accessibility
// features and settings.
package a11y
import (
"context"
"chromiumos/tast/local/a11y"
"... |
package jt
import (
"./json"
"code.google.com/p/goauth2/oauth"
"crypto/tls"
jzon "encoding/json"
"fmt"
"github.com/HouzuoGuo/tiedot/db"
"github.com/gorilla/sessions"
"io/ioutil"
"log"
"net/http"
// "os"
)
type Auth struct {
ClientID string
ClientSecret string
Scope string
RedirectURL string... |
package solutions
func longestConsecutive(nums []int) int {
temp := map[int]int{}
result := 0
for _, number := range nums {
if _, ok := temp[number]; !ok {
left := temp[number - 1]
right := temp[number + 1]
temp[number] = 1 + left + right
if left >... |
// 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 actions
import (
"github.com/gobuffalo/buffalo"
"github.com/bketelsen/microclass/module6/teachweb/models"
"github.com/gobuffalo/buffalo/middleware"
"github.com/gobuffalo/envy"
"github.com/gobuffalo/packr"
)
// ENV is used to help switch settings based on where the
// application is being run. Default i... |
package mqtt
import (
"crypto/tls"
"log"
mqtt "github.com/eclipse/paho.mqtt.golang"
uuid "github.com/satori/go.uuid"
)
type Config struct {
Host string
ClientID string
Username string
Password string
}
var f mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {
log.Printf("TOPIC: %s MSG:%s... |
// Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information.
//go:build go1.20 && !noquic
// +build go1.20,!noquic
package quic
import (
"context"
"crypto/tls"
"net"
"time"
"github.com/quic-go/quic-go"
"github.com/zeebo/errs"
"storj.io/common/peertls/tlsopts"
)
const defaultIdleTimeout = ... |
// 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 main
import "fmt"
// 数组 是 值类型, 深cp, 后面的变量 改变 不会 影响 源
// 切片 是 引用类型 ,浅cp,后面的变量 改变 会 影响 源
func main() {
s1 := make([]int, 5, 10) //用make 函数 定义 一个 长度5,容量10 的切片
fmt.Printf("len:%d,cap:%d,value:%v \n",len(s1),cap(s1),s1)
var s01 []int //len:0, cap:0, s01==nil
s02 := []int{} //len:0, cap:0, s02 != nil
... |
package main
import (
"os"
"sort"
"time"
"book/ch07"
)
var tracks = []*ch07.Track{
{"Go", "Moby", "Moby", 1992, length("3m37s")},
{"Go", "Delilah", "From the Roots Up", 2012, length("3m38s")},
{"Go Ahead", "Alicia Keys", "As I Am", 2007, length("4m36s")},
{"Ready 2 Go", "Martin Solveig", "Smash", 2011, lengt... |
package comparethetriplets
import (
"reflect"
"testing"
)
func TestExample(t *testing.T) {
if !reflect.DeepEqual([]int32{1, 1}, CompareTriplets([]int32{5, 6, 7}, []int32{3, 6, 10})) {
t.Errorf("CompareTriplets failed with the example!")
}
}
|
package main
import (
"encoding/json"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ssm"
"github.com/krozlink/betting"
"log"
"os"
"strings"
)
type configuration struct {
Teams map[string]string `json:"teams"`
CompetitionID ... |
package memory_test
import (
"fmt"
"github.com/adamluzsi/frameless/adapters/memory"
"io"
"io/fs"
"os"
"path/filepath"
"testing"
"github.com/adamluzsi/frameless/ports/filesystem"
filesystemcontracts "github.com/adamluzsi/frameless/ports/filesystem/filesystemcontracts"
"github.com/adamluzsi/frameless/adapter... |
// Copyright 2021 - 2021 The goword Authors. All rights reserved. Use of
// this source code is governed by a MIT license that can be found in
// the LICENSE file.
//
// Package goword providing a set of functions that allow you to write to
// and read from DOCX files. Supports reading and writing
// wordprocessing doc... |
// 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"
// DatatypeGeoShape Geo Datatype facilitates the indexing of and searching with arbitrary
// geo shapes such as rectangles and poly... |
package camt053
import (
"io"
)
type PaymentReceived struct {
Id string
Amount string
Comment string
IBAN string
Date string
Name string
}
// Helper function to filter out received payments and translate it to
// an easier parsable format.
// WARN: This parser is Rabobank specific
// https://ww... |
package bot
import (
"errors"
"fmt"
"os"
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestReadConfig(t *testing.T) {
f := filepath.Join(
os.TempDir(),
fmt.Sprintf("feed-bot-testing-%d", time.Now().Nanosecond()),
)
defer os.Remove(f) //nolint: errcheck
t.Run("valid conf... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.