text stringlengths 11 4.05M |
|---|
package main
func main() {
s := "abc"
println(&s) //&s 取s变量的地址, *(&s) 取s地址的值
s, y := "hello", 20
println(&s, y)
{
s, z := 1000, 30
println(&s, z) //不同代码块的同名变量地址不同
}
}
|
package main
import (
"github.com/kedarnag13/Kalisu_Foundation/Godeps/_workspace/src/github.com/gorilla/mux"
"github.com/kedarnag13/Kalisu_Foundation/api/v1/controllers/account"
"log"
"net/http"
)
func main() {
r := mux.NewRouter() //using regexp = r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHan... |
/*
Package js is a drop-in replacement for syscall/js that provides identical behavior in a WebAssembly
environment, and useful non-functional behavior outside of WebAssembly.
To use it, simply import this package instead of "syscall/js" and use it in exactly the same way.
Your code will compile targeting either wasm ... |
package main
import (
"image"
"testing"
)
func TestAspectRatio(t *testing.T) {
rect := image.Rect(0, 0, 1, 4)
ar := aspectRatio(&rect)
if ar != 0.25 {
t.Errorf("Ratio of %#v is %f, not %f", rect, ar, 0.25)
}
}
func TestHeights(t *testing.T) {
rect := &image.Rectangle{image.Pt(0, 0), image.Pt(0, 10)}
squar... |
package token
func NilTok() *Token {
return &Token{"", "nil", Pos{0, 0}, Pos{0, 0}, 0, nil}
}
// STACK -----------------------------------------------------------------------
type TStack struct {
tos *Token
}
func TokenStack() *TStack {
return &TStack{NilTok()}
}
func (s *TStack) Push(tok *Token) {
tok.Next = ... |
package core
type Service struct {
Name string `yaml:"name"`
Group string `yaml:"group,omitempty"`
URL string `yaml:"url"`
}
|
/*
Copyright 2021 The KubeVela 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, softw... |
package x
// GENERATED BY XO. DO NOT EDIT.
import (
"errors"
"strings"
//"time"
"strconv"
"github.com/jmoiron/sqlx"
)
// (shortname .TableNameGo "err" "res" "sqlstr" "db" "XOLog") -}}//(schema .Schema .Table.TableName) -}}// .TableNameGo}}// NotifyRemoved represents a row from 'sun.notify_removed'.
// Manualy ... |
package main
import "os"
import "fmt"
import "sync"
import "time"
import "sync/atomic"
import "math/rand"
import "path/filepath"
import "github.com/bnclabs/golog"
import "github.com/bmatsuo/lmdb-go/lmdb"
import humanize "github.com/dustin/go-humanize"
func perflmdb() error {
path := lmdbpath()
defer func() {
if ... |
package paperswithcode_go
import "encoding/json"
func (c *Client) sendGetRequest(url string, result interface{}) error {
response, err := c.httpClient.Get(url)
if err != nil {
return err
}
return json.NewDecoder(response.Body).Decode(result)
}
|
package main
import (
"fmt"
"os"
"strconv"
"time"
)
/*
-- Sort.go --
The goal of this is to take a list of numbers in the terminal and sorts them from low to high. It does this using Selection Sort.
In essence what it's going to do is take an array of x numbers and with those x numbers it recursively ... |
package helper
import "math"
// @title InsertionSort
// @des 插入排序,下标从1开始
// 插入排序的思想:拿一个长度大于2的数组,从数组的第二位开始
// 取出第二位作为一个临时值(此时的位置为空),依次与前一位做比较,如果比前一位小,则前一位后挪一个位置(前一位的位置空出),
// 最后这个零时的值放到空位置上。循环对比直到最后一个值
// 算法时间复杂度的计算
// T(n) = an.n+bn+c
func InsertionSort(A map[int]int) map[int]int {
ALen :=len(A) ... |
package settings
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha1"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
"runtime"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/tecnologer/deezer/src/models"
"github.com/tecnologer/go-secrets"
)
//Settings is struct for settings ... |
/*****************************************************************
* Copyright©,2020-2022, email: 279197148@qq.com
* Version: 1.0.0
* @Author: yangtxiang
* @Date: 2020-08-14 12:44
* Description:
*****************************************************************/
package gcontext
import (
"github.com/go-xe2/x/os/xfile... |
package internal
import (
"github.com/confluentinc/confluent-kafka-go/kafka"
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.4.0"
)
// Operation represents a kind of Kafka operation.
type Operation string
const (
// OperationProduce represents a Kafka produce action.
OperationP... |
package main
import (
"github.com/crunchydata/crunchy-postgresql-manager-openshift/admindb"
"github.com/crunchydata/crunchy-postgresql-manager-openshift/collect"
"github.com/crunchydata/crunchy-postgresql-manager-openshift/logit"
"github.com/crunchydata/crunchy-postgresql-manager-openshift/util"
"github.com/prome... |
package bbloom
import (
"bufio"
"fmt"
"log"
"math"
"os"
"testing"
)
var (
wordlist1 [][]byte
n = 1 << 16
bf Bloom
)
func TestMain(m *testing.M) {
file, err := os.Open("words.txt")
if err != nil {
log.Fatal(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
wordlist1 = make([]... |
/*
* @lc app=leetcode.cn id=234 lang=golang
*
* [234] 回文链表
*/
package solution
// @lc code=start
func isPalindrome(head *ListNode) bool {
if head == nil || head.Next == nil {
return true
}
slow, fast := head, head.Next.Next
for fast != nil && fast.Next != nil {
slow = slow.Next
fast = fast.Next.Next
}
... |
/*
Copyright 2019 Dmitry Kolesnikov, 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 l... |
package api
import (
"github.com/gorilla/mux"
"github.com/tech-showcase/covid19-service/config"
"github.com/tech-showcase/covid19-service/endpoint/covid19"
"github.com/tech-showcase/covid19-service/helper"
"github.com/tech-showcase/covid19-service/model"
"github.com/tech-showcase/covid19-service/service"
"githu... |
package main
import (
"image"
"image/color"
"image/draw"
"image/png"
"log"
"os"
)
func switchColor(color *string) {
switch *color {
case "white":
*color = "black"
default:
*color = "white"
}
}
func main() {
boardSize := 400
colors := make(map[string]color.RGBA, 2)
colors["white"] = color.RGBA{255, ... |
package main
import (
"os"
"reflect"
"testing"
)
func TestSortTable(t *testing.T) {
unsortedTable := map[string]int{
"Tarantulas": 6,
"Snakes": 1,
"FC Awesome": 1,
"Lions": 5,
"Grouches": 0,
}
sorted := []tableTeam{
{
teamName: "Tarantulas",
points: 6,
}, {
teamName: "Lions",... |
package atomix
import (
"testing"
)
func TestUint64(t *testing.T) {
a := NewUint64(10)
mustEqual(t, a.String(), "10")
mustEqual(t, a.Load(), uint64(10))
mustEqual(t, a.Add(5), uint64(15))
mustEqual(t, a.Sub(3), uint64(12))
mustEqual(t, a.Inc(), uint64(13))
mustEqual(t, a.Dec(), uint64(12))
mustEqual(t, a... |
// Package goglmath is a lightweight pure Go 3D math package providing essential matrix/vector operations for GL graphics applications.
package goglmath
import (
"errors"
"math"
"reflect"
)
// Matrix4 is a 4x4 matrix.
type Matrix4 struct {
data [16]float32
}
var mat4identity = Matrix4{[16]float32{
1, 0, 0, 0,
... |
package leetcode
/*An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535).
Given a coordinate (sr, sc) representing the starting pixel (row and column) of the flood fill, and a pixel value newColor, "flood fill" the image.
To perform a "flood fill... |
package keys
import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/crypto/keys"
)
func TestGetKeyBaseLocks(t *testing.T) {
dir, err := ioutil.TempDir("", "cosmos-sdk-keys")
require.Nil(t, err)
defer os.RemoveAll(dir)
// Acquire db
kb, err := GetKeyBaseFro... |
package main
import (
"fmt"
)
func main() {
var TimeAmarelo = [5]string{"Fernando", "João", "Lúcia", "Mariana", "Ana"}
var TimeVermelho = [4]string{"Helena", "Jonas", "José", "Juliana"}
fmt.Println("Time Amarelo: ",TimeAmarelo)
fmt.Println("Time Vermelho: ",TimeVermelho)
}
|
package main
import (
"fmt"
"log"
"net"
"github.com/troydai/blocks/echo/proto"
"github.com/troydai/blocks/echo/server"
"google.golang.org/grpc"
)
func main() {
lis, err := net.Listen("tcp", "localhost:5436")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
var opts []grpc.ServerOption
grpcServ... |
package locationSvc
import (
"encoding/json"
"time"
"github.com/BorisBorshevsky/GolangDemos/catapult"
"github.com/BorisBorshevsky/GolangDemos/catapult/addons/cache"
"github.com/BorisBorshevsky/GolangDemos/catapult/addons/cache/cache_provider"
"github.com/BorisBorshevsky/GolangDemos/catapult/addons/circuit-brea... |
package parser
import (
"net/http"
"encoding/json"
"io/ioutil"
"log"
"bytes"
"strings"
"os"
url2 "net/url"
"net/http/httputil"
)
type requestPayloadStruct struct {
ProxyCondition string `json:"proxy_condition"`
}
func requestBodyDecoder(request *http.Request) *json.Decoder {
body,err := ioutil.ReadAll(req... |
/*
package game
модуль transport
модуль для реализации транспортных функций между клиентом и сервером
*/
package game
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net"
"net/http"
)
func getServerInfo(postMethodName string, message *transportData) []byte {
// сообщим серверу имя клиента
message.... |
// This file was generated for SObject UserListViewCriterion, API Version v43.0 at 2018-07-30 03:47:30.778534462 -0400 EDT m=+17.121783356
package sobjects
import (
"fmt"
"strings"
)
type UserListViewCriterion struct {
BaseSObject
ColumnName string `force:",omitempty"`
CreatedById string `force:",omi... |
package main
import (
"os"
"fmt"
"strconv"
"log"
"net/http"
"github.com/gorilla/mux"
)
func handleRequests(PORT int) {
fmt.Printf("listening for requests on port %d ...\n", PORT);
myRouter := mux.NewRouter().StrictSlash(true);
myRouter.HandleFunc("/", homePage).Methods("GET");
myRouter.HandleFunc("/api/{nam... |
package redis
import "gopkg.in/redis.v5"
func Setup() (*redis.Client, error) {
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
DB: 0,
})
_, err := client.Ping().Result()
return client, err
} |
package tests
import (
"fmt"
"testing"
"github.com/cloud-ark/kubeplus/etcd_helper"
"github.com/stretchr/testify/assert"
)
var (
rdr etcd_helper.Etcdreader
wrtr etcd_helper.Etcdwriter
)
func init() {
rdr.EtcdServiceURL = "http://localhost:2379"
wrtr.EtcdServiceURL = "http://localhost:2379"
}
func TestGet(t... |
package main
import (
"crypto/hmac"
"crypto/sha1"
"fmt"
)
// https://tools.ietf.org/html/rfc4226
var doubleDigits = []int{0, 2, 4, 6, 8, 1, 3, 5, 7, 9}
var digitsPower = []int{1, 10, 100, 1000, 10000, 100000, 1000000, 10000000}
func main() {
secret := []byte("12345678901234567890")
codeDigits := 6
for i := 0;... |
package ast
import (
"github.com/graphql-go/graphql/language/kinds"
)
// Document implements Node
type Document struct {
Kind string
Loc *Location
Definitions []Node
}
func NewDocument(d *Document) *Document {
if d == nil {
d = &Document{}
}
return &Document{
Kind: kinds.Document,
... |
package main
import (
"fmt"
"reflect"
)
func split(str string) {
fmt.Println("----------", str, "----------")
}
// 空文字の取り扱い
func stringCheck() {
fmt.Println("stringCack")
s := string("Go tutorial start")
fmt.Println(s)
empty := string("")
fmt.Printf("%s %T %v %d", empty, empty, empty, empty)
fmt.Println(e... |
package main
import "fmt"
type Worker interface {
Work()
}
type Person struct {
name string
age int
}
func (p Person) Work() {
fmt.Println("Person worked!")
}
func FindType(i interface{}) {
switch t := i.(type) {
case string:
fmt.Println("This is string and value : ", i.(string))
case int:
fmt.Println(... |
package main
import (
"fmt"
)
//这个是定义了接口
type Phone interface {
call()
}
//这个是结构体
type NokiaPhone struct {
}
//接口实现方法
func (nokiaPhone NokiaPhone) call() {
fmt.Println("I am Nokia, I can call you!")
}
//结构体
type IPhone struct {
}
func (iPhone IPhone) call() {
fmt.Println("I am iPhone, I can call you!")
}
func... |
package db
var sgID = uint64(2)
var shardID = uint64(1)
|
package api
type ClusterOperation struct {
ClusterId int64 `json:"clusterId"`
OutputSubject string `json:"outputSubject"` // output nats subject where cluster outputs are sent
}
type ClusterCreateResponse struct {
OutputChannel string
}
type TokenForm struct {
Token string `form:"jwt" binding:"Requi... |
package app
import (
"fmt"
"github.com/10gen/realm-cli/internal/cli"
"github.com/10gen/realm-cli/internal/cloud/realm"
"github.com/10gen/realm-cli/internal/terminal"
)
const (
flagDeploymentModelDefault = realm.DeploymentModelGlobal
flagLocationDefault = realm.LocationVirginia
)
type newAppInputs struc... |
package commands
import (
"archive/zip"
"encoding/json"
"fmt"
"io"
"log"
"os"
"testing"
. "github.com/smartystreets/goconvey/convey"
"github.com/spf13/cobra"
)
func createZip(name string, files []string) *os.File {
zipfile, err := os.Create(name)
w := zip.NewWriter(zipfile)
for _, file := range files {
... |
package suites
import (
"context"
"fmt"
"log"
"strings"
"time"
)
// MultiCookieDomainScenario represents a set of tests for multi cookie domain suite.
type MultiCookieDomainScenario struct {
*RodSuite
domain, nextDomain string
cookieNames []string
remember bool
}
// NewMultiCookieDomainScenario ret... |
/*
Copyright The Helm 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, software
distrib... |
package field
import (
"encoding/binary"
"fmt"
"io"
)
// SessionID is the session ID of the track.
type SessionID struct {
header *Header
data []byte
}
// Value returns the session ID.
func (f *SessionID) Value() int {
return int(binary.BigEndian.Uint32(f.data))
}
func (f *SessionID) String() string {
retu... |
package db
import (
"math/rand"
"time"
"github.com/oklog/ulid"
)
var epoch, _ = time.Parse("Jan 2 2006", "Jan 1 2020")
func newUUID() string {
t := time.Unix(0, time.Now().UnixNano()-epoch.UnixNano())
var entropy = ulid.Monotonic(rand.New(rand.NewSource(t.UnixNano())), 0)
return ulid.MustNew(ulid.Timestamp(t)... |
package resolver
import (
"fmt"
"github.com/dalloriam/websynth/app/audio"
"github.com/dalloriam/synthia/core"
)
type MixerResolver struct {
sys *audio.System
mixer *core.Mixer
}
func (m *MixerResolver) Channel(args struct{ Idx int32 }) (*ChannelResolver, error) {
i := int(args.Idx)
if i >= len(m.mixer.Ch... |
package main
import (
"os"
"pcps/internal/logging"
"pcps/internal/setting"
"pcps/pcpsd"
)
var file *os.File
func init() {
//初始化配置
setting.Setup()
logging.SetLog()
}
func main() {
writerLog := logging.GetWriter()
//启动http服务
pcpsd.StartHTTPServer(writerLog)
}
|
// Copyright 2010 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.
package json
import (
"errors"
)
// RawMessage is a raw encoded JSON value.
// It implements Marshaler and Unmarshaler and can
// be used to delay JSON decod... |
package smallestrangeintegers
import "testing"
func TestFindSmallestRange(t *testing.T) {
got := findSmallestRange([][]int{
[]int{4, 10, 15, 24, 26},
[]int{0, 9, 12, 20},
[]int{5, 18, 22, 30},
})
expected := [2]int{20, 24}
if got != expected {
t.Error("got different from expected", got, expected)
}
}
|
package main
//region Usings
import "github.com/ravendb/ravendb-go-client"
//endregion
func main() {
createDocumentStore()
}
var globalDocumentStore *ravendb.DocumentStore
//region Demo
//region Step_1
var globalDocumentStore *ravendb.DocumentStore
//endregion
//region Step_2
func createDocumentStore() (*raven... |
package dynamo
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
"testing"
)
type ExampleRecord struct {
Id string `dynamo:"id,key"`
ExternalId string `dynamo:"external_id,idx|external_id-group_key"`
GroupKey string `dynamo:"group_key,idx|external_id-group_ke... |
package main
import (
"fmt"
"strings"
"github.com/reconquest/karma-go"
)
type Tree struct {
Package string
Nested []*Tree
}
func handleTree(withTests bool) error {
packages, err := listPackages()
if err != nil {
return karma.Format(
err,
"unable to list packages",
)
}
var inRoot bool
if len(pa... |
package repositories
import (
"fmt"
"forum/internal/pkg/capsule"
"forum/pkg/model"
"gorm.io/gorm"
)
type forumRepository struct {
db *gorm.DB
}
func newForumRepository() *forumRepository {
return &forumRepository{
db: capsule.DBConn(),
}
}
var ForumRepository = newForumRepository()
func (f *forumReposito... |
/*
* Copyright (c) 2020. Ant Group. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
package stargz
import "strings"
type digest string
func (d digest) String() string {
return string(d)
}
func (d digest) Sha256() string {
pair := strings.Split(string(d), ":")
return pair[1]
}
|
package main
import (
"fmt"
"log"
"github.com/valyala/fasthttp"
)
const (
SOCK = "/var/run/appgo.sock"
)
type Server struct {
Type string
}
func (s Server) HandleFastHTTP(ctx *fasthttp.RequestCtx) {
body := "Hello World " + s.Type + "\n"
fmt.Fprint(ctx, body)
}
func main() {
server := Server{}
server.Ty... |
package merchant
import (
"Advance-Golang-Programming/advanced/final/product"
"net/http"
"strconv"
"github.com/gin-gonic/gin"
"github.com/go-delve/delve/pkg/config"
log "github.com/sirupsen/logrus"
)
type merchantService interface {
Register(string, string) (int, error)
Information(int) (Merchant, error)
Ad... |
package cli
// A collection of UTF-8 symbols that work by default in Gnome terminal on
// Debian AND that are specifically useful for UI design.
// https://en.wikipedia.org/wiki/Miscellaneous_Symbols
// https://www.w3schools.com/charsets/ref_html_utf8.asp
// TODO: This will be moved into its own package and called i... |
package server
type OkCancelTextQuestionModel struct {
Title string
Question string
ErrorMessage string
Destination string
Ok string
OkLabel string
Cancel string
CancelLabel string
}
|
package iapclient
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"sync"
"time"
"cloud.google.com/go/compute/metadata"
"github.com/pkg/errors"
"golang.org/x/oauth2/google"
"google.golang.org/api/iam/v1"
)
const (
iamScope = "https://www.googleapis.com... |
/*
Copyright 2017 Eliott Teissonniere
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, merge,
publish, distribute,... |
package mail
import (
"testing"
)
func TestBuildRawMessage(t *testing.T) {
testCases := []struct {
name string
from, to, subject, msg string
want string
}{
{
"simple",
"src@src.net", "dest@dest.net", "Hello sir", "How are you?",
"From: src@src.net\r\nTo: dest@de... |
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
// This example program allows to set an IP that deviates from the automatically determined interface address.
// Use the "-ip" parameter to set an IP. If not set, the example server defaults to "1.2.3.4".
package main... |
package server
import (
"chlorine/apierror"
"chlorine/auth"
"chlorine/cl"
"chlorine/storage"
"chlorine/ws"
"encoding/json"
"errors"
"github.com/gorilla/mux"
"io/ioutil"
"log"
"net/http"
"strconv"
)
// MemberHandler serve endpoint for creating non-admin member for Chlorine.
type MemberHandler struct {
aut... |
package combat
import (
"log"
"math/rand"
"time"
"github.com/I82Much/rogue/monster"
)
// TODO(ndunn): Figure out how to avoid duplication between monster and player.
type Monster struct {
MaxLife int
Life int
WordsPerMinute int
Words []AttackWord
Type monster.Type
}
var ... |
//
// Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org>
//
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless requir... |
package ssdb
import (
"bytes"
"errors"
"fmt"
"io"
"net"
"strconv"
"strings"
"time"
)
type Client struct {
sock *net.TCPConn
recv_buf bytes.Buffer
seek_start int //the start position to seek '\n\n' for predicating a complete packet.
}
func connect(strAddr string) (*net.TCPConn, error) {
addr, err ... |
/*
1.A Slice is a segment of an array. Slices build on arrays and provide more power,
flexibility, and convenience compared to arrays.
2.Just like arrays, Slices are indexable and have a length.But unlike arrays,
they can be resized.
3.A Slice is just a reference to an underlying array.
4.slices are passed by reference... |
// Copyright 2016-2021, Pulumi Corporation. All rights reserved.
//go:build nodejs || all
// +build nodejs all
package examples
import (
"path/filepath"
"testing"
"github.com/pulumi/pulumi/pkg/v3/testing/integration"
)
func TestSimpleTs(t *testing.T) {
test := getJSBaseOptions(t).
With(integration.ProgramTes... |
// Copyright 2020 MongoDB 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 in... |
package main
import (
"fmt"
"os"
"k8s.io/klog"
"github.com/kpaas-io/volume-exporter/cmd/volume-exporter/app"
)
func main() {
klog.InitFlags(nil)
cmd := app.NewExporterCommand()
if err := cmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
}
|
package mcauth
type Profile struct {
Id string `json:"id"`
PlayerName string `json:"name"`
Legacy bool `json:"legacy,omitempty"`
}
type Account struct {
Login string
AccessToken string `json:"accessToken"`
ClientToken string `json:"clientToken"`
Authenticated bool `json:"-" sql:... |
/*
Copyright 2020 Kamal Nasser 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 law or agreed to in wr... |
package main
import (
"encoding/json"
"io/ioutil"
"os"
"path"
"github.com/brigadecore/brigade-foundations/file"
"github.com/mitchellh/go-homedir"
"github.com/pkg/errors"
)
type config struct {
APIAddress string `json:"apiAddress"`
APIToken string `json:"apiToken"`
IgnoreCertErrors bool `jso... |
package expect
import (
"encoding/json"
"errors"
opa_client "github.com/open-policy-agent/kube-mgmt/pkg/opa"
)
// Client emulates OPA Client API
type Client struct {
PrefixList []string
// This function will be called on every request
actor func(req Request, value interface{}) error
}
// Prefix implements Dat... |
package smhi
import (
"context"
"fmt"
"net/http"
)
// Temperature parameter definitions
const (
TemperatureParameterHourly = 1
TemperatureParameterAverageDaily = 2
TemperatureParameterMinimumDaily = 19
TemperatureParameterMaximumDaily = 20
TemperatureParameterAverageMonthly = 22
... |
package compiler
type exprType int
const (
exprUnkn exprType = iota
exprBool
exprNum
exprStr
exprPath
)
type expr struct {
typ exprType
val interface{}
}
|
package models
import (
"labix.org/v2/mgo/bson"
)
type Cate struct {
Id bson.ObjectId "_id"
CategoryID int "categoryID"
CategoryName string "categoryName"
Description string "description"
} |
/*
* @lc app=leetcode.cn id=151 lang=golang
*
* [151] 翻转字符串里的单词
*/
// @lc code=start
package main
import "strings"
import "fmt"
func removeBlank(s string) string {
var s2 strings.Builder
l := len(s)
for s[l-1] == ' ' {
l--
}
for i := 0; i < l; i++ {
if i == 0 && s[i] == ' ' {
continue
}
if i > 0 ... |
package main
import (
"fmt"
"net"
"net/http"
"time"
)
var url=[]string{
"http://www.baidu.com",
"http://google.com",
"http://taobao.com",
}
func main() {
for _,v:=range url{
c:=http.Client{
Transport:&http.Transport{
Dial: func(network, addr string) (conn net.Conn, e error) {
timeOut:=time.Mic... |
package models
//casbin_rule
type CasbinRule struct {
PType string `json:"p_type" gorm:"column:p_type"`
V0 string `json:"v0" gorm:"column:v0"`
V1 string `json:"v1" gorm:"column:v1"`
V2 string `json:"v2" gorm:"column:v2"`
V3 string `json:"v3" gorm:"column:v3"`
V4 string `json:"v4" gorm:"column:v4"`... |
/*
Copyright 2018 Intel Corporation.
SPDX-License-Identifier: Apache-2.0
*/
package log
import (
"github.com/intel/oim/pkg/log/level"
)
// The LoggerBase struct can be embedded to simplify the implementation
// of a Logger: the implementer then only has to implement the
// three output functions plus With.
type Lo... |
package httpd
// xlattice_go/httpd/siteList.go
import (
"bufio"
"bytes"
"crypto/rsa"
"encoding/base64"
xc "github.com/jddixon/xlCrypto_go"
xb "github.com/jddixon/xlCrypto_go/builds"
"io"
"strings"
)
/**
* Serialized, a site list is a list of Web site names. The names
* must end with a File.separator. Line... |
package do
import "github.com/stretchr/testify/mock"
type MockDigitalOcean struct {
mock.Mock
}
func (_m *MockDigitalOcean) CreateAgent(_a0 *DropletCreateRequest) (*Agent, error) {
ret := _m.Called(_a0)
var r0 *Agent
if rf, ok := ret.Get(0).(func(*DropletCreateRequest) *Agent); ok {
r0 = rf(_a0)
} else {
i... |
package main
import (
"errors"
"fmt"
"testing"
)
func Fibonacci(n int) int {
if n == 0 || n == 1 {
return n
}
return Fibonacci(n-2) + Fibonacci(n-1)
}
func TestHello_Say(t *testing.T) {
a := Fibonacci(10)
t.Log(a)
}
type strA struct {
A int
}
func fp(lst []*strA) {
for i, _ := range lst {
lst[i].A = ... |
package main
import (
"fmt"
"github.com/zenthangplus/gomailer"
)
func main() {
// Create the email client
client := gomailer.Client{
Host: "smtp.example.com",
Port: 465,
Username: "<your-username>",
Password: "<your-password>",
Encryption: gomailer.EncryptionTls,
}
// Create the templ... |
package common
import (
"fmt"
"net/url"
"os"
"path/filepath"
"github.com/connext-cs/pub/logs"
)
func GetAppPath() string {
path, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
fmt.Println("GetAppPath err:", err.Error())
panic(err)
return ""
}
return path
}
func GetWorkPath() string {
w... |
package twitchrouter
import (
"context"
"google.golang.org/grpc"
"io"
"log"
"strconv"
)
type Message struct{
Msg *string
Command *string
Uuid *string
MsgId *string
}
func Send(){
}
func Client(cmd string,help string,accessLevel int32,onMessage func(request *Message, send func(*MessageRequest) error)){
pri... |
package main
import "fmt"
func CreatePhoneNumber(numbers [10]uint) string {
phoneno := "("
for i, num := range numbers {
if i == 3 {
phoneno += ") "
} else if i == 6 {
phoneno += "-"
}
phoneno += fmt.Sprint(num)
}
return phoneno
} |
package main
import (
"fmt"
"net/http"
"time"
)
func main() {
h := http.Client{
Timeout: 1 * time.Second,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
},
}
_, _ = h.Get("http://75.139.38.211:666")
fmt.Println("💀💀💀💀")
}
|
package Memento
import (
"fmt"
"testing"
)
func TestNumber_ReinstateMemento(t *testing.T) {
n := NewNumber(7)
n.Double()
n.Double()
memento := n.CreateMemento() //记录此时是28
n.Half() //一半14
n.ReinstateMemento(memento) //看备忘录里的值
fmt.Println(n.value)
}
|
package docker
import (
"encoding/json"
"fmt"
"path/filepath"
"strconv"
"strings"
"time"
"github.com/Sirupsen/logrus"
"github.com/pkg/errors"
"golang.org/x/net/context"
dTypes "github.com/docker/docker/api/types"
dContainer "github.com/docker/docker/api/types/container"
"github.com/rancher/longhorn-mana... |
/*
Tencent is pleased to support the open source community by making Basic Service Configuration Platform available.
Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except
in compliance with the License. You may obtain... |
package controllers
import (
"encoding/json"
"mall/models"
"mall/utils"
"strconv"
)
// Operations about UmsMemberReceiveAddress
type UmsMemberReceiveAddressController struct {
BaseController
}
// @Title CreateUmsMemberReceiveAddress
// @Description create UmsMemberReceiveAddress
// @Param body body models.Ums... |
package main
import (
"os"
"os/signal"
log "github.com/Sirupsen/logrus"
"github.com/nats-io/nats"
)
const msgSubject = "natssample.pubsub"
func main() {
natsURL := nats.DefaultURL
if h := os.Getenv("NATS_HOST"); len(h) > 0 {
natsURL = "nats://" + h
}
nc, err := nats.Connect(natsURL)
if err != nil {
lo... |
package kamino_test
import (
. "github.com/modcloth/kamino"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"fmt"
"io/ioutil"
"os"
"os/exec"
"github.com/modcloth/go-fileutils"
)
var (
requestedSHA = "df66a4216affe8fe29af354f78e9016781e7bb8e"
nonRequestedSHA = "9830dc808697ba1c7db91df908cb99eb9b30... |
package wire
import (
"bytes"
"encoding/binary"
"io"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/protocol"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoidkFuTUyTXWJPXXFJ/quic-go/internal/utils"
"gx/ipfs/QmU44KWVkSHno7sNDTeUcL4FBgxgoid... |
package main
import "fmt"
type person struct {
name string
friends []*person
}
func main() {
john := person{name: "John"}
paul := person{name: "Paul"}
george := person{name: "George"}
ringo := person{name: "Ringo"}
listFriends(john)
makeFriends(&john, &paul)
makeFriends(&john, &ringo)
makeFriends(&george,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.