text stringlengths 11 4.05M |
|---|
package p2pv1
import (
"errors"
"sync"
"github.com/patrickmn/go-cache"
xctx "github.com/xuperchain/xupercore/kernel/common/xcontext"
"github.com/xuperchain/xupercore/kernel/network/p2p"
pb "github.com/xuperchain/xupercore/protos"
)
func (p *P2PServerV1) GetPeerInfo(addresses []string) ([]*pb.PeerInfo, error) {... |
package main
import(
"go_project_ex"
)
func main(){
go_project_ex.Hello()
}
|
package main
import (
"fmt"
"sort"
"strconv"
"strings"
)
/*
A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits
1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order.
The lexicographi... |
package main
import(
"time"
)
type MovimientoInventario struct
{
CodigoMovimiento string `bson:"codigomovimiento"`
TipoMovimiento string `bson:"tipomovimiento"`
CodigoArticulo string `bson:"codigoarticulo"`
Cantidad int32 `bson:"cantidad"`
Fecha time.Time
Unidad string `bson:"unidad"`//lb,caja,etc
}
type Artic... |
package driver
import (
"finance/models"
models_driver "finance/models/driver"
"finance/validator"
)
type DriverIdBase struct {
DriverId uint `json:"driver_id" form:"driver_id" validate:"required" error_message:"驾驶员编号~required:请填写后重试."`
}
func (form *DriverIdBase) GetDriver() *models_driver.FinanceDriver {
var ... |
package configs
import "os"
func ternaryMap(value string, defaultValue string) string {
return map[bool]string{true: value, false: defaultValue}[len(value) != 0]
}
// Envs has values for environment variables and the defaults for them
var Envs = map[string]string{
"PROXY_DESTINATION": ternaryMap(os.Getenv("PROXY_D... |
// Copyright (c) 2016-2019 Uber Technologies, 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... |
package golory
import (
"github.com/1pb-club/golory/log"
)
// Get logger by name
func Logger(name string) *log.Logger {
return gly.components.getLogger(name)
}
|
package app
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"log"
"os"
"sync"
)
var (
instance *App
iOnce sync.Once
)
type App struct {
Bot *tgbotapi.BotAPI
}
func New() (*App, error) {
bot, err := tgbotapi.NewBotAPI(os.Getenv("T_TOKEN"))
if err != nil {
return nil, err
}
log.Printf("Author... |
// Copyright 2019 - 2022 The Samply Community
//
// 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 ... |
package api
import (
"net/http"
"testing"
"github.com/google/go-cmp/cmp"
)
func TestListAlertConditions(t *testing.T) {
c := newTestAPIClient(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write([]byte(`
{... |
package alidns
import (
"fmt"
"net/url"
"testing"
"time"
)
func Test_Sig(t *testing.T) {
var p = url.Values{}
p.Add("akid", "test")
fmt.Println(p.Encode())
//uri:=`Format=XML&AccessKeyId=testid&Action=DescribeDomainRecords&SignatureMethod=HMAC-SHA1&DomainName=example.com&SignatureNonce=f59ed6a9-83fc-473b-... |
package db
import (
"fmt"
"os"
"path"
"path/filepath"
"github.com/go-xorm/core"
"github.com/go-xorm/xorm"
"github.com/zaaksam/dproxy/go/model"
)
// IModel 模型接口
type IModel interface {
TableName() string
NewItems() interface{}
}
// Engine 数据库引擎
var Engine *xorm.Engine
var tables []xorm.TableName
func init(... |
package main
import (
"fmt"
"log"
"os"
"path/filepath"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
type Entity string
const (
Client Entity = ".client"
Project Entity = ".project"
Task Entity = ".task"
)
/*_init ...
Initialize client and project directives
*/
func _init(c *cli.Context) error {
... |
package actions
import (
"errors"
"github.com/LiveSocket/bot/command-service/models"
"github.com/LiveSocket/bot/conv"
"github.com/LiveSocket/bot/service"
"github.com/LiveSocket/bot/service/socket"
"github.com/gammazero/nexus/v3/wamp"
)
// Update Updates a command
//
// public.command.update
// {channel string,... |
package main
import (
"encoding/json"
"fmt"
"net/http"
"time"
"github.com/blend/go-sdk/env"
"github.com/blend/go-sdk/exception"
"github.com/blend/go-sdk/logger"
"github.com/blend/go-sdk/web"
)
func main() {
log := logger.All()
appStart := time.Now()
app := web.NewFromConfig(web.NewConfigFromEnv()).WithL... |
package camo
import (
"math"
"net"
"sync"
)
// IPPool assigns ip addresses
type IPPool interface {
Get(cid string) (net.IP, net.IPMask, bool)
Use(ip net.IP, cid string) (net.IPMask, bool)
Free(net.IP)
Gateway() net.IP
}
// SubnetIPPool assigns ip addresses in a subnet segment.
// Currently supports up to 256 ... |
package PrintElevator
import (
"fmt"
"strconv"
"github.com/TTK4145-Students-2021/project-gruppe48/Elevator"
"github.com/TTK4145-Students-2021/project-gruppe48/Elevio"
)
func Print(numFloors int, e Elevator.ElevatorStates, o Elevator.ElevatorOrders) {
p := fmt.Printf
p(" +--------------------+\n")
... |
package util
import (
"fmt"
"sms-sorter/service/mqtt"
"sms-sorter/service/telegram"
"sms-sorter/util/logger"
"sms-sorter/util/uTime"
"time"
)
func SendFailed(location string, err error) {
t := uTime.GetKST(nil)
msg := fmt.Sprintf("[ERROR/%s]\n=> %s", location, err)
telegram.SendFailedMsg(msg, t)
mqtt.SendF... |
package eoy
import (
"fmt"
"time"
)
//Year is used to provide a primary key for storing stats by year.
type Year struct {
ID int
CreatedDate *time.Time
}
//YearResult holds a year and a stats record.
type YearResult struct {
ID int
Stat
}
//YOYear is used to provide a primary key for storing stats by... |
package main
import "fmt"
type greeting struct {
name string
}
func (g greeting) Greet() {
fmt.Println("你好" + g.name)
}
func Greet() {
fmt.Println("你好")
}
var Greeter greeting
func init() {
Greeter = greeting{
name: "s",
}
}
|
// GENERATED CODE, DO NOT EDIT
package arrowtools
import (
"github.com/apache/arrow/go/arrow"
"github.com/apache/arrow/go/arrow/array"
"github.com/apache/arrow/go/arrow/memory"
)
// ColumnFromUint8Slices returns a pointer to an array.Column value that
// holds the given uint8 data.
func (sh *SliceHelper) Uint8Col... |
package api
import (
"MCS_Server/global"
"MCS_Server/middleware"
"MCS_Server/model/request"
"MCS_Server/model/response"
"MCS_Server/service"
"MCS_Server/utils/verify"
"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
"time"
)
// @Tags 账户
// @Summary 用户登录
// @Security ApiKeyAuth
// @... |
/*
* Copyright 2021 American Express
*
* 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 (
"flag"
"fmt"
"os"
"github.com/unprofession-al/mystrom"
)
func must(err error) {
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func main() {
d := flag.String("d", "", "IP or hostname of the myStrom Switch device")
a := flag.String("a", "toggle", "action to execute, can be [on, off... |
package search
/*
Given a sorted array arr[] of n elements, return the index of a given element x in arr[].
Binary Search: Search a sorted array by repeatedly dividing the search interval in half.
Begin with an interval covering the whole array. If the value of the search key is less
than the item in the middle of th... |
package uiresource
import (
"context"
"fmt"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"sigs.k8s.io/controller-runtime/pkg/cache"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
"github.com/tilt-dev/tilt/internal/controllers/apicmp"
"github.com/tilt-dev/tilt/internal/hud/webview"
"github.com/til... |
package main
import (
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
)
func helloHandler(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "Hello, world!\n")
fmt.Println("-----Method:")
fmt.Println(req.Method)
fmt.Println("")
fmt.Println("-----Header:")
fmt.Println(req.Header)
for k, v := range req... |
package center
import (
"common"
)
func (self *Center) del(table string, key string) (err error) {
return common.Redis_del(self.maincache, table, key)
}
func (self *Center) setInt(table string, key string, value int) (err error) {
return common.Redis_setInt(self.maincache, table, key, value)
}
func (self *Center... |
package api
import "testing"
func TestDefaultStorer(t *testing.T) {
s := &DefaultStorer{}
if _, _, err := s.List(nil, nil, nil); err != ErrNotImplemented {
t.Errorf("List(): expected error ErrNotImplemented, got %v", err)
}
if err := s.Create(nil, nil, nil); err != ErrNotImplemented {
t.Errorf("Create(): exp... |
package handler
import (
"net/http"
jwtConfig "github.com/RudyDamara/golang/lib/jwt"
"github.com/RudyDamara/golang/lib/models"
"github.com/RudyDamara/golang/pkg/user_login/structs"
"github.com/labstack/echo"
)
func (h *HTTPHandler) ToLogout(c echo.Context) error {
dataUser := jwtConfig.GetDataUser(c)
model... |
package persistent
import "time"
type DataQuery struct {
StartDate time.Time
EndDate time.Time
MinCount int
MaxCount int
}
type DataQueryRecord struct {
Key string `bson:"key"`
CreatedAt time.Time `bson:"createdAt"`
TotalCount int `bson:"totalCount"`
}
|
package parser
import (
"errors"
"strings"
)
// ParseClass handles the specific parsing of a package class.
func (p *Parser) ParseClass() (err error) {
// Set one time switches
URLSet := false
GitURLSet := false
HomepageSet := false
token := p.scnr.Peak()
if !token.IsClass() {
return errors.New("called Par... |
// Licensed to Comcast Cable Communications Management, LLC under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Comcast Cable Communications Management, LLC licenses this file to you under
// the Apache Licen... |
// 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 solutions
import (
"sort"
)
func permuteUnique(nums []int) [][]int {
if len(nums) == 0 {
return nil
}
sort.Ints(nums)
result := make([][]int, 0)
backtrackUnique(nums, nil, &result)
return result
}
func backtrackUnique(nums []int, previous []int, result *[][]int) {
... |
package mfcc
import (
"math/rand"
"testing"
)
const fftBenchSize = 512
func TestFFT(t *testing.T) {
inputs := [][]float64{
[]float64{0.517450},
[]float64{0.517450, -0.515357},
[]float64{0.517450, 0.591873, 0.104983, -0.512010},
[]float64{0.517450, 0.591873, 0.104983, -0.512010, -0.037091, 0.203369,
0.4... |
// 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 chain
// names of all chains
const (
Bitmark = "bitmark"
Testing = "testing"
Local = "local"
)
// Valid - validate a chain name
func ... |
package mws
import "encoding/json"
// StsRole is the object that contains cross account role arn and external app id
type StsRole struct {
RoleArn string `json:"role_arn,omitempty"`
ExternalID string `json:"external_id,omitempty"`
}
// AwsCredentials is the object that points to the cross account role
type AwsC... |
package simplepaste
import (
"net/url"
"net/http"
"bytes"
)
//look defines.go
type Paste struct {
Text string
Name string
Privacy string
ExpireDate string
//You have to get it by .GetUserKey method, if you want to create private paste
UserKey string
}
func NewPaste(name string, text string) ... |
package vector
import "testing"
func TestVectorNew(t *testing.T) {
v := New(1, 3, 5)
if len(v.data) != 3 {
t.Error("NewVector failed")
}
}
func TestVectorNormal(t *testing.T) {
v := New(1, 3, 5)
if v.Count() != 3 {
t.Error("VectorNormal 0 failed")
}
if v.data[0] != 1 || v.data[1] != 3 || v.data[2] != 5 {
... |
package main
func main() {
func test() {
}
}
|
package status
import (
"github.com/gorilla/mux"
"github.com/jmoiron/sqlx"
)
// Init - initialize router
func Init(r *mux.Router, db *sqlx.DB) {
r.Methods("GET").Path("/api/status").HandlerFunc(Get(db))
r.Methods("POST").Path("/api/status").HandlerFunc(Insert(db))
r.Methods("PUT").Path("/api/status").HandlerFu... |
package presenters
import "testing"
func TestBuildingANewAttachment(t *testing.T) {
attachment := NewAttachment("Bazinga", "foo", "bar", "#fff", "footer")
if attachment.Title != "Bazinga" {
t.Error("Failed to set attachments title")
}
if attachment.Text != "bar" {
t.Error("Failed to set attachments text")
... |
package net
import (
"bytes"
"testing"
)
var (
testKey = []byte("bbe88b3f4106d354")
testPlaintext = []byte(`{"devId":"002004265ccf7fb1b659","dps":{"1":false,"2":0},"t":1529442366,"s":8}`)
testCiphertext = []byte("3.133ed3d4a21effe90zrA8OK3r3JMiUXpXDWauNppY4Am2c8rZ6sb4Yf15MjM8n5ByDx+QWeCZtcrPqddxLrhm906bS... |
package main
import (
"io/ioutil"
"time"
yaml "gopkg.in/yaml.v2"
)
type Date time.Time
type Config struct {
Birthdays map[string][]Birthday `yaml:"birthdays"`
}
type Birthday struct {
Name string `yaml:"name"`
Date Date `yaml:"date"`
}
func (b *Birthday) Time() time.Time {
return time.Time(b.Date)
}
fun... |
package main
import (
//"crypto/md5"
"database/sql"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
"io/ioutil"
"net/http"
"os"
"strings"
"time"
)
func main() {
fmt.Println("Go access mysql!")
//db, err := sql.Open("mysql", "liminghao:liminghao@tcp(47.89.43.129:3308)/testdb?charset=utf8")
db, e... |
package main
func f() {
}
f()
|
package main
import (
"bufio"
"fmt"
"io/ioutil"
"os"
)
type tape struct {
Source string
Tape [30000]byte
Cursor int
OpenLoops map[int]int
CloseLoops map[int]int
}
func (t *tape) incCursor() {
t.Cursor++
}
func (t *tape) decCursor() {
t.Cursor--
}
func (t *tape) incVal() {
t.Tape[t.Cursor]++
}
func (... |
package wtemplate_test
import (
"testing"
"github.com/okke/wired/wtemplate"
)
type evalContext struct {
variables map[string]string
}
func (evalContext *evalContext) Solve(name string) string {
return evalContext.variables[name]
}
func newEvalContext() wtemplate.Context {
variables := make(map[string]string, ... |
package marshalutil
// Uint8Size contains the amount of bytes of a marshaled uint8 value.
const Uint8Size = 1
// WriteUint8 writes a marshaled uint8 value to the internal buffer.
func (util *MarshalUtil) WriteUint8(value uint8) *MarshalUtil {
writeEndOffset := util.expandWriteCapacity(Uint8Size)
util.bytes[util.wr... |
package play
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/joshprzybyszewski/cribbage/model"
)
func TestPlayersToDealTo(t *testing.T) {
alice := model.Player{
ID: model.PlayerID(`1`),
Name: `alice`,
}
bob := model.Player{
ID: model.PlayerID(`2`),
Name: `bob`,
}
charlie := m... |
package cmd
import (
"fmt"
"io"
"os"
"os/exec"
"github.com/baetyl/baetyl-go/v2/errors"
"github.com/baetyl/baetyl-go/v2/log"
"github.com/baetyl/baetyl-go/v2/utils"
"github.com/kardianos/service"
"github.com/spf13/cobra"
"gopkg.in/natefinch/lumberjack.v2"
)
func init() {
rootCmd.AddCommand(programCmd)
}
va... |
package mvc
import (
"io/ioutil"
"log"
"net/http"
"sync"
)
var luftDaten LuftDatenReading
const (
Last string = "last"
FiveMins string = "5mins"
OneHour string = "1hour"
TwentyFourHours string = "24hours"
)
type LuftDatenReading struct {
lastReading *Welcome
mutLastReading syn... |
package main
import (
"log"
"os/exec"
"strings"
"time"
"gobot.io/x/gobot"
"gobot.io/x/gobot/drivers/gpio"
"gobot.io/x/gobot/platforms/beaglebone"
"gobot.io/x/gobot/platforms/dragonboard"
"gobot.io/x/gobot/platforms/raspi"
)
func main() {
out, err := exec.Command("uname", "-r").Output()
if err !... |
package routers
import (
"festival/app/common/middleware/auth"
"festival/app/common/router"
"festival/app/controller/system"
)
func init() {
g2 := router.New("admin", "/admin/system", auth.Auth)
g2.GET("/users", true, system.UserList)
g2.GET("/user/edit", true, system.UserEdit)
g2.POST("/user/save", true, sys... |
package protectionpolicies
import "github.com/cohesity/management-sdk-go/models"
import "github.com/cohesity/management-sdk-go/configuration"
/*
* Interface for the PROTECTIONPOLICIES_IMPL
*/
type PROTECTIONPOLICIES interface {
GetProtectionPolicyById (string) (*models.ProtectionPolicy, error)
U... |
/*
Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']',
determine if the input string is valid.
The brackets must close in the correct order,
"()" and "()[]{}" are all valid but "(]" and "([)]" are not.
*/
package main
func isValid(s string) bool {
stack, top := make([]... |
package main
import "testing"
type point struct {
x, y int
}
type tuple struct {
a, b, c, d point
}
func TestOverlapping(t *testing.T) {
for k, v := range map[tuple]bool{
tuple{point{-3, 3}, point{-1, 1}, point{1, -1}, point{3, -3}}: false,
tuple{point{-3, 3}, point{-1, 1}, point{-2, 4}, point{2, 2}}: true}... |
package image
import (
gocontext "context"
"fmt"
"net/url"
"runtime"
lxd "github.com/lxc/lxd/client"
lxdapi "github.com/lxc/lxd/shared/api"
"github.com/sirupsen/logrus"
"github.com/travis-ci/worker/context"
"golang.org/x/sync/errgroup"
)
var (
arch = runtime.GOARCH
infra = fmt.Sprintf("lxd-%s", arch)
t... |
package jmodels
// BasicUser базовые поля
type BasicUser struct {
Username string `json:"username"`
PhotoUUID string `json:"photo_uuid"`
}
// InfoUser BasicUser, расширенный служебной инфой
type InfoUser struct {
BasicUser
ID int64 `json:"id"`
Active bool `json:"active"`
}
// ScoredUser инфа о юзере расши... |
// +build go1.9
package sqlmock
import (
"context"
"testing"
)
func TestCustomValueConverterExec(t *testing.T) {
db, mock, _ := New(ValueConverterOption(CustomConverter{}))
expectedQuery := "INSERT INTO tags \\(name,email,age,hobbies\\) VALUES \\(\\?,\\?,\\?,\\?\\)"
query := "INSERT INTO tags (name,email,age,ho... |
package main
//2006. 差的绝对值为 K 的数对数目
//给你一个整数数组nums和一个整数k,请你返回数对(i, j)的数目,满足i < j且|nums[i] - nums[j]| == k。
//
//|x|的值定义为:
//
//如果x >= 0,那么值为x。
//如果x < 0,那么值为-x。
//
//
//示例 1:
//
//输入:nums = [1,2,2,1], k = 1
//输出:4
//解释:差的绝对值为 1 的数对为:
//- [1,2,2,1]
//- [1,2,2,1]
//- [1,2,2,1]
//- [1,2,2,1]
//示例 2:
//
//输入:nums = [1,3],... |
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT License was not distributed with this
// file, you can obtain one at https://opensource.org/licenses/MIT.
//
// Copyright (c) DUSK NETWORK. All rights reserved.
package blindbid
import (
"bytes"
"github.com/dusk-network/du... |
// Package version contains version information
package version
const (
// Version is the software version
Version = "3.11.0-alpha"
)
|
package api
import (
"context"
"fmt"
"github.com/love477/cooking_book/proto/menu"
)
type MenuServer struct {
menu.UnimplementedMenuServer
}
func (menuServer * MenuServer) CreateMenu(ctx context.Context, request *menu.CreateMenuRequest) (*menu.CreateMenuResponse, error) {
fmt.Println("get request from client for... |
package gdash
//FindLastIndex return last slice element index when predicate is true
func FindLastIndex(slice []interface{}, predicate func(interface{}) bool) int {
for i := len(slice) - 1; i >= 0; i-- {
if predicate(slice[i]) {
return i
}
}
return -1
}
|
package signer
import (
"io/ioutil"
"os"
"path"
)
const (
DIRNAME = ".store"
)
type Store interface {
Save(key string, data []byte) error
Delete(key string) error
ReadAll() ([][]byte, error)
}
// Saves key data in files under a given directory
type FileStore struct {
}
func MakeFileStore() (*FileStor... |
package engine
import (
"regexp"
"strings"
)
var re1 = regexp.MustCompile("{[0-9]}*.{[0-9]}*")
var re2 = regexp.MustCompile("({[!-/:-@[-`{-~]}+|{[0-9]}+)+")
type HMM struct {
tagCounts map[string]int64
wordCounts map[string]map[string]int64
tagBigramCounts map[string]... |
package main
import "fmt"
func desc(s1 []int) {
fmt.Printf("s1: %p; Len: %d, Cap: %d; %#v\n", s1, len(s1), cap(s1), s1)
for idx, el := range s1 {
fmt.Println("\t", idx, ":", el)
}
}
func main() {
// s := make([]int, 5)
s := []int{1, 2, 3, 5, 7}
desc(s)
s = s[0:1]
desc(s)
s = s[0:cap(s)]
desc(s)
}
|
package solutions
func letterCombinations(digits string) []string {
if len(digits) == 0 {
return nil
}
result := make([]string, 0)
combinations(&result, digits, "", 0)
return result
}
func combinations(result *[]string, digits string, letters string, i int) {
if i == len(digits) {
... |
package raft
import "github.com/shaneing/go-examples/raft/pb"
type TransportInterface interface {
SendAppendEntries(server Server, request *raftpb.AppendEntriesRequest) (*raftpb.AppendEntriesReply, error)
SendRequestVote(server Server, request *raftpb.RequestVoteRequest) (*raftpb.RequestVoteReply, error)
LocalAddr... |
package metrics
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/tilt-dev/tilt/internal/tiltfile/starkit"
)
func TestMetricsEnabled(t *testing.T) {
f := newFixture(t)
f.File("Tiltfile", "experimental_metrics_settings(enabled=True)")
_, err := f.ExecFile("Tiltfile")
assert.NoError(t, err)
... |
package app
import (
"github.com/kataras/iris"
"../app/configs"
)
type App struct {
}
func New() (app *App) {
return
}
func (app *App) Start() {
irisApp := iris.New()
configs.ConfigureServer(irisApp)
configs.ConfigureRoutes(irisApp)
configs.ConfigureDB()
irisApp.Run(iris.Addr(":8080"), iris.WithoutServerE... |
package main
import (
"fmt"
"gopkg.in/yaml.v2"
)
var e = yaml.Encoder{}
func init() { fmt.Printf("Type: %T\n", e) }
func main() {}
|
//
// Copyright (c) SAS Institute 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 agre... |
package main
import (
"fmt"
)
func main() {
//fmt.Println(check())
//a:=make([]string,10)
a := []string{"a", "b", "c", "d"}
//join := strings.Join(a, "c")
//fmt.Println(join)
VarAgesJoin(a, "aaa", "vvv")
fmt.Println(a)
}
func check(vals ...int) (max, min int) {
if len(vals) == 0 {
return
}
max, min = va... |
package function
func Returnval(a, b int) (int, int, int) {
return a + b, a * b, a - b
}
func Returnval2(a, b int) (sum, mul, diff int) {
sum = a + b
mul = a * b
diff = a - b
return
}
|
package godlutil
import (
"crypto/sha256"
"fmt"
"io"
"path"
"github.com/mitchellh/go-homedir"
)
// GetDownloadDir returns the `godl` download directory
func GetDownloadDir() (string, error) {
home, err := homedir.Dir()
if err != nil {
return "", fmt.Errorf("home directory cannot be detected: %v", err)
}
r... |
package main
import (
"configer/server"
"configer/server/structure"
"fmt"
)
func main() {
a := &structure.A{Name: "wmq"}
exist, err := server.Get(server.NewAer(a))
fmt.Println(a, exist, err)
b := &structure.A{Name: "wxx", Age: 30}
num, err := server.Insert(server.NewAer(b))
fmt.Println(num, err)
}
|
package application
import (
"flag"
"fmt"
"strings"
)
type App struct {
oneOff oneOff
}
type oneOff interface {
Run(oneOffInputs OneOffInputs) error
}
func New(oneOff oneOff) App {
return App{
oneOff: oneOff,
}
}
func (a App) Execute(args []string) error {
oneOffInputs, err := a.parseArgs(args)
if err !... |
package structs
import "math"
type Shape interface {
Area() float64
}
type Rectangle struct {
Width float64
Height float64
}
type Circle struct {
Radius float64
}
type Triangle struct {
Base float64
Height float64
}
type Person struct {
AgeYears int
Name string
Friends []Person
}
func NewPerson() Pers... |
package legs
import (
"context"
dt "github.com/filecoin-project/go-data-transfer"
"github.com/ipfs/go-cid"
"github.com/kenlabs/pando/pkg/metrics"
"sync"
)
type dataTransferRecorder struct {
record map[cid.Cid]func()
lock sync.Mutex
}
var recorder = dataTransferRecorder{
record: make(map[cid.Cid]func()),
l... |
package main
import (
"github.com/cobersky/xlsxconv"
)
func main() {
xlsxconv.Launch()
}
|
package arraysandstrings
func ContainsOnlyUniqueChars(str string) bool {
m := make(map[rune]int)
for _, c := range str {
_, exists := m[c]
if (exists) {
return false
}
m[c] = 1
}
return true
}
func ContainsOnlyUniqueCharsWithoutDataStructure(str string) bool {
var substr string
for... |
package json
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"strings"
formatter_api "github.com/cyberark/secretless-broker/bin/juxtaposer/formatter/api"
"github.com/cyberark/secretless-broker/bin/juxtaposer/formatter/util"
"github.com/cyberark/secretless-broker/bin/juxtaposer/timing"
)
type JsonFormatter s... |
//
// goamz - Go packages to interact with the Amazon Web Services.
//
// https://wiki.ubuntu.com/goamz
//
// Copyright (c) 2011 Canonical Ltd.
//
// Written by Graham Miller <graham.miller@gmail.com>
//
package mturk
import (
"bytes"
"os"
"http"
"url"
"time"
"xml"
"strconv"
"fmt"
"launchpad.net/goamz/aws"
... |
/*
* Copyright (c) 2020. Uriel Márquez All Rights Reserved
* https://umarquez.c0d3.mx
*/
package day1_test
import (
"log"
"main/day1"
"strconv"
"strings"
"testing"
)
var input = `1348
1621
1500
1818
1266
1449
1880
1416
1862
1665
1588
1704
1922
1482
1679
1263
1137
1045
1405
1048
1619
1520
455
1142
1415
1554
1... |
package datastore
import (
"github.com/mongodb/mongo-go-driver/mongo"
)
func IsDuplicateError(err error) bool {
if err, ok := err.(mongo.WriteErrors); ok {
if (err)[0].Code == 11000 {
return true
}
}
return false
}
func IsNotFoundError(err error) bool {
return err.Error() == mongo.ErrNoDocuments.Error()... |
package robot
var move []Point = []Point{
{0, 1},
{1, 0},
{0, -1},
{-1, 0},
}
// Advance goes forward
func Advance() {
Step1Robot.X += move[Step1Robot.Dir].X
Step1Robot.Y += move[Step1Robot.Dir].Y
}
// Right turns right
func Right() {
Step1Robot.Dir = (Step1Robot.Dir + 1) % 4
}
// Left turns left
func Left()... |
package testing
import (
"fmt"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/suite"
"testing"
)
type resourceGroupSuite struct {
terraformOptions *terraform.Options
fixturefolde string
suite.Suite
}
func TestInputOutput(t *testing.T) {
suite.Run(t, new(resourceGroupSu... |
package owplugin
import (
// Please excuse this
"nano/plugins/ow"
"github.com/Krognol/dgofw"
)
func OWOnMessage(m *dgofw.DiscordMessage) {
bt := m.Arg("battletag")
region := m.Arg("region")
if bt == "" || region == "" {
return
}
stats, err := ow.GetStats(bt, region)
if err != nil {
m.Reply("Something h... |
package vault
import (
"bytes"
"crypto/rand"
"errors"
"io"
"io/ioutil"
"os"
"path"
"encoding/gob"
"github.com/NebulousLabs/entropy-mnemonics"
"golang.org/x/crypto/nacl/secretbox"
"golang.org/x/crypto/scrypt"
)
const (
scryptN = 16384
scryptR = 8
scryptP = 1
keyLen = 32
ge... |
package main
func main() {
var y int
for x = 0; x < 10; x++ {
}
}
|
// Package ccaddrepo allows to add a GitHub repository to CodeClimate
// and setup its report id as a CC_TEST_REPORTER_ID secret in the repository.
//
// This two function works together in order to automate the setup of
// a GitHub repository.
//
// If you are using this package in GitHub Actions,
// you can easily pu... |
package main
import (
"io/ioutil"
"encoding/json"
"strconv"
)
type GameJSON struct {
Id int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
HintAttempts int `json:"hint_attempts"`
Questions []struct {
Id int `json:"id"`
Name string `json:"name"`
Text string `json:"text"`
... |
package library
import "fmt"
type nama_mahasiswa struct{
nama string
umur int
}
// Public
func Public(){
var m1 nama_mahasiswa
m1.nama = "Aldo"
m1.umur = 19
var m2 = nama_mahasiswa{"John Mayer", 26}
m1.tampil()
m2.tampil()
}
/* Private
func private(){
var m1 nama_mahasiswa
m1... |
package main
import (
"flag"
"fmt"
"strings"
"github.com/ema/qdisc"
mp "github.com/mackerelio/go-mackerel-plugin"
)
type QdiscPlugin struct {
Prefix string
Interfaces []string
}
func (q QdiscPlugin) GraphDefinition() map[string]mp.Graphs {
return map[string]mp.Graphs{
"#": {
Label: "Qdisc data Sum... |
package main
import (
"fmt"
"time"
"github.com/golang/glog"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
informers "k8s.io/client-go/informers/core/v1"
clientset "k8s.io/client-go/kubernetes"
listers "k8s.io... |
package main
// import "fmt"
func main() {
// var colors map[string]string
color:=map[string]string{
"white":"ffff",
"Green":"ffff0",
"yellow":"dmat",
}
println(color)
delete(color,"yellow")
// delete(color,"white")
mapPrint(color)
}
func mapPrint(c map[string]string) {
for color, hex := range c {
pr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.