text stringlengths 11 4.05M |
|---|
package middlewares
import (
"net/http"
)
func XssProtectMiddleware() Adapter {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-XSS-Protection", "1; mode=block")
w.Header().Set("X-Frame-Options", "deny")
h.ServeHTTP(w, ... |
package brightctl
import (
haikunator "github.com/atrox/haikunatorgo/v2"
"github.com/gorilla/sessions"
"github.com/shihtzu-systems/bright/pkg/ghost"
"github.com/shihtzu-systems/bright/pkg/tower"
log "github.com/sirupsen/logrus"
"net/http"
"path"
)
const (
hackBasePath = "/hack"
)
func HackPath(pieces ...stri... |
package main
// verify the token is valid or not
func verifyToken(token string) bool {
return true
}
|
/*
* 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 leetcode
func containsDuplicate(nums []int) bool {
n := make(map[int]int, len(nums))
for _, op := range nums {
if n[op] != 0 {
return true
}
n[op]++
}
return false
}
|
package leetcode
import (
"testing"
"github.com/go-playground/assert/v2"
. "github.com/summerKK/leetcode-Go/utils"
)
func TestMergeTwoLists(t *testing.T) {
testcases := []struct {
arg0 *ListNode
arg1 *ListNode
except []int
}{
{
arg0: GenLinked([]int{1, 2, 4}),
arg1: GenLinked([]int{1, 3, ... |
package mdproc
import (
"bytes"
"regexp"
"github.com/n0x1m/md2gmi/pipe"
)
// state function.
type stateFn func(*fsm, []byte) stateFn
// state machine.
type fsm struct {
state stateFn
i int
out chan pipe.StreamItem
// combining multiple input lines
multiLineBlockMode int
blockBuffer []byte
sendB... |
package models
type JsonReservationResponse struct {
OK bool `json:"ok"`
Message string `json:"message"`
RoomID string `json:"room_id"`
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
}
|
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"github.com/alecthomas/jsonschema"
)
func check(e error) {
if e != nil {
panic(e)
}
}
var schemaFolder string = "./jsonschemas"
func ensureSchemaFolder() {
if _, err := os.Stat(schemaFolder); os.IsNotExist(err) {
err := os.Mkdir(schemaFolder,... |
package solutions
type BSTIterator struct {
stack []*TreeNode
}
type GraphNode struct {
Val int
Neighbors []*GraphNode
}
type ListNode struct {
Val int
Next *ListNode
}
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
type Node struct {
Val int
Left *Node
... |
package matchmaker
import (
"context"
"log"
"sort"
"sync"
"time"
"github.com/xssnick/wint/pkg/repo"
)
type Repo interface {
CreateGame(ctx context.Context, owner uint64, users []uint64) (uint64, error)
GetGameState(ctx context.Context, user uint64) (repo.MatchState, error)
}
type matchQueue struct {
wantSt... |
package ioutil
import (
"fmt"
"testing"
)
func Test_Uint16(t *testing.T) {
tmp := make([]byte, 2)
for _, bo := range []ByteOrder{LittleEndian, BigEndian} {
var i uint16
for i = 0; i < MaxUint16; i++ {
bo.PutUint16(tmp, i)
i2 := bo.Uint16(tmp)
if i != i2 {
t.Fatalf("expected %d but got %d", i, i... |
package main
import (
"bufio"
"fmt"
"os"
"sort"
"strconv"
)
var in = bufio.NewScanner(os.Stdin)
var n, w, h, max, maxi, elen int
var e [5001][3]int
var dep [5001]int
var prev [5001]int
var ret [5001]int
type Matrix [5001][3]int
func init() {
in.Split(bufio.ScanWords)
for i := range dep {
dep[i] = 1
}
f... |
package main
import (
"bytes"
"fmt"
"sort"
"strings"
)
func main() {
fmt.Println(comma("-12345123154567"))
}
// handles signed/unsigned int and floats
func comma(s string) string {
n := len(s)
const size = 3
sign := 0
var buf bytes.Buffer
if s[0] == '-' {
sign = 1
}
if strings.ContainsRune(s, '.') {
... |
package run
import (
"bufio"
"errors"
"fmt"
"io"
"os"
"os/signal"
"path/filepath"
"regexp"
"strings"
"github.com/pgavlin/warp/go_wasm_exec"
"github.com/pgavlin/warp/load"
"github.com/pgavlin/warp/wasi"
"github.com/spf13/cobra"
)
// [to=]from(,flags)
type preopens struct {
values []wasi.Preopen
strin... |
// generated by wsp, DO NOT EDIT.
package main
import "net/http"
import "time"
import "github.com/simplejia/namesrv/controller/admin"
import "github.com/simplejia/namesrv/controller"
import "github.com/simplejia/namesrv/filter"
func init() {
http.HandleFunc("/admin/relation/create", func(w http.ResponseWriter, r *h... |
// Package retry provides util functions to retry fail actions.
package retry
import (
"context"
"errors"
"time"
)
// ErrNeedRetry is a placholder helper, in case you have no error to return, such as bool status, etc.
var ErrNeedRetry = errors.New("need retry")
// State controls whether the fail action should con... |
package services
import (
"io"
"net/http"
"os"
"path/filepath"
)
//UploadFileService ...
func UploadFileService(w http.ResponseWriter, r *http.Request) {
file, handler, err := r.FormFile("file")
if err != nil {
panic(err)
}
defer file.Close()
// copy example
absPath, _ := filepath.Abs(handler.Filename)
... |
package types
import (
tmbytes "github.com/tendermint/tendermint/libs/bytes"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
QueryDefinition = "definition" // query definition
QueryBinding = "binding" // query binding
QueryBindings = "bindings" // query bindings
... |
package executor
import "errors"
var (
// ErrTaskRejected task was rejected because task queue is reach to max.
ErrTaskRejected = errors.New("executor: task rejected")
// ErrTaskCanceled task was canceled by timeout or by caller (with context.Context).
ErrTaskCanceled = errors.New("executor: task canceled")
)
t... |
/*
Copyright 2021 The Skaffold 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, sof... |
package controllers
import (
"github.com/gin-gonic/gin"
"net/http"
"github.com/mickaelmagniez/elastic-alert/store"
)
type ElasticsController struct{}
func (ElasticsController) GetServers(c *gin.Context) {
servers, err := store.GetElasticServers()
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"e... |
package main
import (
"fmt"
"github.com/aliyun/aliyun-datahub-sdk-go/datahub"
)
func main() {
dh = datahub.New(accessId, accessKey, endpoint)
}
func createSubscription() {
csr, err := dh.CreateSubscription(projectName, topicName, "sub comment")
if err != nil {
fmt.Println("create subscrip... |
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"html/template"
"io/ioutil"
"net/http"
"net/url"
"time"
)
// geetest 公钥
const CAPTCHA_ID string = "647f5ed2ed8acb4be36784e01556bb71"
// geetest 密钥
const CAPTCHA_KEY string = "b09a7aafbfd83f73b35a9b530d0337bf"
// geete... |
package problem0448
func findDisappearedNumbers(nums []int) []int {
for i := 0; i < len(nums); i++ {
for nums[nums[i]-1] != nums[i] {
nums[i], nums[nums[i]-1] = nums[nums[i]-1], nums[i]
}
}
res := []int{}
for pos, v := range nums {
if pos+1 != v {
res = append(res, pos+1)
}
}
return res
}
|
// 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 blockowner
import (
"encoding/binary"
"golang.org/x/time/rate"
"github.com/bitmark-inc/bitmarkd/blockrecord"
"github.com/bitmark-inc/... |
package netxlite
import (
"context"
"crypto/tls"
"errors"
"io"
"net"
"strings"
"testing"
"time"
"github.com/google/go-cmp/cmp"
"github.com/ooni/probe-cli/v3/internal/netxmocks"
)
func TestTLSDialerFailureSplitHostPort(t *testing.T) {
dialer := &TLSDialer{}
ctx := context.Background()
const address = "ww... |
package buffer
import (
"fmt"
"sort"
"strings"
)
type Buffer struct {
FirstTime float64
Len int
}
type Buffers map[string]Buffer
type ResultData struct {
MaxPacketNum int
AccessCount int
NextAccessTime int
BufMax int
PacketNumAll int
PacketOfAllBuffers int
Access... |
package chronos
type Container struct {
Type string `json:"type"`
Image string `json:"image"`
Network string `json:"network"`
}
// NewContainer creates a new Container assignment
func NewContainer(image string) *Container {
return &Container{
Type: "DOCKER",
Image: image,
Network: "BRIDGE",
}
}
|
package util
import "log"
import "fmt"
import "time"
// Debugging
const Debug = 0
func DPrintf(format string, a ...interface{}) (n int, err error) {
if Debug > 0 { log.Printf(format, a...) }
return
}
func Log(format string, args ...interface{}) {
nowStr := time.Now().Format("15:04:05.000")
s := fmt.Sprintf(... |
//
// 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 sequencing
func LCSStrings(a []string, b []string, v0 []int, v1 []int) int {
m := len(a)
n := len(b)
if v0 == nil {
v0 = make([]int, n+1, n+1)
}
if v1 == nil {
v1 = make([]int, n+1, n+1)
}
for i := 0; i < m; i++ {
v1[0] = 0
for j := 0; j < n; j++ {
if a[i] == b[j] {
v1[j+1] = v0[j] + 1... |
package command
import (
"fmt"
"regexp"
"time"
)
const (
Beer = "\U0001f37a"
Clock = "\U000023f0"
StartingHour = 18
)
var queryRegexp *regexp.Regexp
func init() {
queryRegexp = regexp.MustCompile(`(?i)time|long|til|left|remaining|eta`)
}
type BeerOClockCommand struct {
name string
patter... |
package gui
import (
"fmt"
"log"
"strings"
"github.com/fatih/color"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazynpm/pkg/utils"
)
// Binding - a keybinding mapping a key and modifier to a handler. The keypress
// is only handled if the given view has focus, or handled globally if the view
// ... |
package url
import (
"github.com/pkg/errors"
"github.com/spf13/afero"
)
func (installer Installer) unpackOneAgentZip(targetDir string, tmpFile afero.File) error {
var fileSize int64
if stat, err := tmpFile.Stat(); err == nil {
fileSize = stat.Size()
}
log.Info("saved OneAgent package", "dest", tmpFile.Name()... |
// Package transparent is a library that provides transparent operations for key-value stores.
// Transparent Layer is tearable on Stack. In addition to caching, it is also possible to
// transparently use a layer of synchronization between distributed systems.
// See subpackage for implementation.
package transparent
... |
package almanack
import (
"net/http"
"github.com/spotlightpa/almanack/internal/aws"
"github.com/spotlightpa/almanack/internal/db"
"github.com/spotlightpa/almanack/internal/github"
"github.com/spotlightpa/almanack/internal/google"
"github.com/spotlightpa/almanack/internal/index"
"github.com/spotlightpa/almanack... |
package main
import (
"fmt"
"github.com/pulumi/pulumi-azure-native/sdk/go/azure/resources"
"github.com/pulumi/pulumi-azure-native/sdk/go/azure/web"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
const (
resourceGroupName string = "funcy-app-rg"
plan ... |
package main
import (
"flag"
"fmt" // пакет для форматированного ввода вывода
"log" // пакет для логирования
"net/http" // пакет для поддержки HTTP протокола
// пакет для работы с UTF-8 строками
)
func main() {
port := flag.String("port", "3000", "an int")
flag.Parse()
http.HandleFunc("/", HelloS... |
package private
import (
"github.com/google/go-querystring/query"
"github.com/pkg/errors"
"github.com/potix/gobitflyer/api/types"
"github.com/potix/gobitflyer/client"
)
const (
getBalanceHistoryPath string = "/v1/me/getbalancehistory"
)
type GetBalanceHistoryResponse []*GetBalanceHistoryEvent
type GetBalanceH... |
// Package goutils contains a collection of useful Golang utility methods and libraries
package goutils
// SliceContains returns true if a slice of strings includes a specific string
func SliceContains(needle string, haystack []string) bool {
for _, value := range haystack {
if needle == value {
return true
}
... |
//
// 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 api
import (
backendProto "github.com/clintjedwards/comet/backend/proto"
"github.com/clintjedwards/comet/proto"
"github.com/rs/zerolog/log"
)
// spawnComet starts and tracks the creation of a comet
func (api *API) spawnComet(request *backendProto.CreateMachineRequest) {
// It should never be possible to ... |
package authentication
import "errors"
var (
ErrLogin = errors.New("given secret or CPF are incorrect")
ErrInvalidSecret = errors.New("given secret is invalid")
)
|
package model
import (
"encoding/json"
es_models "github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/user/model"
"testing"
"time"
)
func TestAppendDeactivatedEvent(t *testing.T) {
type args struct {
user *User
}
tests := []struct {
name string
args args
result *U... |
package primitives
type World struct {
elements []Hitable
}
func (w *World) Add(h Hitable) {
w.elements = append(w.elements, h)
}
func (w *World) AddAll(hitables ...Hitable) {
for _, h := range hitables {
w.Add(h)
}
}
func (w *World) Hit(r Ray, tMin float64, tMax float64) (bool, HitRecord) {
hitAnyth... |
// Copyright 2018 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package example
import (
"context"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: ReconnectToDUT,
Desc: "Demonstrates connec... |
package session
import (
"errors"
uuid "github.com/satori/go.uuid"
)
// ErrStateNotFound is returned from Store.Get() when the requested session id was not found in the store.
var ErrStateNotFound = errors.New("no session state was found in the session store")
// Store represents a session data store.
// This is ... |
package leetcode
func findTheDifference(s string, t string) byte {
letter := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
smap := make(map[string]int)
tmap := make(map[string]int)
for i := range s {
_, ok := smap[stri... |
package quartz
import (
"errors"
"fmt"
"regexp"
"sort"
"strconv"
"strings"
"time"
)
// CronTrigger implements the quartz.Trigger interface.
// Used to fire a Job at given moments in time, defined with Unix 'cron-like' schedule definitions.
//
// Examples:
//
// Expression Meaning
// "0 0 12 * * ?... |
package utils
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"net/url"
)
func InitGlobalVar() {
globalClient = nil
globalClient = nil
globalCookieJar = nil
request = nil
response = nil
Url = nil
jarBind = false
}
func GetUrlHtml(_url string) (string, error) {
if len(_url) <= 0 {
f... |
package main
func main() {
var x int
for x
> 0 {
}
}
|
package pretend
import (
"time"
"github.com/spf13/viper"
)
func PayPeriodDuration() time.Duration {
if viper.InConfig("PayPeriodDuration") {
return viper.GetDuration("PayPeriodDuration")
}
d, _ := time.ParseDuration("5h") // default to 5h
return d
}
func VotingPeriodDuration() time.Duration {
if viper.InCo... |
package main
import (
"errors"
"fmt"
"io"
"net/url"
rtmp "github.com/junli1026/gortmp"
)
func validateRTMPStreamURL(uri string) error {
url, err := url.Parse(uri)
if err != nil {
return err
}
if url.Path != "/live" && url.Path != "/LIVE" {
return errors.New("invalid string url " + uri)
}
return nil
}
... |
/*
* Npcf_SMPolicyControl API
*
* Session Management Policy Control Service © 2019, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TSDSI, TTA, TTC). All rights reserved.
*
* API version: 1.0.4
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/
package openapi
type RedirectInformation... |
package utils
import (
"os"
"github.com/ozonva/ova-food-api/internal/logger"
"gopkg.in/yaml.v3"
)
type GRPC struct {
GRPCPort string `yaml:"grpc_port"`
}
type DATABASE struct {
DBHost string `yaml:"db_host"`
DBPort string `yaml:"db_port"`
DBUser string `yaml:"db_user"`
DBPassword string `yaml:"... |
package main
import "testing"
func TestGns3License(t *testing.T) {
license, err := getLicense("00000000", "gns3vm")
if err != nil {
t.Errorf("License had an error: %s", err.Error())
}
if license != "73635fd3b0a13ad0" {
t.Errorf("License was incorrect got: %s, want: %s.", license, "73635fd3b0a13ad0")
}
}
fun... |
package weibo
type Following struct {
// 关注者的id
FromUserID int64 `json:"from_user_id" db:"from_user_id"`
// 被关注者的id
ToUserID int64 `json:"to_user_id" db:"to_user_id"`
// 关注时间
CreatedAt int64 `json:"created_at" db:"created_at"`
}
|
package nginx
import (
"fmt"
"github.com/layer5io/gokit/errors"
)
var (
ErrOpInvalid = errors.New(errors.ErrOpInvalid, "Invalid operation")
)
// ErrInstallMesh is the error for install mesh
func ErrInstallMesh(err error) error {
return errors.New(errors.ErrInstallMesh, fmt.Sprintf("Error installing mesh: %s", e... |
// Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package balancer
import (
"testing"
"time"
)
////////////////////// balancer.HTTPMonitor Tests //////////////////////
// Test the construction of HTTPMonitor
func TestHTTPMonitorConstruction(t *testing.T) {
m := NewHTTPMonitor(DefaultHealthCheckRoute)
// things should be initialized correctly by constructor
if... |
package mondohttp
import "testing"
func TestNewAccountsRequest(t *testing.T) {
req := NewAccountsRequest("token")
assertReqEquals(t, req, `GET /accounts HTTP/1.1
Host: api.getmondo.co.uk
User-Agent: Go-http-client/1.1
Authorization: token
`)
}
func TestBalanceRequest(t *testing.T) {
req := NewBalanceRequest("tok... |
// Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package notification
import "time"
type Sender interface {
Send(msg string)
}
type Notification interface {
SendIfNeed(t time.Time, s Sender)
}
type TimeChecker interface {
Check(time time.Time) bool
}
type MessageProvider interface {
Message() string
}
|
package handlers
import (
"fmt"
log "log"
"strings"
iris "github.com/kataras/iris/v12"
minio "github.com/minio/minio-go/v6"
cnf "github.com/rzrbld/adminio-api/config"
resph "github.com/rzrbld/adminio-api/response"
)
var BuckList = func(ctx iris.Context) {
lb, err := minioClnt.ListBuckets()
var res = resph.B... |
package binance
import (
"encoding/json"
)
func (b *Binance) clientGetExchangeInfo() (*ExchangeInfo, error) {
body, err := b.clientGet("/api/v3/exchangeInfo")
if err != nil {
log.WithError(err).Error("can't get ExchangeInfo")
return nil, err
}
exchangeInfo := &ExchangeInfo{}
err = json.Unmarshal(body, &exc... |
package main
import "fmt"
func main() {
var n int
fmt.Scan(&n)
var counter int
counter = n
for i := 1; i <= n; i++ {
for j := 1; j <= n; j++ {
if j < counter {
fmt.Print(" ")
}
if j >= counter {
fmt.Print("#")
}
}
counter = counter - 1
fmt.Println()
}
}
|
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func Test_isHappy(t *testing.T) {
type args struct {
n int
}
tests := []struct {
name string
args args
want bool
}{
{
args: args{
n: 19,
},
want: true,
},
{
name: "for single digit",
args: args{
n: 2,
... |
package basket
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/dvdalilue/invopop/db"
"github.com/dvdalilue/invopop/api/common"
)
// Mapper function to translate a basket model into a friendlier
// DTO. Get the basket/product relations and creates a 'summary'
// object with the list of items... |
package jsondiff
import (
"encoding/json"
"errors"
"reflect"
)
// Diff compares oldValue with newValue and returns a json tree of
// the changed values.
func Diff(oldValue interface{}, newValue interface{}) (json.RawMessage, error) {
return DiffFormat(oldValue, newValue, DefaultFormat)
}
func DefaultFormat(oldVa... |
package rpc
import (
"github.com/jrapoport/gothic/api/grpc/rpc"
"github.com/jrapoport/gothic/core/tokens"
"github.com/jrapoport/gothic/models/user"
"github.com/jrapoport/gothic/utils"
"google.golang.org/protobuf/types/known/structpb"
"google.golang.org/protobuf/types/known/timestamppb"
)
// UserResponse maps th... |
package main
import (
"app"
"app/configSettting"
log "github.com/Sirupsen/logrus"
"github.com/garyburd/redigo/redis"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
"os"
)
func main() {
gin.SetMode(gin.ReleaseMode)
// broadscaler admin
//
// adscoopsDB := fmt.Sprintf... |
package main
import "go/ast"
func main() {
var gd *ast.GenDecl
v := gd.Specs[0].(*ast.ValueSpec)
v.
}
|
// Copyright 2018 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, ... |
package logic
import (
"fmt"
"io"
"bufio"
"testing"
)
type BasicReader struct{
data []byte
pos int
}
type ConsoleWriter struct{}
func (br *BasicReader) Read(p []byte) (n int, err error) {
l := len(p)
if l > len(br.data)-br.pos {
l = len(br.data)-br.pos
}
if l == 0 {
return 0, io.EOF
}
copy(p, br.dat... |
package api
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/dolittle/platform-api/pkg/git"
gitStorage "github.com/dolittle/platform-api/pkg/platform/storage/git"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var gitTestCMD = &cobra.Command{
Use: "git-test",
... |
package main
import (
"context"
"fmt"
"log"
"net/http"
"os"
"os/signal"
redis "xj_web_server/cache"
"xj_web_server/config"
"xj_web_server/db"
"xj_web_server/httpserver"
"xj_web_server/tcp"
"xj_web_server/util"
"time"
)
func main() {
config.InitConfig("/../config/config.yml")
err := ... |
package goods
import (
"flea-market/common/tools"
"flea-market/model/goodsModel"
"github.com/gin-gonic/gin"
"net/http"
"strconv"
)
func Delete(c *gin.Context) {
claims := tools.CheckToken(c)
goodsIdStr := c.Query("goods_id")
if goodsId,err := strconv.Atoi(goodsIdStr);err != nil {
c.JSON(http.StatusBadRequ... |
package main
import "fmt"
type Student struct {
Id int
Name string
Gender bool
}
type Beaner interface {
GetName() string
SetName(string)
}
func (s Student) GetName() string { // 1
return s.Name
}
func (s *Student) SetName(name string) { // 2
s.Name = name
}
func main() {
// stu := Student{1, "lisi"... |
package config
import (
"encoding/json"
"io/ioutil"
)
const minWidth = 320
const minHeight = 240
// Project configuration properties
// Engine needs to know where to locate its game data
type Config struct {
GameDirectory string
Video struct {
Width int
Height int
}
}
// @TODO Implement something ... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package arc
import (
"bytes"
"context"
"strconv"
"strings"
"time"
"chromiumos/tast/common/testexec"
"chromiumos/tast/errors"
"chromiumos/tast/local/arc"
"chromiumo... |
package gwfunc
import (
//"sync"
"time"
)
func init() {
}
//var pool = sync.Pool {
// New: func() interface{}{
// var executor = &execution {
// hasTimeout: false,
// hasDone: make(chan bool, 1),
// }
// return executor
// },
//}
type execution struct {
f func()
state uint8
hasDone cha... |
// 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... |
// Attempted the following name for package:
// - authenticator: this sounds more like a verb
// - authentication: too long
// - userlogin: is too specific, since user can also register
// - loginUser: breaks the convention, since package name is preferable a noun.
// - authz and authn is better.
package authnsvc
imp... |
package config
import (
"encoding/json"
"errors"
"io/ioutil"
"os"
"path"
"path/filepath"
)
const (
configDirectoryName = "wundercli"
configFileName = "config.json"
)
var Config struct {
AccessToken string
}
type ConfigDoesNotExist error
// Get config file path.
func getConfigPath() string {
configDi... |
package main
import (
"bufio"
"fmt"
"os"
)
type ByteCounter int
func (c *ByteCounter) Write(p []byte) (int, error) {
*c += ByteCounter(len(p)) // convert in to ByteCounter
return len(p), nil
}
func main() {
fmt.Printf("Words count: %d\n", countWords())
fmt.Printf("Lines count: %d\n", countLines())
}
func co... |
package usecase
type CreateProductInputPort interface {
CreateProduct(interface{}) (interface{}, error)
}
type CreateProductOutputPort interface {
CreateProductResponse(interface{}) (interface{}, error)
} |
package smoothfs
import (
"log"
"os"
"path/filepath"
"syscall"
"bazil.org/fuse"
"bazil.org/fuse/fs"
)
// SmoothFS implements an IO smoothing virtual filesystem.
type SmoothFS struct {
SrcDir string // The directory we are mirroring
CacheDir string // A location locally our cache entries are stored.
NumS... |
package main
import (
"fmt"
_ "github.com/brewlin/net-protocol/pkg/logging"
"github.com/brewlin/net-protocol/protocol/transport/udp/client"
)
func main() {
con := client.NewClient("10.0.2.15", 9000)
defer con.Close()
if err := con.Connect(); err != nil {
fmt.Println(err)
}
con.Write([]byte("send msg"))
r... |
// This file is part of CycloneDX GoMod
//
// 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 config
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_EchoTmpl(t *testing.T) {
tmpl := &Base{}
result, err := EchoTmpl(tmpl)
t.Log(result)
require.NoError(t, err, "tmpl")
}
|
package main
import (
"antalk-go/internal/common"
"antalk-go/internal/seq/protocol/http"
"flag"
"log"
"os"
"os/signal"
"syscall"
)
var (
configName = flag.String("config_name", "seq", "config name")
configType = flag.String("config_type", "toml", "config type")
configPath = flag.String("config_path", ".", "... |
// Copyright 2021 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package crostini
import (
"context"
"os"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/local/crostini"
"chromiumos/tast/local/crostini/ui/settings"
"chromiumos/t... |
package array
import (
"encoding/json"
"fmt"
"github.com/project-flogo/core/data/coerce"
"github.com/stretchr/testify/assert"
"testing"
)
func TestFlatternFunc(t *testing.T) {
fn := &fnFlatten{}
str := `[
[
{
"id": 1
}
],
[
{
"id": 2
},
{
"id": 3
}
]
]`
va... |
package binding
package binding
// Kafka defines the operation bindings for the Kafka protocol
type Kafka {
// GroupID is the ID of the consumer group.
GroupID string
// ClientID is the ID of the consumer inside a consumer group.
ClientID string
// BindingVersion specifies the version of this binding. If omit... |
// Copyright 2022 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package inputs
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/bundles/cros/inputs/emojipicker"
"chromiumos/tast/l... |
package logs
import (
"os"
log "github.com/sirupsen/logrus"
)
// Setup set format, output, and level of logs
func Setup() {
log.SetFormatter(&log.TextFormatter{})
log.SetOutput(os.Stdout)
log.SetLevel(log.DebugLevel)
}
|
package p_00101_00200
// 146. LRU Cache, https://leetcode.com/problems/lru-cache/
type ListNode struct {
Key int
Val int
Prev *ListNode
Next *ListNode
}
type LRUCache struct {
storage map[int]*ListNode
capacity int
head *ListNode
tail *ListNode
}
func Constructor(capacity int) LRUCache {
head :=... |
package s3
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"net/textproto"
"os"
"path/filepath"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
... |
package main
import (
"models"
"net/http"
"redis"
)
func init() {
redis.Initialize()
models.Initialize()
}
func main() {
server := http.Server{
Addr: ":8000",
}
assetsHandler := http.StripPrefix("/assets/", http.FileServer(http.Dir("assets")))
http.HandleFunc("/", handleRequest)
http.Handle("/assets/", ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.