text stringlengths 11 4.05M |
|---|
package test
import (
"fmt"
"testing"
"time"
mapset "github.com/deckarep/golang-set"
"github.com/stretchr/testify/assert"
"github.com/fdingiit/matching-algorithms/def"
"github.com/fdingiit/matching-algorithms/matcher/fair"
"github.com/fdingiit/matching-algorithms/matcher/naive"
"github.com/fdingiit/matching... |
package xlsx
import (
"github.com/plandem/ooxml"
"github.com/plandem/xlsx/internal"
"github.com/plandem/xlsx/internal/hash"
"github.com/plandem/xlsx/internal/ml"
"github.com/plandem/xlsx/internal/ml/primitives"
)
//SharedStrings is a higher level object that wraps ml.SharedStrings with functionality
type SharedS... |
package main
import (
"os"
"testing"
)
func TestEnvVarEmptyOk(t *testing.T) {
os.Setenv("MyTestVar", "1")
defer func() {
os.Unsetenv("MyTestVar")
}()
isEmpty := envVarEmpty("MyTestVar")
if isEmpty {
t.Errorf("Variable should have value of 1 , but instead was empty")
}
}
func TestEnvVarEmptyNotOk(t *test... |
package semt
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document04200101 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:semt.042.001.01 Document"`
Message *SecuritiesBalanceTransparencyReportStatusAdviceV01 `xm... |
package group
import (
"context"
"github.com/gookit/gcli/v3"
"github.com/ovrclk/akash/x/deployment/types"
"github.com/ovrclk/akcmd/client"
"github.com/ovrclk/akcmd/flags"
)
func QueryCmd() *gcli.Command {
cmd := &gcli.Command{
Name: "group",
Desc: "Deployment group query commands",
Func: func(cmd *gcli.C... |
package problem0047
import "testing"
func TestPermute(t *testing.T) {
//t.Log(permute([]int{0, 1}))
//t.Log(permute([]int{0, 1, 2}))
//t.Log(permuteUnique([]int{0, 1}))
t.Log(permuteUnique([]int{1, 1, 2}))
}
|
package main
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"net"
"net/http"
"os"
"github.com/Sirupsen/logrus"
"github.com/husobee/vestigo"
"golang.org/x/net/context"
"golang.org/x/net/trace"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
r "gopkg.in/dancan... |
package handlers_test
import (
"errors"
"net/http"
"net/http/httptest"
"github.com/cloudfoundry-incubator/notifications/fakes"
"github.com/cloudfoundry-incubator/notifications/postal"
"github.com/cloudfoundry-incubator/notifications/web/handlers"
"github.com/ryanmoran/stack"
. "github... |
package shell
import (
"io"
"github.com/projecteru2/phistage/common"
"github.com/projecteru2/phistage/executors"
"github.com/projecteru2/phistage/store"
)
type ShellJobExecutorProvider struct {
config *common.Config
store store.Store
}
func NewShellJobExecutorProvider(config *common.Config, store store.Store... |
package api
import (
"context"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
)
// GetEvent returns the current state event in the room or nil.
func GetEvent(ctx context.Context, stateAPI CurrentStateInternalAPI, roomID string, tuple gomatrixserverlib.StateKeyTuple) *gomatrixserverlib.Head... |
package rest
import (
"fmt"
"net/http"
"context"
"github.com/fxnn/deadbox/model"
)
type Server struct {
addr string
server *http.Server
tls TLS
router *router
stopped chan error
}
func NewServer(addr string, tls TLS, drop model.Drop) *Server {
return &Server{addr: addr, tls: tls, router: newRout... |
// Writing a basic HTTP server is easy using the
// `net/http` package.
package main
import (
"bufio"
"fmt"
"log"
"net/http"
)
// A fundamental concept in `net/http` servers is
// *handlers*. A handler is an object implementing the
// `http.Handler` interface. A common way to write
// a handler is by using the `h... |
package aoc2015
import (
"testing"
aoc "github.com/janreggie/aoc/internal"
"github.com/stretchr/testify/assert"
)
func Test_newRacingReindeer(t *testing.T) {
assert := assert.New(t)
tests := []struct {
description string
want racingReindeer
}{
{description: "Comet can fly 14 km/s for 10 seconds, b... |
package Problem0127
func ladderLength(beginWord string, endWord string, words []string) int {
// 把 words 存入字典
// 可以利用快速地添加,删除和查找单词
dict := make(map[string]bool, len(words))
for i := 0; i < len(words); i++ {
dict[words[i]] = true
}
// 删除 dict 中的 beginWord
delete(dict, beginWord)
// queue 用于存放被 trans 到的 word
... |
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
// checkoutCmd represents the checkout command
var checkoutCmd = &cobra.Command{
Use: "checkout",
Short: "checkout is used for file restore",
Long: `checkout is used for file restore`,
Run: checkout,
}
var theirs bool
var ours bool
func init() ... |
package sdl
type SDL_Scancode int32
type SDL_Keycode int32
/**
* \brief General event structure
*/
type SDL_Keysym struct {
Scancode SDL_Scancode
Sym SDL_Keycode
Mod uint16
unused uint16
}
const (
SDL_SCANCODE_UNKNOWN SDL_Scancode = 0
/**
* \name Usage page 0x07
*
* These values are fro... |
package functions
// Unshift adds one or more elements to the beginning of the slice
// and returns the new slice.
func (ss SliceType) Unshift(elements ...ElementType) (unshift SliceType) {
unshift = append(SliceType{}, elements...)
unshift = append(unshift, ss...)
return
}
|
package bpmconverter
import (
"fmt"
"path/filepath"
"strconv"
"strings"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
resource "k8s.io/apimachinery/pkg/api/resource"
qjv1a1 "code.cloudfoundry.org/quarks-job/pkg/kube/apis/quarksjob/v1alpha1"
"code.cloudfoundry.org/quarks-operator/pkg/bosh/bpm"
bdm "co... |
// Example to use GLM C++ library to calculate matrix transformation
//go:generate dllcall -fast if.go ../glmcpp/if.h
package main
import (
"flag"
"fmt"
"log"
)
func main() {
debug := flag.Bool("debug", false, "Debug DLL")
fast := flag.Bool("fast", false, "Debug DLL")
flag.Parse()
var err error
if *debug {
... |
package main
import "./greeting"
func main() {
//message := "Hello Go World!"
//var greeting *string = &message
//var message Salutation = "Hello"
//fmt.Println(message, greeting)
//fmt.Println(message, *greeting)
var s = greeting.Salutation{"Cookie", "Hello"}
greeting.Greet(s, greeting.CreatePrintFunction... |
package entity
type Car struct {
Name string `json:"carro"`
Year int `json:"ano"`
}
func (c *Car) Drive() {
println(c.Name, "andou")
c.Name = "Polo"
}
func (c Car) Cambio() string {
return "manual"
}
|
package main
import (
"io/ioutil"
"log"
"net"
"os"
)
func main() {
tcpAddr, err := net.ResolveTCPAddr("tcp4", "127.0.0.1:8080") //换成www.baidu.com:80试一试
checkError(err)
// fmt.Printf("%v\n", tcpAddr)
log.Printf("%v\n", tcpAddr)
// laddr := &net.TCPAddr{IP: net.ParseIP("192.168.1.102"), Port: 52464, Zone: ""... |
package adapter
import (
"testing"
"github.com/giantswarm/apiextensions/pkg/apis/provider/v1alpha1"
)
func TestAdapterRecordSetsRegularFields(t *testing.T) {
t.Parallel()
testCases := []struct {
description string
customObject v1alpha1.AWSConfig
route53Enabled bool
expectedBa... |
package main
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/zhulik/margelet"
)
type CatHandler struct {
}
func (responder CatHandler) HandleCommand(margelet margelet.MargeletAPI, message tgbotapi.Message) error {
margelet.Send(tgbotapi.NewChatAction(message.Chat.ID, tgbotapi.ChatUploadPhot... |
// You can edit this code!
// Click here and start typing.
// /Users/ati/goprj/goprj tsk.php 2
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"time"
)
func main() {
taskfile := os.Args[1]
sec := os.Args[2]
fmt.Println(os.Args[1])
fmt.Println("Hello, 44")
fmt.Println(os.Executable())
// /User... |
package object
import "time"
// SimplifiedAlbum represents SimplifiedAlbumObject
// Link: https://developer.spotify.com/documentation/web-api/reference/#object-simplifiedalbumobject
type SimplifiedAlbum struct {
Name string `json:"name"`
ID string `json:"id"... |
package gocloudlb
import (
"github.com/gophercloud/gophercloud"
)
func NewLB(client *gophercloud.ProviderClient, eo gophercloud.EndpointOpts) (*gophercloud.ServiceClient, error) {
serviceType := "rax:load-balancer"
eo.ApplyDefaults(serviceType)
url, err := client.EndpointLocator(eo)
if err != nil {
return nil... |
package services
import (
"testing"
"github.com/ne7ermore/gRBAC/models"
"gopkg.in/mgo.v2/bson"
)
func Test_valid(t *testing.T) {
models.Get().Build()
a := "asd"
if bson.IsObjectIdHex(a) {
t.Fatal()
}
b := bson.NewObjectId()
c := b.Hex()
if !bson.IsObjectIdHex(c) {
t.Fatal()
}
users, err := GetUsers... |
package utils
import "fmt"
var debug = false
func Debugf(s string, args ...interface{}) {
if debug {
fmt.Printf("[DEBUG]"+s, args...)
}
}
|
package main
import (
"context"
"github.com/juju/errors"
"github.com/pingcap/tidb/kv"
)
func HandleSet(db kv.Storage, key []byte, value []byte) (interface{}, error) {
txn, err := db.Begin()
if err != nil {
return nil, err
}
defer txn.Rollback()
it, err := SeekPrefix(txn, key)
if err != nil {
return nil... |
/*
* Copyright 2017 StreamSets 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... |
package main
//假设按照升序排序的数组在预先未知的某个点上进行了旋转。例如,数组 [0,1,2,4,5,6,7] 可能变为 [4,5,6,7,0,1,2] 。
//
//请找出其中最小的元素。
//
//
//
//示例 1:
//
//输入:nums = [3,4,5,1,2]
//输出:1
//示例 2:
//
//输入:nums = [4,5,6,7,0,1,2]
//输出:0
//示例 3:
//
//输入:nums = [1]
//输出:1
//
//
//提示:
//
//1 <= nums.length <= 5000
//-5000 <= nums[i] <= 5000
//nums 中的所有整数都是... |
package stitch
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"net/http"
stitchApi "terraform-provider-stitch/stitch/model"
)
// PURPOSE:
// The Source Type object contains the information needed... |
package main
import (
"os"
"log"
"fmt"
"github.com/galdor/go-cmdline"
"github.com/olekukonko/tablewriter"
"github.com/iksday/go-iksday/client"
)
func (this *Application) ProjectIssueReopenAction(args []string) {
// Create args2
args2 := make([]string, len(args)+1)
copy(args2[1:], args[:])
args2[0] = "xday ... |
package todo
import (
"math/rand"
"time"
)
// Todo struct
type Todo struct {
ID uint64 `json:",omitempty"`
Task string `json:""`
IsCompleted bool `json:""`
CreatedAt time.Time `json:",omitempty"`
}
// NewTodo creates a new Todo struct and sets the CreatedAt field to the current tim... |
package main
import (
"fmt"
"log"
"math"
"github.com/nobonobo/joycon"
)
func adjustment(n float32) float32 {
if math.Abs(float64(n)) < 0.2 {
return 0
} else {
return n
}
}
func makeSign(n float32) float32 {
if math.Abs(float64(n)) < 0 {
return -1
} else {
return 1
}
}
func main() {
devices, err ... |
package main
import (
"container/heap"
"fmt"
"sort"
)
func main() {
//["DinnerPlates","push","push","push","push","push",
//"popAtStack","push","push","popAtStack","popAtStack","pop","pop","pop","pop","pop"]
//[[2],[1],[2],[3],[4],[7],
//[8],[20],[21],[0],[2],[],[],[],[],[]]
dp := Constructor(1)
dp.Push(1)
... |
package tstune
import (
"fmt"
"math/rand"
"os"
"os/exec"
"path/filepath"
"testing"
"github.com/timescale/timescaledb-tune/pkg/pgutils"
)
func TestFileExists(t *testing.T) {
existsName := "exists.txt"
errorName := "error.txt"
cases := []struct {
desc string
filename string
want bool
}{
{
... |
package db
// Database constants
const (
// DB name
Name = "url-shortener"
// DB collection
Collection = "urlshorten"
)
|
package types
import (
"time"
)
type Organisation struct {
Id string `json:"id"`
App string `json:"app"`
Name string `json:"name"`
Description string `json:"description"`
Teams []string `json:"teams"`
ImageUrl string `json:"image_url"`
CreatedBy string `js... |
package data
import (
v1 "fxkt.tech/bj21/api/bj21/v1"
"fxkt.tech/bj21/internal/data/logic"
"fxkt.tech/bj21/internal/pkg/json"
)
var emptyjson = []byte("{}")
func (r *bj21Repo) login(txt []byte, srv v1.BlackJack_LogicConnServer) []byte {
var req v1.LoginRequest
json.ToObjectByBytes(txt, &req)
playe... |
package stringutil
import "path/filepath"
func RemoveFilenameExt(fname string) string {
extension := filepath.Ext(fname)
noExtFilename := fname[0 : len(fname)-len(extension)]
return noExtFilename
}
|
package repository
import (
entity "github.com/Surafeljava/Court-Case-Management-System/Entity"
user "github.com/Surafeljava/Court-Case-Management-System/appealUse"
"github.com/jinzhu/gorm"
)
// AppealGormRepo Implements the Repoeitory interface
type AppealGormRepo struct {
conn *gorm.DB
}
// NewAppealGormRepo c... |
package main
// Devops describes a devops query generator.
type Devops interface {
// These are now deprecated
AvgCPUUsageDayByHour(*Query)
AvgCPUUsageWeekByHour(*Query)
AvgCPUUsageMonthByDay(*Query)
// These are now deprecated
AvgMemAvailableDayByHour(*Query)
AvgMemAvailableWeekByHour(*Query)
AvgMemAvailable... |
package dbmng
import ("database/sql"
_ "github.com/go-sql-driver/mysql")
var DB_MANAGER, errglobal = sql.Open("mysql", "root:@tcp(localhost:3306)/webapp")
|
package buffer
import (
"bytes"
"fmt"
"testing"
"github.com/lioneagle/goutil/src/chars"
"github.com/lioneagle/goutil/src/test"
)
func TestBytesBufferWrite(t *testing.T) {
testdata := []struct {
data string
}{
{"abc"},
{"124aadf"},
}
for i, v := range testdata {
v := v
t.Run(fmt.Sprintf("%d", i),... |
package combat
import "github.com/steelx/go-rpg-cgm/world"
type ActorLabel struct {
EquipSlotLabels []string
EquipSlotId []string
ActorStats []string
ItemStats []string
ActorStatLabels []string
ItemStatLabels []string
ActionLabels ActionLabels
EquipSlotTypes map[world.ItemType]string
}
typ... |
package quantum
// A Reg is a "quantum register". It is simply a list of
// distinct qubit indices.
type Reg []int
// Valid ensures that no qubits are repeated in the list
// and that no qubit indices are less than 0.
func (r Reg) Valid() bool {
set := map[int]bool{}
for _, x := range r {
if set[x] || x < 0 {
... |
// Copyright © 2016 Nathan Sharpe <nathanjsharpe@gmail.com>
//
// 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 a... |
package helpers
import (
"github.com/sirupsen/logrus"
"github.com/globalsign/mgo"
)
// HandleDBError handles the error and reconnects if needed.
func HandleDBError(err error) {
logrus.WithFields(logrus.Fields{"err": err}).Error("DB Error")
}
// AddBasicIndex add a ascending index given a list of `keys`. The in... |
package pretty_poly
type StaticError struct {
string
}
func (err StaticError) Error( ) string {
return err.string
}
var (
ErrMisbalancedBits = StaticError { "will not divide an odd-number of bits into two slices." }
ErrOrderArgumentSize = StaticError { "the 'order' argument was too small." }
)
|
/* Construct text/plain MIME messages for use with net/smtp.
*
* Base64 is used as transfer encoding and utf-8 as charset.
*/
package mimemail
import (
"encoding/base64"
"fmt"
"strings"
)
// A recipient or sender address.
type Address struct {
Name string
Email string
}
// Format address for use in headers... |
package example_test
import (
"testing"
"github.com/meidoworks/nekoq-api/rpc/example"
)
func TestEmptyClientFactory_CreateClient(t *testing.T) {
example.ExampleRpcClientUsage()
}
|
package friend
import (
"github.com/gin-gonic/gin"
commands "spapp/src/commands/friend"
helper "spapp/src/common/helpers"
"spapp/src/models/apimodels"
friendmodels "spapp/src/models/apimodels/friend"
)
// Get Common Friends docs
// @Summary Get Common Friends
// @Description As a user, I need an API to retrieve... |
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris aix
package lfile
import (
"io"
"log"
"syscall"
)
func (lf *LockableFile) UseFCNTL() {
lf.unixLockType = FCNTL
}
func (lf *LockableFile) UseFLOCK() {
lf.unixLockType = FLOCK
}
func (lf *LockableFile) lock(exclusive bool) error {
fd := lf.Fd... |
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in the "license" file ... |
package main
import (
"fmt"
"strings"
)
const (
OFFSET = 5
)
func neatPrint(strs [][]string) {
sliceOfStrs := strs[:]
maxL, maxR := maxLeftAndRight(sliceOfStrs)
fmt.Println(strings.Repeat("#", maxL+maxR+OFFSET))
for _, v := range sliceOfStrs {
fmt.Print("#" + padString(v[0], maxL, true))
fmt.Print(" - ")
... |
package ch01
import (
"testing"
)
func TestEx08(t *testing.T) {
for _, c := range []struct {
in []int
want []int
}{
{in: []int{1, 2, 1}, want: []int{2}},
{in: []int{2, 2, 1}, want: []int{}},
{in: []int{3, 2, 1}, want: []int{3}},
{in: []int{3, 2, 1, 8}, want: []int{8, 3}},
{in: []int{3, 2, 1, 8, 7},... |
package models
import "github.com/jinzhu/gorm"
//产品中心
type Product struct {
BaseModel
Name string `json:"name" form:"name"` //产品名称
Code string `json:"code" form:"code"` //产品编号
CategoryId int `json:"category_id" form:"category_id"` //分类
Category *Category `jso... |
package config
const (
DBUser = "postgres"
DBPassword = "password"
DBDatabase = "pokemon"
DBHost = "postgres-db"
DBPort = "5432"
GRPCPort = ":9090"
HTTPPort = ":8080"
DefaultVersionGroupNumb... |
package util
import (
"crypto/md5"
"crypto/sha1"
"encoding/hex"
"fmt"
)
// SHA1 hashes using sha1 algorithm
func SHA1(text string) string {
algorithm := sha1.New()
algorithm.Write([]byte(text))
return hex.EncodeToString(algorithm.Sum(nil))
}
// Md5 32位小写
func Md5(text string) string {
data := []byte(text)
h... |
package main
import "fmt"
func main() {
number1 := 10
number2 := 10
add , sub := addSUb( number1, number2)
fmt.Println("Addition --->" , add , "Substartion--->" , sub)
mul , div := mulDiv( number1, number2)
fmt.Println("Multiplication --->" , mul , "Division--->" , div)
}
/* A function with multiple return ... |
/*
* Copyright © 2018-2022 Software AG, Darmstadt, Germany and/or its licensors
*
* SPDX-License-Identifier: Apache-2.0
*
* 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://... |
package calculator
import (
"testing"
)
func TestValidExpression(t *testing.T) {
expr := "( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )"
expected := 101
result := Evaluate(expr)
if result != expected {
t.Errorf("Evaluating %v resulted in %v, should have been %v", expr, result, expected)
}
}
|
package geoserver
import (
// "encoding/xml"
)
type StyledLayerDescriptor struct {
Version string `xml:"version,attr" json:",omitempty"`
NamedLayer NamedLayer `xml:"NamedLayer" json:",omitempty"`
}
type NamedLayer struct {
Name string `xml:"Name" json:",omitempty"`
UserStyle UserStyles `xml:"U... |
package providers
import (
"io/ioutil"
"strings"
)
func AWS(sysfscheck chan<- string) {
data, err := ioutil.ReadFile("/sys/class/dmi/id/product_version")
if err != nil {
sysfscheck <- ""
}
if strings.Contains(string(data), "amazon") {
sysfscheck <- "aws"
}
sysfscheck <- ""
}
|
package core
import (
"fmt"
)
var VerificationDone = make(chan bool, 1)
var ProgramState map[string]ModeState
func Process() {
var verificationDone = false
defer func() {
VerificationDone <- verificationDone
}()
data, e := MakeInputData()
if e != nil {
fmt.Println("Program input parameter are not appropri... |
/////////////////////////////////////////////////////////////////////
// arataca89@gmail.com
// 20210417
//
// func ToLower(s string) string
//
// Retorna s com todas as letras minúsculas.
//
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(strings.ToLower("Gopher"))
}
// Saí... |
package main
import (
"fmt"
)
func main() {
// reserva 5
paises := make(map[string]string, 5)
fmt.Println(paises)
paises["Mexico"] = "D.F"
paises["Argentina"] = "Buenos Aires"
fmt.Println(paises["Mexico"])
fmt.Println(paises)
//ordena alfabeticamente por la clave
campeonato := map[string]int{
"Barcelona"... |
// Copyright 2022 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 db_file
import (
"bankBigData/BankServerJournal/entity"
"bankBigData/BankServerJournal/table"
"gitee.com/johng/gf/g"
)
func List() (g.List, error) {
db := g.DB(table.PSDBName)
res, err := db.Table(table.ComTaskFile).OrderBy("id desc").Limit(0, 30).All()
return res.ToList(), err
}
func Add(data g.List) ... |
package repositories
import (
"net/http"
"../../domain/repositories"
"../../services"
"../../utils/errors"
"github.com/gin-gonic/gin"
)
func CreateRepo(c *gin.Context) {
var request repositories.CreateRepoRequest
err := c.ShouldBindJSON(&request)
if err != nil {
apiErr := errors.NewBadRequestError("invali... |
package event
import (
"github.com/alexandrevicenzi/go-sse"
"github.com/labstack/echo/v4"
)
type (
Hub struct {
server *sse.Server
}
)
func NewHub() *Hub {
return &Hub{
server: sse.NewServer(&sse.Options{}),
}
}
func (h *Hub) RegisterHandlers(g *echo.Group) {
g.GET("", echo.WrapHandler(h.server))
}
func ... |
package utility
import (
"errors"
"net/http"
"time"
"github.com/gin-gonic/gin"
)
func SetCookie(c *gin.Context, key string, value string) {
expiration := time.Now().Add(365 * 24 * time.Hour)
cookie := http.Cookie{
Name: key,
Value: value,
Expires: expiration,
Path: "/",
}
http.SetCookie(c.Wri... |
package http
import (
"time"
)
const DEFAULT_RESP_TIMEOUT = time.Second * 15
|
package database
import (
"log"
_ "github.com/go-sql-driver/mysql"
"github.com/jmoiron/sqlx"
)
func Connect() *sqlx.DB {
db, err := sqlx.Connect("mysql", "homestead:secret@tcp(localhost:3306)/homestead")
if err != nil {
log.Fatal(err)
}
if err = db.Ping(); err != nil {
panic(err)
}
return db
}
|
// Copyright 2015 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 mathematics
import "fmt"
func ExampleModPow() {
fmt.Println(ModPow(2, 4, 4))
fmt.Println(ModPow(3, 4, 4))
// Output:
// 0
// 1
}
|
package address
import (
"github.com/gomeetups/gomeetups/fixtures"
"github.com/gomeetups/gomeetups/models"
)
// ServiceMemory Address store uses an in memory store
type ServiceMemory struct{}
// GetByGroupID Find all addresses belongs to given group ids..
func (*ServiceMemory) GetByGroupID(groupIds []string) (addr... |
package main
import (
"crypto/sm2"
"crypto/x509"
"encoding/base64"
"fmt"
"gm/util"
)
func main() {
sm2PriKey, err := sm2.GenerateKey()
if err != nil {
fmt.Println(err)
}
fmt.Println("-----------------SM2私钥-----------------")
fmt.Println(sm2PriKey)
pemPriKey, _ := util.PriKeyToPem(sm2PriKey)
fmt.Print... |
package LinkedList
import (
"fmt"
"testing"
)
func TestLinkedList(t *testing.T) {
sample := [][2]interface{}{
{1, 1},
{2, 2},
{3, 3},
}
var l LinkedLister = new(LinkedList)
// for k, v := range sample {
// l.Insert(k, v[0])
// }
l.Insert(0, 0)
l.Insert(0, 1)
l.Insert(0, 2)
fmt.Println(l.Get(1))
... |
package fuctional_options
import (
"crypto/tls"
"time"
)
type Config struct {
Protocol string
Timeout time.Duration
Maxconns int
TLS *tls.Config
}
type Server2 struct {
Addr string
Port int
Conf *Config
}
func NewServer(addr string, port int, conf *Config) (*Server, error) {
//...
return nil, nil
}... |
package main
import "os"
func main() {
a := "Hello"
_ = a
_, err := os.Open("abc.txt")
_ = err
}
|
// Copyright The OpenTelemetry 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 agre... |
package cli
import (
"fmt"
"os"
"os/exec"
"strings"
)
const SERVICE_STRONGSWAN = "ipsec"
const SERVICE_DHCCP = "isc-dhscp-server"
const SERVICE_DNS = "bind9"
const SERVICE_MQTT = "mqtt"
const SERVICE_TFTP = "tftpd-hpa"
const SERVICE_HAPROXY = "haproxy"
const SERVICE_NFINX = "nginx"
const SERVICE_SNORT = "snort"... |
//go:generate reform
package front
import "github.com/empirefox/reform"
type VipRebateType int
const (
TVipRebateUnknown VipRebateType = iota
TVipRebateRebate
TVipRebateReward
)
//reform:cc_member
type VipIntro struct {
ID uint `reform:"id,pk"`
CreatedAt int64 `reform:"create_date"`
HeadImageU... |
/*
Copyright 2020 Dan Molik <dan@hyperspike.io>.
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 models contains the types for schema 'public'.
package models
// GENERATED BY XO. DO NOT EDIT.
import (
"database/sql"
"errors"
"time"
)
// Deployment represents a row from 'public.deployments'.
type Deployment struct {
ID int `json:"id"` // id
ApplicationID sql.NullI... |
package cf
import (
"encoding/json"
"fmt"
)
type CloudControllerOrganization struct {
Guid string
Name string
}
type CloudControllerOrganizationResponse struct {
Metadata struct {
Guid string `json:"guid"`
} `json:"metadata"`
Entity struct {
Name string `json:"name"`
... |
package model
import (
"encoding/json"
"fmt"
"io"
)
type GeneralError struct {
Code int `json:"code"`
Message string `json:"message"`
}
func NewGeneralError(code int, message string) *GeneralError {
return &GeneralError{Code: code, Message: message}
}
func (self *GeneralError) error() string {
return fm... |
package ZFic
import (
"fmt"
"time"
)
func Reap() {
var Dead []string
var Sessions = *Sesses
for s, ses := range Sessions {
if time.Since(ses.Expires) > 0 {
Dead = append(Dead, s)
}
}
if len(Dead) > 0 {
for _, name := range Dead {
delete(Sessions, name)
fmt.Println(name + " has been expired")
}... |
package redis
import (
"fmt"
"github.com/go-redis/redis/v8"
"time"
)
type Client interface {
GetPipelines(targets []interface{}) error
GetPipeline(uid string, target interface{}) error
SavePipeline(uid string, data interface{}) (*PipelineLease, error)
CreatePipeline(uid, owner string, data interface{}) (*Pipel... |
package cosmos
import "context"
// Iterator used to iterate through documents.
type Iterator struct {
continuationToken string
err error
response *Response
next bool
source IteratorFunc
docs *Documents
}
// NewIterator creates iterator instance
func N... |
package cmd
import (
log "github.com/sirupsen/logrus"
)
var logLevel string
func levelStringToLevel(level string) log.Level {
if level == "debug" {
return log.DebugLevel
} else if level == "warning" {
return log.WarnLevel
}
return log.InfoLevel
}
|
package main
import (
"time"
"github.com/birdayz/gstreams"
)
func main() {
g := gstreams.NewStreamThread("my-group", "abc")
g.Start()
time.Sleep(10 * time.Minute)
}
|
package main
import (
"strconv"
)
/**
216. 组合总和 III
找出所有相加之和为 n 的 k 个数的组合。组合中只允许含有 1 - 9 的正整数,并且每种组合中不存在重复的数字。
说明:
- `所有数字都是正整数。`
- `解集不能包含重复的组合。 `
示例1:
```
输入: k = 3, n = 7
输出: [[1,2,4]]
```
示例 2:
```
输入: k = 3, n = 9
输出: [[1,2,6], [1,3,5], [2,3,4]]
```
*/
/**
好吧,还算是写出来了,去重用的还是不好
*/
func CombinationSum3(k int,... |
package xdominion
import (
"fmt"
"strings"
)
const (
OP_Equal = "="
OP_NotEqual = "!="
OP_Inferior = "<="
OP_StrictInferior = "<"
OP_Superior = ">="
OP_StrictSuperior = ">"
OP_Between = "between"
OP_In = "in"
OP_NotIn = "not in"
OP_Like = "l... |
package aws
import (
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/openshift/installer/pkg/rhcos"
"github.com/openshift/installer/pkg/types"
)
// knownPublicRegions is the subset of public AWS regions where RHEL CoreOS images are published.
// This subset does not include supported regions which are found... |
package main
import "fmt"
type food struct {
name string
dollars float32
g Grams
carbs float32
protein float32
fat float32
fiber float32
calories float32
}
func (f *food) String() string {
return fmt.Sprintf("%15s %11.0f %9.0f %10.0f %7.2f %6.0f\n",
f.name,
f.Ne... |
// bridge.go
package main
// typedef void (*cb)(char* extra, char* data);
// void callCb(cb callback, char* extra , char* arg) { // c的回调, go将通过这个函数回调c代码
// callback(extra,arg);
// }
import "C" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.