text stringlengths 11 4.05M |
|---|
package main
import (
"flag"
"fmt"
"log"
"os"
"github.com/slavrd/go-tfev4-backup/helpers"
)
var fpass = flag.String("pass", "", "Encryption password for the backup data. Can also be set via TFE_BACKUP_PASSWORD environment variable.")
var fhost = flag.String("host", "", "Hostname of the tfe instance. E.g. tfe.my... |
package ctx
func MustProvision(ctx *TestContext) func() {
deprovision, err := Provision(ctx)
if err != nil {
panic(err)
}
return deprovision
}
func MustInstall(ctx *TestContext) {
if err := Install(ctx); err != nil {
panic(err)
}
}
|
package leetcode
import (
"fmt"
"testing"
)
func TestLRUCache(t *testing.T) {
obj := Constructor(5)
obj.Put(1, 1)
obj.Put(2, 2)
obj.Put(3, 3)
obj.Put(4, 4)
obj.Put(5, 5)
fmt.Println(obj)
obj.Put(1, 51)
fmt.Println(obj)
obj.Put(6, 6)
fmt.Println(obj)
fmt.Println(obj.Get(4), obj)
}
func TestLRUCache2(... |
package main
import (
"fmt"
"github.com/jack0liu/vastflow"
)
type AttachVolumeRiver struct {
vastflow.River
}
func init() {
vastflow.RegisterStream(new(AttachVolumeRiver))
}
func (r *AttachVolumeRiver) Update(attr *vastflow.RiverAttr) {
attr.CycleInterval = 1
attr.CycleTimes = 3
attr.Durable = true
}
func (... |
/*
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, so... |
package timeseries
import (
"bytes"
"context"
"database/sql"
"encoding/gob"
"fmt"
"log"
"sync/atomic"
"time"
)
// DBQuery is the SQL client.
var DBQuery func(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
// DBExec is the SQL client.
var DBExec func(query string, args ...interface... |
package server
import (
"context"
"encoding/json"
"fmt"
"net/http"
"path"
"strconv"
"strings"
"time"
"../cloudstorage"
"../db"
"../util"
"github.com/google/uuid"
"github.com/gorilla/mux"
"github.com/rs/zerolog/log"
)
type RestFile struct {
ID string `json:"id,omitempty"`
Name ... |
package resource
// Drive holds information about a team drive.
type Drive struct {
ID ID `json:"id"`
Version Version `json:"version"`
DriveData
}
|
package database
/*type postsRepository struct{}
func (pr postsRepository) GetPosts() ([]*model.Post, error) {
panic("implement me")
}
func NewPostsRepository() repository.PostsRepository {
return &postsRepository{}
}*/
|
// Galang - Golang common utilities
// Copyright (c) 2020-present, gakkiiyomi@gamil.com
//
// gakkiyomi is licensed under Mulan PSL v2.
// You can use this software according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of Mulan PSL v2 at:
// http://license.coscl.org.cn/MulanPSL2
//... |
package main
import . "leetcode"
func main() {
}
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func leafSimilar(root1 *TreeNode, root2 *TreeNode) bool {
var travel func(root *TreeNode) []int
travel = func(root *TreeNode) [... |
package matrix
// Matrix represents a two-dimensional array
type Matrix [][]float64
// NewMatrix creates a new matrix
func NewMatrix(rows int, columns int, generator func() float64) Matrix {
r := make(Matrix, rows)
for row := range r {
r[row] = make([]float64, columns)
for column := range r[row] {
r[row][col... |
package binutil
import (
"errors"
"fmt"
)
const minPrintable rune = 0x20
const maxPrintable rune = 0x7e
func StringBytesCheckingAscii(s string) ([]byte, error) {
for _, r := range s {
if r < minPrintable || r > maxPrintable {
return nil, errors.New(
fmt.Sprintf("character %c out of range of printable ASC... |
package core
import (
"github.com/gorilla/websocket"
)
type App struct {
WebSocketUpgrader *websocket.Upgrader
center *Center
config *Config
Twitter *Twitter
Tumblr *Tumblr
}
func NewApp(config *Config) (*App, error) {
twitter, err := NewTwitter(config.Twitter)
if e... |
package login
import (
"github.com/xeha-gmbh/homelab/shared"
)
var (
ErrAuth = shared.ErrorFactory(10)("authentication_error")
)
|
package main
import (
"fmt"
"log"
)
// struct 结构体 关键字 强类型 node json
type User struct {
Name string
Age int
}
type Person struct {
Name string
Age int
}
func main() {
u := User{
Name: "陈方闻",
Age: 18,
} // 声明变量, 并赋值,类推推段
// f 格式化
log.Printf("hello struct %s, age is %d", u.Nam... |
package observe
import (
"context"
"fmt"
"github.com/opentracing/opentracing-go"
"github.com/uber/jaeger-client-go"
"io"
"testing"
)
var testErr = fmt.Errorf("test error")
func newTestTracer() (opentracing.Tracer, io.Closer){
reporter := jaeger.NewInMemoryReporter()
sampler := jaeger.NewConstSampler(true)
... |
package util
import "fmt"
func Log(sign, addr, msg string) string {
if addr == "" {
return fmt.Sprintf("[type : %v act: %v] ", sign, msg)
}
return fmt.Sprintf("[type : %v user: %v act: %v] ", sign, addr, msg)
}
func Loger(sign, msg string) string {
if sign == "api" {
return fmt.Sprintf("< --API-- act: %... |
package test
import "fmt"
func Test() {
fmt.Println("version TWO")
}
|
package main
import (
"fmt"
"time"
"github.com/subchen/gstack/errors"
)
func createFile() error {
return errors.New("file not permission")
}
func writeFile() error {
err := createFile()
if err != nil {
return errors.Wrap(err, "file write error")
}
return nil
}
func main() {
err := writeFile()
fmt.Prin... |
// Copyright (C) 2019 Cisco Systems 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 agr... |
package main
//Create a value and assign it to a variable.
//Print the address of that value.
import "fmt"
func main() {
x := 789
y := &x
fmt.Println(y)
}
|
package task
import "context"
var (
impl Task
)
// Implementor returns the task service implementor.
func Implementor() Task {
return impl
}
// RegisterImplementor registers the task service implementor.
func RegisterImplementor(c Task) {
impl = c
}
type Executor interface {
Execute(context.Context, interface{... |
package cmd
import (
"fmt"
"github.com/bb-orz/gt/libs/libStarter"
"github.com/bb-orz/gt/utils"
"github.com/urfave/cli/v2"
"io"
)
func StarterCommand() *cli.Command {
return &cli.Command{
Name: "starter",
Usage: "Add Goinfras Starter",
UsageText: "gt starter [--name|-n=][StarterName]",
Des... |
package chain
import (
"fmt"
"net"
"sync"
"sync/atomic"
"github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/btcsuite/btcd/rpcclient"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/ticker"
)
const (
// rawBlockZM... |
package testhelpers
import (
"testing"
"github.com/gobuffalo/httptest"
"github.com/ory/viper"
"github.com/ory/kratos/driver"
"github.com/ory/kratos/driver/configuration"
"github.com/ory/kratos/x"
)
func NewKratosServer(t *testing.T, reg driver.Registry) (public, admin *httptest.Server) {
rp := x.NewRouterPu... |
//An interface type is defined as a set of method signatures.
//A value of interface type can hold any value that implements those methods.
package main
import (
intf "github.com/parit90/interfaces/first"
sendf "github.com/parit90/interfaces/second"
)
/*
interfaces has two main uses
1. The first is to use it as a... |
// Copyright 2020 Kuei-chun Chen. All rights reserved.
package mdb
import (
"context"
"os"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
var UnitTestURL = "mongodb://localhost/?replicaSet=replset"
func getMongoClient() *mongo.Client {
var err error
var client *mongo.Client... |
package stringutils
import (
"encoding/hex"
"regexp"
"strings"
)
// RemoveDuplicates removes duplicate strings from the slice.
// Comparision is case-insensitive
func RemoveDuplicates(strs []string) []string {
m := make(map[string]struct{})
var res []string
for _, s := range strs {
ls := strings.ToLower(strin... |
package amelia
import (
"fmt"
"io/ioutil"
"path/filepath"
"time"
)
// User represents a GitHub user.
type User struct {
Login *string `json:"login,omitempty"`
Name *string `json:"name,omitempty"`
}
// GistFilename represents filename on a gist.
type GistFilename string
// GistFile represents a file on a gist... |
package advent
import (
"bufio"
"fmt"
"os"
"strconv"
)
func day1() error {
i, err := os.Open("day1.input")
if err != nil {
return err
}
defer i.Close()
var frequency int
frequencies := []int{}
reach := map[int]int{0: 1}
scanner := bufio.NewScanner(i)
for scanner.Scan() {
i, err := strconv.Atoi(scan... |
package main
import (
"fmt"
"os"
)
func main() {
//os.Open 只读方式打开
//fp,err := os.Open("D:/a.txt")
//os.OpenFile(文件名,打开方式,打开权限)
fp,err := os.OpenFile("D:/a.txt",os.O_RDWR,6)
if err!=nil {
fmt.Println("打开文件失败")
}
fp.WriteString("hello")
fp.WriteAt([]byte("hello"),25)
defer fp.Close()
}
|
// Copyright 2016 The Gem Authors. All rights reserved.
// Use of this source code is governed by a MIT license
// that can be found in the LICENSE file.
package gem
import (
"net"
"os"
"github.com/go-gem/log"
"github.com/go-gem/sessions"
"github.com/valyala/fasthttp"
)
const (
// Gem name
name = "Gem"
// ... |
package dht
import (
"bytes"
"testing"
proto "gx/ipfs/QmdxUuburamoF6zF9qjeQC4WYcWGbWuRmdLacMEsW8ioD8/gogo-protobuf/proto"
recpb "gx/ipfs/QmexPd3srWxHC76gW2p5j5tQvwpPuCoW7b9vFhJ8BRPyh9/go-libp2p-record/pb"
)
func TestCleanRecordSigned(t *testing.T) {
actual := new(recpb.Record)
actual.TimeReceived = "time"
act... |
package main
import (
"fmt"
)
type Person struct {
// Public fields
Name string
Surname string
Age int
// Private field
id string
}
func (person *Person) getFullName() string {
return fmt.Sprintf("%s %s", person.Name, person.Surname)
}
func main() {
var p = Person{"Arturo", "Tarin", 50, "0001"}
println(p... |
package main
import (
"fmt"
)
type veículo struct {
portas int
cor string
}
type caminhonete struct {
veículo
traçãoNasQuatro bool
}
type sedan struct {
veículo
modeloLuxo bool
}
func main() {
carrãodotio := sedan{veículo{4, "abóbora"}, true}
fubicadovô := caminhonete{
veículo: veículo{
portas: 8,... |
/**
* @Author: yanKoo
* @Date: 2019/3/11 10:39
* @Description: main
*/
package main
import (
cfgWs "configs/web_server"
"flag"
"fmt"
"github.com/gin-gonic/gin"
"github.com/lestrrat/go-file-rotatelogs"
"github.com/rifflock/lfshook"
"github.com/sirupsen/logrus"
"github.com/unrolled/secure"
"log"
"net/http"
"... |
package base
import (
"logicdata/entity"
"server"
"server/data/datatype"
"server/share"
)
type Player struct {
server.Callee
}
func (p *Player) OnLoad(self datatype.Entity, typ int) int {
//player := self.(*entity.Player)
if typ == share.LOAD_DB {
}
return 1
}
func (c *Player) OnPropertyChange(self datat... |
package sandbox_tests
import (
"github.com/iotaledger/wasp/packages/solo"
"github.com/iotaledger/wasp/packages/vm/core/testcore/sandbox_tests/test_sandbox_sc"
"github.com/stretchr/testify/require"
"strings"
"testing"
)
func TestPanicFull(t *testing.T) { run2(t, testPanicFull) }
func testPanicFull(t *testing.T, w... |
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanLines)
scanner.Scan()
a := scanner.Text()
scanner.Scan()
b := scanner.Text()
if len(a) < len(b) {
fmt.Print("no")
} else {
fmt.Println("go")
}
}
|
package stateful
import (
"context"
aliceapi "github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/alice/api"
"github.com/yandex-cloud/examples/serverless/alice-shareable-todolist/app/errors"
)
type scenario = func(context.Context, *aliceapi.Request) (*aliceapi.Response, errors.Err)
func (h *... |
//go:build !tinygo
// +build !tinygo
package vugu
import "reflect"
func rvIsZero(rv reflect.Value) bool {
return rv.IsZero()
}
|
package sortfunc
import "testing"
func TestQuickSortArrays(t*testing.T){
// nums := []int{-1,0,1,2,-1,-4}
nums := []int{6,0,1,2,-1,-4}
t.Log(nums)
err := QuickSortArrays(nums)
if err == nil{
t.Log(nums)
}
} |
// Copyright (c) 2017, 0qdk4o. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package domain
import (
"bytes"
"encoding/json"
"strings"
)
// Checkavailable represents operation type
type Checkavailable Cmd
// SplicingURL splice pieces ... |
package clock
import "fmt"
const testVersion = 4
// Clock : Complete the type definition. Pick a suitable data type.
type Clock struct {
hour int
minute int
}
// New creates a new clock
func New(hour, minute int) Clock {
c := Clock{0, 0}
if hour >= 0 && minute >= 0 {
min := minute + (hour * 60)
c = c.Add... |
package main
import (
"codeci/src/util/k8s"
"os"
// "log"
)
func main() {
}
|
package common
import (
"math/big"
)
const (
HGS = "hgs"
HNB = "hnb"
)
type Address [20]byte
type Hash [32]byte
type Transactions []*Transaction
func (h *Hash) GetBytes() []byte {
var m []byte
m = make([]byte, 32)
copy(m, h[:])
return m
}
func (a *Address) SetBytes(b []byte) {
if len(b) > len(a) {
b = b[... |
package leetcode
import (
"reflect"
"testing"
"github.com/ironzhang/leetcode/util"
)
func TestReverseKNodes(t *testing.T) {
tests := []struct {
input []int
k int
output []int
prev []int
next []int
}{
{
input: []int{1, 2, 3},
k: 2,
output: []int{2, 1, 3},
prev: []int{1, ... |
package Controllers
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/james-vaughn/PersonalWebsite/Models"
"github.com/james-vaughn/PersonalWebsite/Services"
)
type GenerativeArtController struct {
PagesService *Services.PagesService
pages []Models.Page
}
const GenerativeArtControllerName = "a... |
package env
// Convenience functions for working with environment variables
import (
"os"
"strconv"
"strings"
)
// Default gets the value of an environment variable or a default if not set
func Default(key string, def string) string {
env := os.Getenv(key)
if env == "" {
return def
}
return env
}
// Bool r... |
package arch
import (
"fmt"
"math"
)
/**
* This file contains the implementations of Chip8 instructions.
*/
// Graphics controls
func (c8 *Chip8) ClearScreen() {
if c8.Debug {
fmt.Println("Executing ClearScreen()")
}
c8.Screen.ClearScreen()
c8.DrawFlag = true
}
func (c8 *Chip8) DrawSprite() {
if c8.De... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/12/11 8:56 上午
# @File : lt_12_整数转罗马数字.go
# @Description :
# @Attention :
*/
package hot100
// func intToRoman(num int) string {
// r := ""
// romans := []string{"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"}
// ints := []int{1000, 9... |
package transport
import (
"bufio"
"bytes"
"context"
"encoding/binary"
"errors"
"io"
"net"
"sync"
"sync/atomic"
"time"
"github.com/tochka/tcached/cache"
)
func NewServer(c cache.Cache, address string) *Server {
return &Server{
Cache: c,
Address: address,
}
}
type Server struct {
Cache cache... |
package main
import (
"context"
"errors"
"os"
"time"
"github.com/aws/aws-lambda-go/lambda"
"github.com/dghubble/go-twitter/twitter"
"github.com/po3rin/qiitter/oauth"
"github.com/po3rin/qiitter/qiita"
"golang.org/x/sync/errgroup"
)
var hash = os.Getenv("HASH_TAG")
func post() error {
var ... |
package lyrics
type backend interface {
init(qartist, qtitle string)
getTrackInfo() (TrackInfo, error)
getLyrics() (string, error)
}
|
// Copyright 2017 Jeff Foley. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package dnssrv
import (
"math/rand"
"net"
"strings"
"time"
"github.com/OWASP/Amass/amass/core"
"github.com/OWASP/Amass/amass/utils"
evbus "github.com/asaskevich/... |
package tanggal
import (
"errors"
"fmt"
"strconv"
"strings"
"time"
)
type Format string
type Timezone string
const (
Hari Format = "hari"
NamaHari Format = "namaHari"
NamaHariDenganKoma Format = "namaHariDenganKoma"
Minggu Format = "minggu"
NamaMinggu Format = "n... |
package json
import (
"io"
"testing"
"github.com/polydawn/refmt/tok/fixtures"
)
func testArray(t *testing.T) {
t.Run("empty array", func(t *testing.T) {
seq := fixtures.SequenceMap["empty array"]
checkCanonical(t, seq, `[]`)
t.Run("decode with extra whitespace", func(t *testing.T) {
checkDecoding(t, seq... |
package hooks
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"sync"
"time"
"github.com/samkreter/go-core/log"
"github.com/sirupsen/logrus"
)
const (
timeFormat = "2006-01-02T15:04:05.000Z07:00"
channelBufferSize = 1024
defaultHTTPClientTimeout = time.Second... |
//go:generate mockgen -destination=./mock/storage_mock.go github.com/nomkhonwaan/myblog/pkg/storage Storage
package storage
import (
"context"
"io"
)
// Storage uses to storing or retrieving file from cloud or remote server
type Storage interface {
Delete(ctx context.Context, path string) error
Download(ctx cont... |
package main
import "fmt"
type T1 struct {
}
type T3 = T1
func (t1 T1) say() {
}
type S struct {
T1
T3
}
func (t3 T3) greeting() (i int){
fmt.Println("xxx.txt")
i=0
return i
}
func main() {
var s S
s.say()
//var t1 T1
//var t3 T3
//
//t1.say()
//t1.greeting()
//
//
//t3.say()
//t3.greeting()... |
package solutions
/*
* @lc app=leetcode id=8 lang=golang
*
* [8] String to Integer (atoi)
*/
/**
Note: Really disappointed with test cases come with this question.
Wasting many hours to handle all the weird edge case but you can't just send a format error.
Worst LeetCode experience ever.
I should have check thumb... |
package messenger
type (
// Field represents a field in facebook graph API
Field string
// Fields is a []Field
Fields []Field
)
// Stringify converts Fields to []string
func (f Fields) Stringify() []string {
var ret []string
for _, i := range f {
ret = append(ret, string(i))
}
return ret
}
// Available fie... |
package Problem0026
func removeDuplicates(nums []int) int {
if len(nums) <= 1 {
return len(nums)
}
res := 1
i := 1
for ; i < len(nums); i++ {
if nums[i] == nums[i-1] {
continue
}
if res != i {
nums[res] = nums[i]
}
res++
}
return res
}
|
package resolvers
import (
"context"
"github.com/syncromatics/kafmesh/internal/graph/generated"
"github.com/syncromatics/kafmesh/internal/graph/model"
"github.com/pkg/errors"
)
//go:generate mockgen -source=./pod.go -destination=./pod_mock_test.go -package=resolvers_test
// PodLoader is the dataloaders for a p... |
package order
import (
"github.com/jinzhu/gorm"
"mall_server/internal/models/wx"
"time"
)
type Order struct {
OrderCode string `json:"order_code"`
ThirdOrderCode string `json:"third_order_code"`
GoodsId int64 `json:"goods_id"`
GoodsName string `json:"goods_name"`
SkuId i... |
package entity
type UmsAdminPermissionRelation struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20) 'id'"`
AdminId int64 `json:"admin_id" xorm:"default NULL BIGINT(20) 'admin_id'"`
PermissionId int64 `json:"permission_id" xorm:"default NULL BIGINT(20) 'permission_id'"`
Type int `json:... |
package vo
// json2go
// https://www.sojson.com/json/json2go.html
// ErrorMsg
type ErrorMsg struct {
Msg string `json:"msg"`
Code int `json:"code"`
}
// Json Server Req GetList
type JSReqGetList struct {
Start int `form:"_start"`
Limit int `form:"_limit"`
Order string `form:"_order"`
Sort string `fo... |
package main
import "fmt"
func runeToByteBoard(rBoard [][]rune) [][]byte {
rows := len(rBoard)
cols := len(rBoard[0])
bBoard := make([][]byte, rows)
for r := 0; r < rows; r++ {
bBoard[r] = make([]byte, cols)
for c := 0; c < cols; c++ {
bBoard[r][c] = byte(rBoard[r][c])
}
}
return bBoard
}
func clea... |
package filehandler
import (
"path/filepath"
"strings"
)
// FileSet stores the file permissions in the hierarchical set
type FileSet struct {
Set map[string]bool
SystemRoot bool
}
// FilePerm stores the permission apply to the file
type FilePerm int
// FilePermWrite / Read / Stat are permissions
const (
... |
package main
import (
"io/ioutil"
"testing"
"github.com/stretchr/testify/assert"
)
func TestEqualFieldsSorted(t *testing.T) {
jsonFileArrayBytes1, _ := ioutil.ReadFile("response-host-1.json")
jsonFileArrayBytes2, _ := ioutil.ReadFile("response-host-2.json")
leftJSON, _ := unmarshal(jsonFileArrayBytes1)
right... |
package main
import "github.com/QisFj/godry/gen/graph"
type Entry []string // one object's different field
type Group []Entry // objects with same type
type Data []Group // objects with different type
func (data Data) Len() int { return len(data) }
func (data Data) Get(i int) graph.LayerI { return data[i] }
func... |
package c34_mitm_diffie_hellman
import (
"crypto/sha1"
"math/big"
"github.com/vodafon/cryptopals/set2/c10_implement_cbc_mode"
)
type MITM struct {
name string
P *big.Int
receiverA Point
receiverB Point
receiverN int
side int
decryptedMessage []byt... |
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"strings"
)
func checkDependencyPr(depUrl string, prUrl string, statusUrl string) {
client := &http.Client{}
req, err := http.NewRequest("GET", depUrl, nil)
if err != nil {
panic(err)
}
req.Header.Add("Authorization", `Basic dGNyYW5kczpiYWlsZ... |
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
// 📝 Github Repository: https://github.com/gofiber/fiber
// 📌 API Documentation: https://docs.gofiber.io
package fiber
import (
"fmt"
"testing"
"github.com/gofiber/fiber/v2/utils"
)
// go test -race -run Test_Path_parseRoute
func Test_Path_... |
package controllers
import (
"nepliteApi/models"
"github.com/astaxie/beego"
"fmt"
"github.com/astaxie/beego/orm"
"crypto/md5"
"github.com/astaxie/beego/logs"
"encoding/json"
"nepliteApi/comm"
)
// 用户权限这里就和 普通的用户表切开,
// 即 : user power 表只有管理者 还有 最高用户, user表就是 普通的消费客户
type UserPowerController struct {
beego... |
package cmd
import (
"github.com/spf13/cobra"
"github.com/root-gg/plik/server/server"
)
// cleanCmd represents all clean command
var cleanCmd = &cobra.Command{
Use: "clean",
Short: "Delete expired upload and files",
Run: clean,
}
func init() {
rootCmd.AddCommand(cleanCmd)
}
func clean(cmd *cobra.Command,... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2021/11/18 1:12 下午
# @File : shell.go
# @Description :
# @Attention :
*/
package sort
// 希尔排序
// 关键: 是插入排序的优化
// 插入排序: 假设之前的都是有序的,步长为1
func shellSort(arr []int) []int {
stride := len(arr)
for stride != 1 {
stride >>= 1
for i := 0; i < stride; i += stride {
... |
package main
import (
"bytes"
"io/ioutil"
"testing"
)
func TestIngressCleanup(t *testing.T) {
testContents, err := ioutil.ReadFile("testdata/ingress-cleaned.yaml")
if err != nil {
t.Errorf("Unexpected error reading test data file: %s", err)
}
cleanedContents := cleanOpenshiftConfigFile("testdata/ingress-ori... |
package pie
import "golang.org/x/exp/constraints"
// Sequence generates all numbers in range or returns nil if params invalid
//
// There are 3 variations to generate:
// 1. [0, n).
// 2. [min, max).
// 3. [min, max) with step.
//
// if len(params) == 1 considered that will be returned slice between 0 and n,
// w... |
package main
import (
"bufio"
"errors"
"fmt"
"os"
"strconv"
"strings"
)
// сюда писать код
// фукция main тоже будет тут
type Stack struct {
Data []int
Last int
Size int
}
func NewStack() *Stack{
return &Stack{make([]int, 0), 0, 0}
}
func (s *Stack) Push(element int) {
s.Data = append(s.Data, element)
... |
// This file was generated for SObject AccountCleanInfo, API Version v43.0 at 2018-07-30 03:47:56.659680394 -0400 EDT m=+43.003900451
package sobjects
import (
"fmt"
"strings"
)
type AccountCleanInfo struct {
BaseSObject
AccountId string `force:",omitempty"`
AccountSite ... |
/*
* Create a new intra-datacenter firewall policy.
*/
package main
import (
"flag"
"fmt"
"os"
"path"
"strings"
"github.com/grrtrr/clcv2"
"github.com/grrtrr/clcv2/clcv2cli"
"github.com/grrtrr/exit"
)
func main() {
var src, dst clcv2.CIDRs
var ports clcv2.PortSpecs
var acct = flag.String("da", "", "Dest... |
package image
import (
"github.com/projecteru2/cli/cmd/utils"
"github.com/urfave/cli/v2"
)
const (
specFileURI = "<spec file uri>"
)
// Command exports image subcommands
func Command() *cli.Command {
return &cli.Command{
Name: "image",
Usage: "image commands",
Subcommands: []*cli.Command{
{
Name: ... |
// package rest gives rest APIs info for sdk/mesher providers
package rest
// path parameters
const (
Id = "id"
Ms = "ms"
Service = "service"
InstanceName = "instanceName"
StatusCode = "StatusCode"
)
// api path
const (
Hello = "/hello"
SayHello = "/sayhello/{id}"
Svc = "/sv... |
package osbuild2
// Stage to copy items from inputs to mount points or the tree. Multiple items
// can be copied. The source and destination is a URL.
type CopyStageOptions struct {
Paths []CopyStagePath `json:"paths"`
}
type CopyStagePath struct {
From string `json:"from"`
To string `json:"to"`
}
func (CopySt... |
package gateway
import (
"dao"
"input"
"github.com/fatih/structs"
)
var albumDao *dao.AlbumDao
func init() {
albumDao = new(dao.AlbumDao)
}
type AlbumGateway struct{}
func (g AlbumGateway) Store(input input.NewAlbum) bool {
mapInput := structs.Map(input)
return albumDao.Store(mapInput)
... |
package main
import (
"context"
"flag"
"fmt"
"net/http"
"os"
"os/signal"
"strconv"
"strings"
"syscall"
"time"
"github.com/azzzak/fakecast/api"
"github.com/azzzak/fakecast/fs"
"github.com/azzzak/fakecast/store"
)
var version string
func main() {
var (
host string = ""
root string = "/fa... |
package common
import (
"fmt"
"os"
)
// ExitWithError exits the program after printing the given error's message.
func ExitWithError(err error) {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
// Message generates a message payload based off a path and expiry time.
func Message(remote, path string, expi... |
package main
import (
"fmt"
"log"
"database/sql"
_ "github.com/lib/pq"
"github.com/jmoiron/sqlx"
"os"
)
const (
host = "localhost"
port = 5432
user = "postgres"
password = "postgres"
dbname = "postgres"
sslmode = "disable"
)
func connect() *sql.DB {
t := "host=%s port=%d user=%s password... |
// Copyright 2018 PingCAP, 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 i... |
package dao
import (
"fmt"
"github.com/xormplus/xorm"
"go.uber.org/zap"
"mix/test/codes"
entity "mix/test/entity/core/transaction"
mapper "mix/test/mapper/core/transaction"
"mix/test/utils/status"
)
func (p *Dao) CreateMember(logger *zap.Logger, session *xorm.Session, item *entity.Member) (id int64, err error... |
// Package microwebhook provides a MicroMDM-emulating webhook
package microwebhook
import (
"net/http"
"time"
"github.com/micromdm/nanomdm/mdm"
)
type MicroWebhook struct {
url string
client *http.Client
}
func New(url string) *MicroWebhook {
return &MicroWebhook{
url: url,
client: http.DefaultClien... |
package machine
import (
"testing"
"github.com/google/go-cmp/cmp"
)
// TestTakeSteps tests rotors' movement using different step and cycle
// sizes.
func TestTakeSteps(t *testing.T) {
for i, test := range []struct {
rotors *Rotors
steps []int
expected [][]int
}{
{
rotors: newTestRotors(
t,
... |
// Copyright (c) 2020 Xiaozhe Yao & AICAMP.CO.,LTD
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package entities
import (
"strings"
"time"
"github.com/BurntSushi/toml"
"github.com/autoai-org/aid/components/cmd/pkg/storage"
"github.com/autoai-org/aid/components/cm... |
package ipproxy
import (
"context"
"sync"
"github.com/google/netstack/tcpip"
"github.com/google/netstack/tcpip/buffer"
"github.com/google/netstack/tcpip/network/ipv4"
"github.com/google/netstack/tcpip/transport/tcp"
"github.com/google/netstack/waiter"
"github.com/getlantern/errors"
"github.com/getlantern/ev... |
package entities
import "fmt"
type Product struct {
Id int64 `json:"id"`
Data string `json:"data"`
Prices int64 `json:"prices"`
}
func (product Product) ToString() string {
return fmt.Sprintf("id: %d\n name: %s\n ", product.Id, product.Data, product.Prices)
}
|
package sdp
import (
"bufio"
"bytes"
"errors"
"fmt"
"io"
"strconv"
"strings"
"time"
)
var (
ErrSyntax = errors.New("syntax error")
ErrInvalid = errors.New("invalid")
)
const (
NetTypeIN = "IN"
AddrType4 = "IP4"
AddrType6 = "IP6"
ModeIncl = "incl"
ModeExcl = "excl"
)
const (
MediaAudio = "audio"
M... |
package main
import "fmt"
//要求
//f1(f2)
func f1(f func()) {
fmt.Println("this is f1")
f()
}
func f2(x, y int) {
fmt.Println("this is f2")
fmt.Println(x + y)
}
func f3(f func(int, int), x, y int) func() {
tmp := func() {
f(x, y)
}
return tmp
}
func main() {
ret := f3(f2, 100, 200)
f1(ret)
var i, j, k in... |
package ovirt
import (
"crypto/tls"
"crypto/x509"
"encoding/pem"
"fmt"
"io"
"net/http"
"os"
"strconv"
"strings"
"github.com/AlecAivazis/survey/v2"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
var errHTTPNotFound = errors.New("http response 404")
// readFile reads a file provided in the args an... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.