text stringlengths 11 4.05M |
|---|
/*
* Copyright 2023 Gravitational, 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 ag... |
package main
import (
"fmt"
"crypto/des"
"crypto/cipher"
"os"
"bytes"
)
func PKCS5Padding(src []byte, blockSize int) []byte {
padding := blockSize - len(src)%blockSize
padtext := bytes.Repeat([]byte{byte(padding)}, padding)
return append(src, padtext...)
}
func PKC... |
package checkers
import (
"fmt"
"github.com/latam-airlines/crane/configuration"
"github.com/latam-airlines/crane/core"
"github.com/latam-airlines/crane/logger"
)
type IntegrityCheck interface {
Id() string
SetNextCheck(check IntegrityCheck)
Next() IntegrityCheck
Check(service core.ServiceConfigurationBuilder)... |
package storage
import (
"fmt"
"os"
"strconv"
"strings"
"k8s-pv-provisioner/cmd/provisioner/config"
v1 "k8s.io/api/core/v1"
"k8s.io/klog"
)
var appConfig = config.GetInstance()
//ChooseBaseNameOfAsset is func which returns the base name of new storagge asset depending on input args
func ChooseBaseNameOfAsse... |
package loadbalancer
import (
"crypto/tls"
"fmt"
"net/http"
"path"
"time"
"github.com/NodeFactoryIo/vedran/internal/actions"
"github.com/NodeFactoryIo/vedran/internal/auth"
"github.com/NodeFactoryIo/vedran/internal/configuration"
"github.com/NodeFactoryIo/vedran/internal/controllers"
"github.com/NodeFactory... |
package log
import (
"flag"
"fmt"
"os"
"time"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
// Console configures logging to output to console in a more readable format.
// This will be slower logging than just using basic JSON output.
// Output is sent to os.Stderr and timestamps are in local time.
fu... |
package nebula
import (
"context"
"crypto/ed25519"
"crypto/rand"
"net"
"testing"
"time"
"github.com/flynn/noise"
"github.com/slackhq/nebula/cert"
"github.com/slackhq/nebula/config"
"github.com/slackhq/nebula/iputil"
"github.com/slackhq/nebula/test"
"github.com/slackhq/nebula/udp"
"github.com/stretchr/tes... |
package defs
type AStruct struct {
ID int
}
|
// Copyright 2016 Albert Nigmatzianov. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package ui
import (
"bytes"
"sort"
"strconv"
"strings"
)
var (
output bytes.Buffer
newlineItem = MenuItem{
Desc: "",
}
quitItem = MenuItem{
... |
package coffeetable
import (
"errors"
"testing"
"github.com/jmcvetta/randutil"
)
func TestGenerateGroups(t *testing.T) {
inputUsers := []User{slackUser("tarik"), slackUser("ali"), slackUser("veli")}
inputRelations := []UserRelation{
UserRelation{User1: "deli", User2: "ali", Encounters: 1},
UserRelation{User... |
package main
import (
"log"
"net/smtp"
)
// Represents an outgoing message.
type Outgoing struct {
From string
To []string
Body string
}
type SMTPLogin struct {
Server string
Ident string
Uname string
Passwd string
}
func doSend(l *SMTPLogin, m *Outgoing) {
server, ident, uname, pass := l.Server, l.Id... |
package db
import (
"context"
"go.mongodb.org/mongo-driver/bson"
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson/primitive"
)
// insert User into mongo
func (c *Database) insertUser(user User) (string, error) {
collection := c.database.Collection("users") // TODO: Un-hardcode this
insertResult, err ... |
package transaction
import (
"bytes"
"encoding/json"
"fmt"
"kto/types"
"kto/until/miscellaneous"
"time"
"github.com/valyala/fasthttp"
"golang.org/x/crypto/ed25519"
"golang.org/x/crypto/sha3"
)
type Transaction struct {
Nonce uint64 `json:"nonce"`
BlockNumber uint64 `json:"blocknumber"`... |
package flopper_test
import (
"io/ioutil"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/vickleford/promex/flopper"
)
func TestOneFlop(t *testing.T) {
fl := flopper.New()
ts := httptes... |
package odoo
import (
"fmt"
)
// MailThread represents mail.thread model.
type MailThread struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
DisplayName *String `xmlrpc:"display_name,omptempty"`
Id *Int `xmlrpc:"id,omptempty"`
MessageChannelId... |
package entry
import (
"shared/common"
"shared/utility/errors"
"shared/utility/transfer"
"sync"
)
type Chapter struct {
Id int32
ChapterType int32
UnlockCondition *common.Conditions `rule:"conditions"`
InitPos *common.Vec2 `rule:"floatsToVec2"`
}
type ChapterReward struct {
Id... |
package main
import (
"github.com/go-pg/pg"
"github.com/go-pg/pg/orm"
)
//database connection settings
func getDatabaseConnection() *pg.DB {
db := pg.Connect(&pg.Options{
User: "postgres",
Addr: "localhost:5432",
Database: "postgres",
})
return db
}
//schema creation
//todo: move to migration
fun... |
// SPDX-License-Identifier: Apache-2.0
package main
func main() {
println("Hello, World!")
}
|
//go:generate protoc -I ./echo --go_out=plugins=grpc:./echo ./echo/echo.proto
package proto
|
package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
// PostsHandler 博客按年月日获取的处理函数
func PostsHandler(c *gin.Context) {
year := c.Param("year")
mon := c.Param("month")
day := c.Param("day")
c.JSON(http.StatusOK, gin.H{
"year": year,
"month": mon,
"day": day,
})
}
// 演示 URL 参数获取
func main() ... |
package Handlers
import (
"github.com/gin-gonic/gin"
"regexp"
"net/http"
)
func Regexp(ctx *gin.Context) {
//判断是不是ip
ip,ok :=ctx.GetQuery("ip")
if !ok {
}
hx :=IsIP(ip)
ctx.JSON(http.StatusSeeOther,gin.H{
"code":203,
"bool":hx,
})
return
}
func IsIP(ip string) (b bool) {
if m, _ := regexp.MatchStrin... |
package main
import (
"errors"
)
var SumFilterWrongFormatError = errors.New("input data must be []int")
type SumFilter struct {
}
func NewSumFilter() *SumFilter {
return &SumFilter{}
}
func (sf *SumFilter) Porcess(data Request) (Response, error) {
parts, ok := data.([]int)
if !ok {
return nil, SumFilterWrong... |
package browsermain
import (
"context"
"errors"
"strings"
"syscall/js"
"capnproto.org/go/capnp/v3/exc"
"zenhack.net/go/jsapi/streams"
"zenhack.net/go/tea"
"zenhack.net/go/tempest/capnp/collection"
"zenhack.net/go/tempest/capnp/external"
"zenhack.net/go/tempest/capnp/util"
"zenhack.net/go/tempest/internal/c... |
package logger
import (
//"errors"
"fmt"
"path"
"runtime"
"strings"
"time"
)
//往终端写日志内容
//type LogLevel uint16
//
//const (
// UNKNOWN LogLevel = iota
// DEBUG
// TRACE
// INFO
// WARING
// ERROR
// FATAL
//)
//
//func parseLogLevel(s string) (LogLevel, error) {
// s = strings.ToLower(s)
// switch s {
// case "... |
package log
import (
"github.com/rs/zerolog"
"github.com/spf13/viper"
"gopkg.in/natefinch/lumberjack.v2"
"time"
)
var(
Logger zerolog.Logger
)
func InitLog(){
Logger=zerolog.New(&lumberjack.Logger{
Filename: viper.GetString("log.path"),
MaxSize: viper.GetInt("log.filemaxsize"),
MaxBackups: viper.GetInt("... |
package main
import (
"strings"
"testing"
)
func TestConfigErrors(t *testing.T) {
cases := []struct {
configLines []string
errorMessage string
}{
{
[]string{""},
"fan options not specified: cooldown time not set, work time not set, schedule time not set",
},
{
[]string{
"[options]",
"c... |
package main
import "fmt"
func main() {
fmt.Println("入り口の近くに「未成年立ち入り禁止」という立札がある。")
var age = 41
var minor = age < 18
fmt.Printf("%v 歳のぼくは、未成年か? %v", age, minor)
}
|
// Copyright 2021 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... |
// Copyright 2022 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 main
import (
"log"
"github.com/trains629/ms/base"
)
func main() {
runner, err := base.NewEtcdRunner()
if err != nil {
log.Fatalln(err)
}
if err := runner.Run(run); err != nil {
log.Println(err)
}
}
|
package individualparsers
import (
"bytes"
"encoding/base64"
)
type Base64HighEntropy struct{}
func (b Base64HighEntropy) Match(content []byte) (bool, error) {
// PE header base64 encoded
base64DecodedContent, err := base64.StdEncoding.DecodeString(string(content))
if err != nil {
return false, nil
}
entro... |
package parser
import (
"github.com/bingo-lang/bingo/ast"
)
func (p *Parser) parseStatement() (statement ast.Statement, err error) {
switch {
case p.tokenIsLBrace():
statement, err = p.parseStatementBlock()
case p.tokenIsLet():
statement, err = p.parseStatementLet()
default:
statement, err = p.parseStateme... |
package main
import (
"image"
"image/color"
"image/png"
//"image/jpeg"
"os"
"sort"
"sync"
)
type rowInImage struct {
y int
img *image.RGBA
}
func (row *rowInImage) Len() int {
return row.img.Bounds().Dx()
}
func (row *rowInImage) Less(i, j int) bool {
return row.img.At(i, row.y).(color.RGBA).R < row.im... |
package problem0886
func possibleBipartition(N int, dislikes [][]int) bool {
adj := make(map[int][]int)
for i := 0; i < len(dislikes); i++ {
adj[dislikes[i][0]] = append(adj[dislikes[i][0]], dislikes[i][1])
adj[dislikes[i][1]] = append(adj[dislikes[i][1]], dislikes[i][0])
}
color := make([]int, N+1)
for i :=... |
package keybindings
import (
"../ds"
"../printout"
"github.com/jroimartin/gocui"
)
func toggle_PomTimer_State(g *gocui.Gui, v *gocui.View) error {
ds.PomTimer.ToggleState()
printout.Timers(g)
return nil
}
func reset_PomTimer(g *gocui.Gui, v *gocui.View) error {
ds.PomTimer.Reset()
printout.Timers(g)
r... |
package heap
import "container/heap"
type IntHeap []int
func (h IntHeap) Len() int {
return len(h)
}
func (h IntHeap) Less(i, j int) bool {
return h[i] < h [j]
}
func (h IntHeap) Swap (i, j int ) {
h[i], h[j] = h[j], h[i]
}
func (h *IntHeap) Push (x interface{}){
*h = append(*h, x.(int))
}
func (h *IntHeap) ... |
package main
import "io"
type strReader string
func (sr *strReader) Read(p []byte) (n int, err error) {
n = copy(p, *sr)
(*sr) = (*sr)[n:]
if len(*sr) == 0 {
err = io.EOF
}
return
}
func newReader(s string) io.Reader {
reader := strReader(s)
return &reader
}
|
package main
import "github.com/spf13/cobra"
type groupCreateFlags struct {
clusterFlags
name string
description string
version string
image string
maxRolling int64
mattermostEnv []string
annotations []string
}
func (flags *groupCreateFlags) addFlags(command *cobra.Command) {
c... |
package main
import (
"fmt"
"sync"
"time"
)
var wC1 sync.WaitGroup
// 无缓冲channel无论发送操作还是接受操作一开始就是阻塞的,只有配对的操作出现才会开始执行
// 有缓冲这会在 已满/已空情况下的发送/接受操作会阻塞
func main() {
wC1.Add(6)
chNoBuffer := make(chan int)
chBuffer1 := make(chan int, 3)
go func() {
defer wC1.Done()
fmt.Println("start consumer nobuffer chan")
... |
package main
import (
config_agent "github.com/eden-framework/configuration_agent"
"github.com/eden-framework/context"
"github.com/eden-framework/eden-framework/pkg/application"
"github.com/eden-framework/plugin-event/event"
"github.com/robotic-framework/robotic-client/internal/global"
"github.com/robotic-framew... |
package router
import (
"MCS_Server/api"
"github.com/gin-gonic/gin"
)
func InitPrescriptionRouter(Router *gin.RouterGroup) {
prescription := Router.Group("prescription")
{
prescription.POST("add",api.AddPrescription)
prescription.POST("submit",api.SubmitPrescription)
prescription.POST("list",api.ListPrescri... |
// +build js
// +build go1.15
package reflect_test
import (
"fmt"
. "reflect"
"strings"
"testing"
)
func TestConvertNaNs(t *testing.T) {
t.Skip()
}
func shouldPanic(expect string, f func()) {
defer func() {
r := recover()
if r == nil {
panic("did not panic")
}
if expect != "" {
var s string
s... |
// Copyright 2020 Trey Dockendorf
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in wri... |
package main
//11. 盛最多水的容器
//给你 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点(i,ai) 。在坐标内画 n 条垂直线,垂直线 i的两个端点分别为(i,ai) 和 (i, 0)。找出其中的两条线,使得它们与x轴共同构成的容器可以容纳最多的水。
//
//说明:你不能倾斜容器,且n的值至少为 2。
//示例:
//
//输入:[1,8,6,2,5,4,8,3,7]
//输出:49
// 思路 滑动窗口,双指针
func maxArea(height []int) int {
l, r := 0, len(height)-1
result := 0
for l < r {
... |
package main
import "os"
type Config struct {
Host string
Port string
MongoDbUri string
MongoDbName string
MongoUsername string
MongoPassword string
}
const defaultHost = "0.0.0.0"
const defaultPort = "8080"
const defaultMongoDbHost = "localhost"
const defaultMongoDbPort = "27017"
const ... |
package main
/*
给定一个只包括 '(',')','{','}','[',']' 的字符串,判断字符串是否有效。
有效字符串需满足:
左括号必须用相同类型的右括号闭合。
左括号必须以正确的顺序闭合。
注意空字符串可被认为是有效字符串。
示例 1:
输入: "()"
输出: true
示例 2:
输入: "()[]{}"
输出: true
示例 3:
输入: "(]"
输出: false
示例 4:
输入: "([)]"
输出: false
示例 5:
输入: "{[]}"
输出: true
*/
func main() {
s := "((()))"
println(isValid(s))
}
... |
package main
import "fmt"
/*
In a given integer array A, we must move every element of A to either list B or list C. (B and C initially start empty.)
Return true if and only if after such a move, it is possible that the average value of B is equal to the average value of C, and B and C are both non-empty.
Example :... |
package combination
/*
Finding all k-combinations of n items without repetion :
The idea of the algorithm used in Combinations is to enumerate all
ths combinations of k indices in lexicographic order.
For example, for an array of n = 5 elements and k = 3 :
0 1 2 <- Initial indices. Third index can be increased.
0 1... |
/*
Created on 2018/5/29 13:49
author: ChenJinLong
Content:
*/
package main
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/http/cookiejar"
)
var JsonContentType = "application/json;charset=utf-8"
const (
loginUrl = ""
)
func main() {
var client http.Client
jar, err := cookiejar.New(nil)
if ... |
package nginx
import (
"crypto/sha1"
"encoding/hex"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"syscall"
"text/template"
"ark/store"
)
// DefaultOptions ...
var DefaultOptions = Options{
Command: "nginx",
ConfigDir: "/etc/nginx/conf.d",
}
const tpl = `
server {
listen {{.Port}};
root /var/www/... |
package main
import (
"fmt"
"log"
"net/http"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
"github.com/trevrosen/git-grabber/controllers"
"github.com/trevrosen/git-grabber/db"
"github.com/trevrosen/git-grabber/middleware"
)
var sdb *db.SqlDB
func main() {
var err error
setConfig()
// TODO: allow... |
package itree
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestNewTimesTree(t *testing.T) {
now := time.Now()
tree, err := NewTimesTree([][]time.Time{
[]time.Time{now.Add(-2 * time.Minute), now.Add(-1 * time.Minute)},
[]time.Time{now.Add(-2 * time.Hour), now.Add(-1 * time.Hour)},
}... |
// Copyright 2017 Sergio Correia
//
// 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 ingress
import (
"bytes"
"context"
"fmt"
"net/netip"
"sync/atomic"
"testing"
"time"
"github.com/google/gopacket/layers"
"github.com/stretchr/testify/require"
"golang.org/x/net/icmp"
"golang.org/x/net/ipv4"
"golang.org/x/net/ipv6"
"github.com/cloudflare/cloudflared/packet"
quicpogs "github.com/c... |
package main
import (
"fmt"
"github.com/streadway/amqp"
)
func main() {
conn, err := amqp.Dial("amqp://guest:guest@localhost:5672/")
if err != nil {
fmt.Println("amqp dial fail:", err)
return
}
defer conn.Close()
rmqch, err := conn.Channel()
if err != nil {
fmt.Println("amqp get channel fail:", err)
... |
package handler
import (
"encoding/binary"
"net"
"github.com/glasnostic/example/router/packet"
"github.com/google/gopacket/layers"
)
func IPv6ToIPv4Len(ip net.IP) []byte {
if len(ip) == net.IPv6len {
return ip[net.IPv6len-net.IPv4len:]
}
return ip
}
func typeOfPacket(meta *packet.Metadata) layers.EthernetT... |
package flow
import (
"encoding/json"
"fmt"
fgutils "github.com/futurehomeno/fimpgo/utils"
"github.com/labstack/gommon/log"
"github.com/thingsplex/tpflow/model"
"github.com/thingsplex/tpflow/utils"
"io/ioutil"
"path/filepath"
"time"
)
type AutoConfig struct {
flow *model.FlowMeta
flowStorage string
}
func... |
package bill
import (
"encoding/json"
"net/http"
"project/database"
"project/packages/handlers/response"
"time"
)
func Update(w http.ResponseWriter, r *http.Request) {
//read body with Claim: Content-Type: application/json
var updateBill database.Bill
err := json.NewDecoder(r.Body).Decode(&updateBill)
if err... |
// Copyright (C) 2019-2020 Zilliz. 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 ytvideo
import (
"log"
"os"
vlc "github.com/adrg/libvlc-go"
ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"
)
//PlayVideo : Function for video playback
func PlayVideo(uri, name string) {
if err := vlc.Init(); err != nil {
log.Fatal(err)
}
defer vlc.Release()
... |
package main
func main() {
var x int
var a [x]int
}
|
package scalars_test
import (
"strings"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
scalars "github.com/nrfta/go-graphql-scalars"
)
type sampleTime struct {
TimeString string
}
var (
correctTime = "2019-06-24"
wrongTime = "2019-06-2435"
)
var _ = Describe("Unmarshal Date Test", func() {... |
package utils
import "github.com/zhaohaijun/matrixchain/common/constants"
var (
TIME_INTERVAL = constants.UNBOUND_TIME_INTERVAL
GENERATION_AMOUNT = constants.UNBOUND_GENERATION_AMOUNT
)
// startOffset : start timestamp offset from genesis block
// endOffset : end timestamp offset from genesis block
func CalcU... |
package datahub_servicebroker
import (
"errors"
"fmt"
//marathon "github.com/gambol99/go-marathon"
//kapi "golang.org/x/build/kubernetes/api"
//"golang.org/x/build/kubernetes"
//"golang.org/x/oauth2"
//"net/http"
//"net"
"github.com/pivotal-cf/brokerapi"
//"time"
"bytes"
"encoding/json"
"strings"
//"cryp... |
package model
type Id struct {
Table string `json:"table"`
ID int `json:"id"`
}
|
/*
Copyright 2021.
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
distributed un... |
package solutions
import (
"sort"
)
func combinationSum2(candidates []int, target int) [][]int {
sort.Ints(candidates)
line := make([]int, 0)
result := make([][]int, 0)
calc(0, target, candidates, line, &result)
return result
}
func calc(index int, target int, candidates []int, line []int,... |
/*
Copyright 2021-2023 ICS-FORTH.
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... |
package main
import (
"bufio"
"fmt"
"log"
"net"
"strings"
"time"
)
func echo() {
server, err := net.Listen("tcp", ":8091")
if err != nil {
log.Fatal(err)
}
for {
conn, err := server.Accept()
if err != nil {
log.Panicln(err)
continue
}
go handleEchoConn(conn)
}
}
func handleEchoConn(c net... |
package rdb
import (
"testing"
)
func TestDump(t *testing.T) {
Dump()
}
|
// Copyright 2020 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 message
//Msg stores the data from RabbitMQ for transport across the pipeline
// Should this be an interface with methods for filling the msg?
type Msg struct {
} |
package helpers
import (
"math"
"strconv"
"time"
)
func hsin(theta float64) float64 {
return math.Pow(math.Sin(theta/2), 2)
}
//DistanceToBuenosAires calculate the distance of LatLng to Buenos Aires, return unit is meters
func DistanceToBuenosAires(lat, lon float64) float64 {
var la1, lo1, la2, lo2, r float64
... |
package main
import (
"bytes"
"log"
"os"
"os/signal"
"strconv"
"time"
"github.com/ajstarks/openvg"
)
func vgfloat(num int) openvg.VGfloat {
return openvg.VGfloat(num)
}
func timeFormat(i int) string {
if i < 10 {
return "0" + strconv.Itoa(i)
}
return strconv.Itoa(i)
}
func genClock(hour, min, sec int)... |
package forms
import (
"fmt"
"net/url"
"regexp"
"strings"
"unicode/utf8"
)
type Form struct {
url.Values
Errors errors
}
//method to initialize a new Form
func New(data url.Values) *Form {
return &Form{
data,
errors(map[string][]string{}),
}
}
// Implement a Required method to check that specific field... |
package suptree
type Service interface {
Serve()
Stop()
}
|
package api
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"github.com/gorilla/mux"
)
type Todo struct {
UserID int `json:"userId"`
ID int `json:"id"`
Title string `json:"title"`
Completed bool `json:"completed"`
}
type Todos []Todo
func GetApi(w http.ResponseW... |
package main
import (
"fmt"
"time"
)
func sleep_routine(nSeconds int) {
fmt.Printf("sleep_routine start, sleep %d seconds ... \n", nSeconds)
time.Sleep(time.Duration(nSeconds) * time.Second)
fmt.Printf("sleep_routine end ... \n")
}
func main() {
go sleep_routine(10)
c := make(chan int, 1)
fmt.Println("sen... |
package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
"reflect"
)
type MySQLOps struct {
mysql *sql.DB
}
type MySQLConfig struct {
username string
password string
network string
server string
port int
database string
}
func GetOps(config MySQLConfig) *MySQLOps {
connectio... |
package main
//func bstToGst(root *TreeNode) *TreeNode {
// sum := 0
// if root.Right == nil {
// return nil
// }
//} |
package service
import (
"context"
microClient "github.com/micro/go-micro/client"
"github.com/plexmediamanager/micro-torrent/proto"
"github.com/plexmediamanager/micro-torrent/torrent"
)
func TorrentList (client microClient.Client) (*torrent.Torrent, error) {
var result *torrent.Torrent
service... |
package istio
import (
"context"
"fmt"
"net"
"strconv"
"strings"
dynatracev1beta1 "github.com/Dynatrace/dynatrace-operator/src/api/v1beta1"
"github.com/Dynatrace/dynatrace-operator/src/kubeobjects"
istio "istio.io/api/networking/v1alpha3"
istiov1alpha3 "istio.io/client-go/pkg/apis/networking/v1alpha3"
istio... |
// SPDX-License-Identifier: Apache-2.0
package main
var importFuncBodies = map[string]string{
// func wasmExit(code int32)
"runtime.wasmExit": ` var code = go.mem.LoadInt32(local0 + 8);
go.exited = true;
go.inst = null;
go.values = null;
go.goRefCounts = null;
go.ids = null;
go.idPool = n... |
package main
import "fmt"
func main() {
const lightSpeed = 299792 // km/s
const secondsPerDay = 86400
var distance int64 = 41.3e12 // km
fmt.Println("アルファ・ケンタウリまでの距離は、", distance, "km.")
var days = distance / lightSpeed / secondsPerDay
fmt.Println("光の速度で、", days, "日かかる。")
// 以下、普通の整数型では扱えない
//distance = 24... |
package main
import (
"github.com/iamanujvrma/gomodtest/common"
cutils "github.com/iamanujvrma/gomodtest/common/utils"
"github.com/iamanujvrma/gomodtest/customer/utils"
)
func main() {
common.PrintHelloWorld()
utils.Len()
cutils.Len2()
}
|
// Copyright 2020 The SwiftShader Authors. 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 b... |
package handler
import (
"context"
"encoding/json"
"github.com/asim/go-micro/v3"
"github.com/asim/go-micro/v3/client"
log "github.com/asim/go-micro/v3/logger"
message "creapptive.com/ims-security/api/message"
"creapptive.com/ims-security/user/repository"
)
type User struct {
repo repository.Interface
... |
package dbschema
type OUI struct {
MAC string `db:"mac"`
Vendor string `db:"vendor"`
}
|
package models
import (
"StatsCollector/models"
"errors"
"time"
"github.com/gliderlabs/ssh"
)
//Agent is the overarching database structure tying all client metrics together
type Agent struct {
ID int64
Name string
PubKey string `gorm:"unique;not null"`
LastTransmiss... |
// Copyright 2020 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... |
// Copyright 2021 Comcast Cable Communications Management, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required ... |
package query
import (
"math"
"testing"
"time"
"github.com/kylelemons/godebug/pretty"
"github.com/pkg/errors"
. "github.com/yuuki/diamondb/pkg/model"
"github.com/yuuki/diamondb/pkg/storage"
)
func TestDoScale(t *testing.T) {
var tests = []struct {
desc string
args []*funcArg
err error
}{
{
"引数1... |
package restruct
import (
"encoding/binary"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
func TestParseTag(t *testing.T) {
tests := []struct {
input string
opts tagOptions
errstr string
}{
// Blank
{"", tagOptions{}, ""},
// Gibberish
{"!#%,1245^#df,little,&~@~@~@~@", tagOptions... |
package controllers
import (
"log"
)
func handle(json string){
log.Println("handling:"+json)
var res string
res=json
h.broadcast<-[]byte(res)
}
|
package ravendb
import "strings"
var _ queryToken = &declareToken{}
type declareToken struct {
name string
parameters string
body string
}
/*
// TODO: why is this unused? Should declareToken be publicly exposed?
func newDeclareToken(name string, body string, parameters string) *declareToken {
return... |
package Game
import (
"github.com/gin-gonic/gin"
"github.com/qiankaihua/ginDemo/Boot/Orm"
"github.com/qiankaihua/ginDemo/Model"
)
func List(c *gin.Context){
db := Orm.GetDB()
var GameInfo []Model.Game
db.Find(&GameInfo)
c.JSON(200,gin.H{"data":GameInfo})
}
|
package dockerimages
import (
"github.com/tilt-dev/tilt/internal/store"
)
func HandleDockerImageUpsertAction(state *store.EngineState, action DockerImageUpsertAction) {
obj := action.DockerImage
n := obj.Name
state.DockerImages[n] = obj
}
func HandleDockerImageDeleteAction(state *store.EngineState, action Docker... |
package models
import(
"encoding/json"
)
/**
* Type definition for Type17Enum enum
*/
type Type17Enum int
/**
* Value collection for Type17Enum enum
*/
const (
Type17_KINSTANCE Type17Enum = 1 + iota
Type17_KDATABASE
Type17_KAAG
Type17_KAAGROOTCONTAINER
Type17_KROOTCONTA... |
package echo
import (
"encoding/json"
"io/ioutil"
"net/http"
)
type Handler struct{}
func (*Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
body, _ := ioutil.ReadAll(r.Body)
res := Response{
Method: r.Method,
URL: r.URL.String(),
Host: r.Host,
Header: r.Header,
Body: body,
}
w.H... |
package main
import (
"flag"
"fmt"
"log"
"os/signal"
"sort"
"strconv"
"strings"
"sync"
"time"
conf "github.com/cyberark/secretless-broker/bin/juxtaposer/config"
"github.com/cyberark/secretless-broker/bin/juxtaposer/formatter"
formatter_api "github.com/cyberark/secretless-broker/bin/juxtaposer/formatter/ap... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.