text stringlengths 11 4.05M |
|---|
package models
import (
"crypto/md5"
"crypto/rand"
"encoding/base64"
"fmt"
"strings"
u "github.com/xyingsoft/golang-vue/utils"
)
type Account struct {
ID uint
Email string
Password string
Token string
}
//Validate incoming user details...
func (account *Account) Validate() (map[string]interfac... |
package lc
// Time: O(n)
// Benchmark: 0ms 2mb | 100%
func checkZeroOnes(s string) bool {
var oneC, zeroC int
var oneMax, zeroMax int
for _, ch := range s {
if ch == '0' {
oneC = 0
zeroC++
if zeroC > zeroMax {
zeroMax = zeroC
}
} else {
zeroC = 0
oneC++
if oneC > oneMax {
oneMax =... |
package msgraph
import (
"reflect"
"testing"
)
var (
testUser1 = User{ID: "567898765678", UserPrincipalName: "test1@contoso.com", Mail: "test1@contoso.com", MobilePhone: "+1 12346789"}
testUser2 = User{ID: "123456", UserPrincipalName: "test2@contoso.com", Mail: "test2@contoso.com", BusinessPhones: []string{"+9 98... |
package adding
import "errors"
type User struct {
Name string `json:"name"`
LastName string `json:"last_name"`
Password string `json:"password"`
Email string `json:"email"`
IsAdmin bool `json:"is_admin"`
}
func (u User) Validate() error {
if u.Name == "" {
return errors.New("field 'name' empty")
}... |
// 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 memory_management
type DockerContainer struct {
Resource Resource
}
type Resource struct {
MemoryLimit int64
MemoryRequest int64
}
|
// Package google has Google API client stuff
package google
import (
"bytes"
"compress/gzip"
"context"
"encoding/base64"
"flag"
"io"
"net/http"
"sync"
"github.com/spotlightpa/almanack/pkg/almlog"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
)
type Service struct {
certMU sync.RWMutex
cert ... |
package cmd
import (
"context"
"fmt"
"os"
"strconv"
"strings"
"text/tabwriter"
"github.com/fatih/color"
"github.com/porter-dev/porter/cli/cmd/api"
"github.com/porter-dev/porter/cli/cmd/utils"
"github.com/spf13/cobra"
)
// projectCmd represents the "porter project" base command when called
// without any su... |
package store
import (
"errors"
"github.com/skoltai/limithandling/domain"
)
// LimitOverrideRepository specifies the possible interactions with LimitOverride records
type LimitOverrideRepository interface {
Create(l LimitOverride) int
Update(l LimitOverride) bool
Upsert(appID int, limit domain.Limit) error
}
/... |
package jwt
import (
"github.com/dgrijalva/jwt-go"
"github.com/orbis-challenge/src/models"
"github.com/pkg/errors"
)
// Service error list.
var (
ErrTokenInvalid = errors.New("jwt is invalid")
ErrTokenInBlackList = errors.New("jwt is/was blocked")
ErrTokenNotFound = errors.New("jwt not found")
Err... |
package packet
import (
"encoding/binary"
"math"
)
func readBytesAsBool(data []byte) bool {
return readBytesAsUint8(data) > 0
}
func readBytesAsInt8(data []byte) int8 {
return int8(data[0])
}
func readBytesAsUint8(data []byte) uint8 {
return uint8(data[0])
}
func readBytesAsInt16(data []byte) int16 {
return ... |
package zdb
import (
"errors"
"math"
"github.com/sohaha/zlsgo/ztype"
"github.com/zlsgo/zdb/builder"
)
func (e *DB) Insert(table string, data interface{}) (lastId int64, err error) {
return e.insert(table, data, parseAll)
}
func (e *DB) InsertMaps(table string, data interface{}) (lastId int64, err error) {
ret... |
package repositories
import (
"go-architecture-mysql/api/entities"
"go-architecture-mysql/api/payloads"
)
type UserRepository interface {
View() ([]entities.User, error)
FindById(uint) (entities.User, error)
FindByUsername(string) (entities.User, error)
Create(payloads.CreateRequest) (bool, error)
Update(paylo... |
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
// Findlinks1 prints the links in an HTML document read from standard input.
package main
import (
"fmt"
"io"
"os"
"golang.org/x/net/html"
)
func main() {
if !Parse(os.Args[1]) {
os.Exi... |
// Package workwave provides a client for the WorkWave Route Manager API
// https://wwrm.workwave.com/api/
package workwave
|
package service
import (
"fmt"
"github.com/pkg/errors"
"time"
)
const MinUnix int64 = 1e8 // 1976-05-04 03:33:20
const MaxUnix int64 = 1e10 // 2033-05-18 11:33:20,不包含
var CSTLoc = time.FixedZone("CST", 8*60*60)
var (
AllowedDayLayout = []string{"2006-01-02", "20060102", "06-02-02", "060102"}
)
var (
ErrInvali... |
package plugin
type Config struct {
SocketDir string `yaml:"socket_dir" default:"/run/docker/plugins"`
Volumes VolumesConfig `yaml:"volume"`
GPUs map[string]map[string]string
}
type VolumesConfig struct {
Root string `yaml:"root" default:"/var/lib/docker-volumes"`
Volumes map[string]map[string]s... |
// Copyright 2019 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" fil... |
package nats
import (
"time"
gonats "github.com/nats-io/nats.go"
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus"
mint "github.com/void616/gm.mint"
"github.com/void616/gm.mint.sender/internal/sender/db/types"
senderNats "github.com/void616/gm.mint.sender/pkg/sender/nats"
"github.c... |
package metric
import "github.com/danrl/golibby/util"
// LevenshteinDistance returns the Levenshtein distance of two strings
func LevenshteinDistance(a, b string) int {
ar := []rune(a)
br := []rune(b)
v0 := make([]int, len(br)+1)
v1 := make([]int, len(br)+1)
// initialize start vector
for i := 0; i < len(v0);... |
package collections
import (
"errors"
"strconv"
"time"
)
type StrObj struct {
str *String
refCount int
lru time.Time
}
func NewStrObj(str string) *StrObj {
return &StrObj{
str: NewString(str),
refCount: 1,
lru: time.Now(),
}
}
//在字符串对象后面添加字符串
func (s *StrObj) Append(str string) {
... |
package webServer
import (
"fmt"
"io/ioutil"
"net/http"
"sync"
"GlobalFapCenter/bll/globalFapLvRankbll"
"GlobalFapCenter/config"
"GlobalFapCenter/model/globalFapLvRank"
"GlobalFapCenter/redisMgr"
"encoding/json"
"moqikaka.com/goutil/logUtil"
)
// Start 开启web服务器
func Start(wg *sync.WaitGroup) {
defer func... |
package cache
import (
"time"
"openreplay/backend/pkg/db/postgres"
. "openreplay/backend/pkg/db/types"
)
type ProjectMeta struct {
*Project
expirationTime time.Time
}
// !TODO: remove old sessions by timeout to avoid memleaks
/*
* Cache layer around the stateless PG adapter
**/
type PGCache struct {
*po... |
package main
import (
"bufio"
"encoding/json"
"flag"
"fmt"
"net"
"net/http"
"regexp"
"runtime"
"sort"
"strconv"
"strings"
)
// Main function:
// Read ports for show and set stat info from command line flags get_port and set_port.
// And run 2 goroutine, that listen and serve this ports
func main() {
getPo... |
/*
Created on 2018/5/14 11:14
author: ChenJinLong
Content:
*/
package main
import (
"fmt"
)
func print101(n int) {
if n == 1 {
fmt.Println(1)
} else {
fmt.Println(n)
print101(n - 1)
}
}
func main() {
print101(10)
}
|
package iot
import (
"encoding/json"
"log"
"net/http"
)
/*
IoT Handler Manager
Author: tobychui
This manager mange all the existsing / registered ioT Manager.
This allow a much more abstract usage in the main code
*/
type Manager struct {
RegisteredHandler []ProtocolHandler
cachedDeviceList []*Device
}
... |
package valuerange
import (
"fmt"
"golang.org/x/xerrors"
"github.com/iotaledger/hive.go/serializer/v2/marshalutil"
)
// BoundType indicates whether an EndPoint of some ValueRange is contained in the ValueRange itself ("closed") or not
// ("open"). If a range is unbounded on a side, it is neither open nor closed ... |
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in complian... |
// Copyright 2018 Saferwall. All rights reserved.
// Use of this source code is governed by Apache v2 license
// license that can be found in the LICENSE file.
package sandbox
import (
"context"
"encoding/json"
"strings"
"sync"
"github.com/digitalocean/go-libvirt"
so "github.com/iamacarpet/go-win64api/shared"
... |
package p_00401_00500
import (
"sort"
"strings"
)
// 451. Sort Characters By Frequency, https://leetcode.com/problems/sort-characters-by-frequency/
func frequencySort(s string) string {
if len(s) < 1 {
return s
}
countsByChar := make(map[rune]int)
for _, r := range s {
if count, ok := countsByChar[r]; ok {... |
package handler
import (
golog "github.com/op/go-logging"
"github.com/dgonyeo/brandreth2.0/db"
)
var log = golog.MustGetLogger("main")
type Handler struct {
c db.Controller
}
type PersonEntry struct {
Person *db.Person
Entry *db.Entry
}
|
package person_application
import (
person_domain "github.com/MeliCGS/go-project-api-arq-hexa/api/person/domain"
)
type PeopleUpdate struct {
Repo person_domain.PersonRepository
}
func (p *PeopleUpdate) UpdatePerson(Person *person_domain.Person) {
p.Repo.UpdatePeople(Person)
}
|
package gosqs
import (
"context"
"encoding/json"
"github.com/aws/aws-sdk-go/service/sqs"
)
// Message serves as the message interface for handling the message
type Message interface {
// Route returns the event name that is used for routing within a worker, e.g. post_published
Route() string
// Decode will unm... |
package v1
import (
"context"
"errors"
"fmt"
"log"
"github.com/traPtitech/trap-collection-server/src/auth"
"github.com/traPtitech/trap-collection-server/src/cache"
"github.com/traPtitech/trap-collection-server/src/domain"
"github.com/traPtitech/trap-collection-server/src/service"
)
type User struct {
userUt... |
package dynamodb
import (
"bytes"
"encoding/binary"
"fmt"
"math"
"time"
"github.com/aws/aws-sdk-go/aws"
godynamodb "github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/golang/mock/gomock"
"github.com/yuuki/diamondb/pkg/config"
"github.com/yuuki/diamondb/pkg/model"
)
// FakeReadWriter is for stub testin... |
// SPDX-License-Identifier: MIT
package lang
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
"github.com/issue9/assert/v3"
"github.com/issue9/sliceutil"
"github.com/caixw/apidoc/v7/core"
"github.com/caixw/apidoc/v7/core/messagetest"
)
// 当前文件用于测试各个语言的解析是否都正常
//
// 测试数据在 ./testdata 目录,按语言 ID ... |
package leetcode_go
type intPair struct {
x, y int
}
func shortestPathBinaryMatrix(grid [][]int) int {
dirs := []intPair{
intPair{0, 1},
intPair{0, -1},
intPair{1, 0},
intPair{1, 1},
intPair{1, -1},
intPair{-1, 0},
intPair{-1, 1},
intPair{-1, -1},
}
m, n := len(grid), len(grid[0])
q := []intPair{... |
package core
import (
"testing"
)
func TestSetConfig(t *testing.T) {
testConfig := CoreConfig{
State: StateConfig{
DbFile: Defaults().State.DbFile,
},
}
SetConfig(testConfig)
if Config.State.DbFile != Defaults().State.DbFile {
t.Fail()
}
cleanup := func() {
Config = Defaults()
}
t.Cleanup(cleanup)... |
package gar
import (
"archive/zip"
"bufio"
"bytes"
"encoding/binary"
"fmt"
"io"
"os"
"path/filepath"
"strings"
"sync"
)
const suffix = "GAR"
type Archiver struct {
f *os.File
fw *bufio.Writer
fileSize int64
zw *zip.Writer
err error
}
func NewArchiver(fn string) (*Archiver, err... |
package repository
import (
"context"
"github.com/jackc/pgx/v4/pgxpool"
"snippetBox-microservice/news/internal/service"
"snippetBox-microservice/news/pkg/domain"
"time"
)
type news struct {
Pool *pgxpool.Pool
}
func News(Pool *pgxpool.Pool) service.NewsRepositoryInterface {
return &news{Pool: Pool}
}
func (r... |
package singleton
import (
"log"
"github.com/BurntSushi/toml"
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/text/language"
"github.com/naiba/nezha/model"
)
var Localizer *i18n.Localizer
func InitLocalizer() {
bundle := i18n.NewBundle(language.Chinese)
bundle.RegisterUnmarshalFunc("toml", toml.Unmars... |
// Copyright 2017 Google Inc. 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... |
package go2lua
import (
"fmt"
"reflect"
"runtime/debug"
"strings"
lua "github.com/yuin/gopher-lua"
)
// Import takes a Lua value and copies matching values into the provided Go interface.
// By providing the orig interface, values that cannot be imported from Lua will be copied from orig.
func Import(ls *lua.LS... |
package gofastcgi
import (
"io";
"os";
// "fmt";
"bufio";
)
type FlushWriter interface {
Write(p []byte) (n int, err os.Error);
Flush() os.Error;
}
type FCGIStreamWriter struct {
RequestID uint16;
Type byte;
io.Writer;
};
func (s *FCGIStreamWriter) Write(p []byte) (n int, err os.Error) {
var size = 8192;
... |
//
// 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 (
"runtime"
"fmt"
"net/http"
"github.com/gorilla/websocket"
. "slither/types"
)
var (
Counter = 0
Clients = make(map[int] Client) // clients list
Origins = map[string]bool {
"http://localhost:8000": true, // development
"http://slither.io": true, // production
}
)
var ... |
package db
import (
"log"
"time"
"github.com/gocraft/dbr/v2"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
)
type Config struct {
Driver string `json:"driver,omitempty"`
DSN string `json:"dsn,omitempty"`
Timezone string `json:"timezone,omitempty"`
}
type localDialect struct {
dbr.Dialect
lo... |
// Copyright 2019 Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in complian... |
package torrent
import (
"fmt"
"os"
"text/tabwriter"
log "github.com/sirupsen/logrus"
"github.com/sp0x/torrentd/indexer"
"github.com/sp0x/torrentd/indexer/search"
)
// GetNewScrapeItems gets the latest torrents.
func GetNewScrapeItems(facade *indexer.Facade, fetchOptions *indexer.GenericSearchOptions) error {... |
package errors
import "errors"
var ERROR_NOT_FOUND = errors.New("not found")
|
package test
import (
"first/function"
"fmt"
"testing"
)
func TestInterBaseFunc(t *testing.T) {
function.InterBaseFunc()
}
func TestType(t *testing.T) {
{
var x interface{}
x = 10
value, ok := x.(int)
fmt.Println(value, ",", ok)
}
{
var x interface{}
x = 10
value, ok := x.(string)
fmt.Println(... |
package main
import (
"fmt"
)
func main() {
seq := make([]int, 3)
fmt.Println(int(-1e4))
//seq = []int{10, 1, 2, 3, 4, 5}
seq = []int{1, 2, 1, 2}
res := almostIncreasingSequence(seq)
fmt.Println(res)
}
func almostIncreasingSequence(sequence []int) bool {
counter := 0
//default min values from -10**5 ≤ sequ... |
package controllers
import (
"github.com/astaxie/beego"
)
type ErrorController struct {
beego.Controller
}
//func (c *ErrorController) Error404() {
// c.Data["json"] = Response{
// code: 404,
// message: "Not Found",
// }
// c.ServeJSON()
//}
//func (c *ErrorController) Error401() {
// c.Data["json"] = Respons... |
// 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 agreed to... |
package main
import "fmt"
func main() {
result := FireWire(10)
fmt.Println(result)
}
type AType string
func A(a int) AType {
return AType(fmt.Sprintf("%d", a))
}
type BType string
func B(b AType) BType {
return BType(fmt.Sprintf("[%s]", b))
}
|
/*
Copyright 2020 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 main
import (
"JsGo/JsStore/JsRedis"
"fmt"
"math/rand"
"time"
)
func shop() {
var str string
JsRedis.Redis_get("shop", &str)
fmt.Printf("%s\n", str)
}
func admin() {
type Admin struct {
Account string
Password string
Header string
Role string
}
admin := &Admin{"admin", "1qaz2wsx", "... |
// 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 wifi
import (
"context"
"chromiumos/tast/remote/wificell"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: P2PSimpleConnect,
... |
package proxy
import (
"bytes"
"encoding/json"
"fmt"
"github.com/fatih/color"
"github.com/jasonlvhit/gocron"
"github.com/Aegon-n/sentinel-bot/socks5-proxy/constants"
"github.com/Aegon-n/sentinel-bot/socks5-proxy/dbo/ldb"
"github.com/Aegon-n/sentinel-bot/socks5-proxy/dbo/models"
"io/ioutil"
"log"
"math"
"ma... |
package main
import (
"fmt"
"is105gruppe20/is105-ica02/ascii"
)
func main() {
fmt.Println("Oppgave 1A:")
ascii.IterateOverASCIIStringLiteral(ascii.GetASCIIStringLiteral())
}
|
package server
import (
"fmt"
"log"
"net/http"
)
// Server stores the hostname and port number
type ServerConfiguration struct {
Hostname string `json:"Hostname"` // Server name
UseHTTP bool `json:"UseHTTP"` // Listen on HTTP
UseHTTPS bool `json:"UseHTTPS"` // Listen on HTTPS
HTTPPort int... |
package helpers_test
import (
"testing"
"github.com/go-jstmpl/go-jstmpl/helpers"
)
func TestLowerSnakeCase(t *testing.T) {
type Case struct {
Input string
Expected string
Message string
}
cases := []Case{
Case{
Input: "lower spaced string",
Expected: "lower_spaced_string",
Message: "low... |
/* SPDX-License-Identifier: MIT
* Copyright © 2019-2020 Nadim Kobeissi <nadim@nadim.computer>.
* All Rights Reserved. */
/* Based on code by Jun Kimura. */
package main
import (
"fmt"
"regexp"
"strings"
)
var (
adblockHasAnyPrefix = adblockCreateCheckStringSetFunc(strings.HasPrefix)
adblockContainsAny = ad... |
// Copyright 2018 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// https://github.com/cockroachdb/cockroach/blob/master/li... |
package main
import (
"fmt"
"os"
"math/rand"
"strconv"
)
const defaultName string = "Arthur" //Or without string...
//Declaration of some variable.
//We can use "const" in place of "var".
//log.Fatal() || panic("") - когда нельзя дальше продолжать
var (
someFruit string = "Apple"
someNumber uint = 0 //uint (... |
package duration
import (
"errors"
"testing"
"time"
"github.com/google/go-cmp/cmp"
)
func mustParse(t *testing.T, s string) Duration {
d, err := ParseRFC3339(s)
if err != nil {
t.Fatal(err)
}
return d
}
func TestParseRFC3339(t *testing.T) {
tests := []struct {
s string
expected Duration
expecte... |
package lib_gc_debugger
var Dummy struct{} |
package slave
import (
"../logger"
"../master"
"../sdfs_slave"
"fmt"
"log"
"math"
"net"
"net/rpc"
"os"
"os/exec"
"sort"
"strconv"
"strings"
"sync"
"time"
)
const (
INTRODUCER_ADDR = "172.22.157.12"
MIN_NODE_NUM = 4
PERIOD = 5000000000
COOLDOWN = 5000000000
SDFS_FILE_PREFIX =... |
package main
import (
"regexp"
"strings"
"time"
"github.com/PuerkitoBio/goquery"
"github.com/openSUSE/sauria/commit"
"github.com/openSUSE/sauria/configuration"
"github.com/openSUSE/sauria/query"
)
// FetchNewVersion fetch a new version from github
func FetchNewVersion(c *configuration.Configuration) (commit.C... |
package client
import (
"github.com/NodeFactoryIo/vedran/pkg/http-tunnel/proto"
"github.com/NodeFactoryIo/vedran/pkg/http-tunnel/server"
"github.com/cenkalti/backoff"
"github.com/sirupsen/logrus"
"net/url"
"time"
)
func MapTunnels(m map[string]*Tunnel) map[string]*proto.Tunnel {
p := make(map[string]*proto.Tun... |
package nvim
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"log"
"net"
"os/exec"
"reflect"
"strings"
"sync"
"syscall"
"time"
"github.com/neovim/go-client/msgpack"
"github.com/neovim/go-client/msgpack/rpc"
)
//go:generate go run api_tool.go -generate api.go -deprecated api_deprecated.go
var embedProc... |
package main
import (
"bufio"
"fmt"
log "github.com/sirupsen/logrus"
"io"
"math"
"net/http"
"os"
"os/exec"
"strconv"
"strings"
)
const apnicURL = "http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest"
const apincIPListFile = "./apinc_ip_list.txt"
const ipipURL = "https://raw.githubusercontent.com/... |
/*
* Copyright (c) 2013 Matt Jibson <matt.jibson@gmail.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" A... |
package heroku
import (
"context"
"fmt"
"net/http"
"os"
"sync"
"github.com/pganalyze/collector/state"
"github.com/pganalyze/collector/util"
)
func SetupHttpHandlerLogs(ctx context.Context, wg *sync.WaitGroup, globalCollectionOpts state.CollectionOpts, logger *util.Logger, servers []*state.Server, parsedLogStr... |
package cycle
import (
"errors"
"os"
"os/signal"
"syscall"
"time"
)
// PeriodicFn is a function to be executed periodically.
type PeriodicFn func(uint) error
// FinalFn is a function to be executed after periodic behavior has terminated.
type FinalFn func()
// SignalFn is a function to be executed when a signa... |
package rabbitMQ
var URI = "amqp://tfs:tfs-ocg@174.138.40.239:5672/#/"
|
package solver
import (
"nplsolver/dict"
"testing"
)
const (
testWord = "hello"
resultsChannelSize = 100
)
func TestIdentityMatching(t *testing.T) {
entry,_ := dict.NewEntryFromWord(testWord)
matcher,_ := newIdentityMatcher()
if !matcher.Match(testWord,entry) {
t.Errorf("IdentityMatcher di... |
// Copyright 2019 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... |
// go run hello.go 程序go使用 了 run 和 hello.go 两个参数
package main
import "os"
import "fmt"
func main() {
argsWithProg := os.Args
argsWithoutProg := os.Args[1:]
//也可以使用标准索引位置方式取得单个参数的值
arg := os.Args[3]
fmt.Println(argsWithProg)
fmt.Println(argsWithoutProg)
fmt.Println(arg)
}
|
// Copyright (c) 2020-2021 KHS Films
//
// This file is a part of mtproto package.
// See https://github.com/xelaj/mtproto/blob/master/LICENSE for details
package session
import (
"encoding/base64"
"encoding/binary"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"syscall"
"time"
"github.com/pkg/err... |
package problem0015
import "sort"
//先排序,nlogn
//对撞指针。
func threeSum(nums []int) [][]int {
results := [][]int{}
sort.Ints(nums)
for i := 0; i < len(nums)-2; i++ {
iv := nums[i]
//对i进行去重
if i > 0 && iv == nums[i-1] {
continue
}
j, k := i+1, len(nums)-1
for j < k {
jv := nums[j]
kv := nums[k]
... |
package models
import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
"unicode"
)
// Сессия с файловой базой данных
type SessionDb struct {
db *sql.DB
}
// Переподключение или создание подключения к базе
func (self *SessionDb) GetDb() *sql.DB {
if self.db != nil {
return self.db
}
db, err := sql.Open("sqlit... |
package monitoring
import (
"testing"
"github.com/NataliaZabelina/monitoring/internal/app/command"
"github.com/NataliaZabelina/monitoring/internal/storage"
"github.com/stretchr/testify/require"
)
func TestGetLoadAvg(t *testing.T) {
db := &storage.DB{}
db.Init()
result, err := command.GetLoadAvg(db)
require.N... |
// 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 memoryuser
import (
"context"
"fmt"
"path"
"chromiumos/tast/common/testexec"
"chromiumos/tast/errors"
"chromiumos/tast/local/arc"
)
// AllocationTarget is an... |
package engine
import (
"testing"
"time"
"github.com/stretchr/testify/suite"
)
type fakeValueStore struct {
valueStore
}
func (s *fakeValueStore) getType() string {
return "fake"
}
type valueStoreTestSuite struct {
suite.Suite
store fakeValueStore
}
func (suite *valueStoreTestSuite) SetupTest() {
suite.s... |
package e2e
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
configapiv1 "github.com/openshift/api/config/v1"
"github.com/openshift/cluster-image-registry-operator/test/framework"
)
func TestBaremetalAndVSphereDefaults(t *testing.T) {
client := framework.MustNewClientset(t, nil)
infrastructu... |
package v1alpha1
type IDESpec struct {
Image string `json:"image,omitempty"`
}
|
package util
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/hex"
"errors"
"io"
)
//AESCFBDecrypter AES CFB 解密
func AESCFBDecrypter(key string, ciphertext []byte) ([]byte, error) {
keyBytes, err := hex.DecodeString(key)
if err != nil {
keyBytes = make([]byte, 32)
copy(keyBytes, []byte(key))
... |
// Copyright 2018-present The Yumcoder Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// Author: yumcoder (omid.jn@gmail.com)
//
package proc
import (
"crypto/rand"
"testing"
)
func fval(a int, b int) int{
t:= 0
for i:=0; i... |
// Copyright 2022 Saferwall. All rights reserved.
// Use of this source code is governed by Apache v2 license
// license that can be found in the LICENSE file.
// Package log provides context-aware and structured logging capabilities.
package log
import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
func getLogg... |
// Copyright 2016 Zhang Peihao <zhangpeihao@gmail.com>
package protocol
import "errors"
var (
// ErrParseFailed 协议解析失败
ErrParseFailed = errors.New("parse failed")
)
|
package main
import (
"encoding/json"
"fmt"
"os"
"strings"
"code.cloudfoundry.org/cli/plugin"
)
type DefaultEnvPlugin struct{}
func handleError(err error) {
if err != nil {
fmt.Fprintln(os.Stderr, "Error:", err)
os.Exit(1)
}
}
func (c *DefaultEnvPlugin) Run(cliConnection plugin.CliConnection, args []str... |
package main
import (
"fmt"
"net"
"os"
"os/exec"
"strings"
)
const (
CONN_HOST = "0.0.0.0"
CONN_PORT = "9997"
CONN_TYPE = "tcp"
)
func main() {
if len(os.Args) != 2 {
fmt.Println("Usage: ", os.Args[0], "SOURCE_IP_PREFIX")
os.Exit(1)
}
fmt.Println("Source IP prefix:", os.Args[1])
// Listen for incomin... |
package main
import (
"fmt"
"os"
"strings"
)
func main() {
val := os.Environ()
var pathEnv string
for _, field := range val {
//fmt.Println(field)
if strings.HasPrefix(field, "PATH=") {
fmt.Println(field)
pathEnv = strings.Split(field, "=")[1]
}
}
//fmt.Println("PATH:", pathEnv)
for i, path := ra... |
// Copyright 2016-2017 Authors of Cilium
//
// 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 model
type landscapes map[string]Landscape
// Landscape is the Catan landscape type, such as Forest, Mountain
// Each has a name (for readability), and a code for compact data transfer/processing
type Landscape struct {
Name string
Resource
}
var (
Desert = &Landscape{Name: "Desert", Resource: *None}
F... |
package dice
import (
"fmt"
"math/rand"
"time"
"github.com/nickshater/txrlem/score"
"github.com/nickshater/txrlem/types"
)
// Roll simulates the roll of a die
func Roll() types.Die {
rng := rand.NewSource(time.Now().UnixNano())
var roll types.Die
roll.Value = rand.New(rng).Intn(6) + 1
roll.Hold = false
ret... |
package handler
import (
"regexp"
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/klog"
"github.com/baidu/ote-stack/pkg/loadbalancer"
"github.com/baidu/ote-stack/pkg/storage"
"github.com/baidu/ote-stack/pkg/syncer"
)
var connectionUpgradeRegex = regexp.MustCompi... |
package calendar
import (
"fmt"
"strings"
)
const (
SPRING_EMOJI = "🌸"
SUMMER_EMOJI = "🌻"
FALL_EMOJI = "🍄"
WINTER_EMOJI = "⛄️"
)
type Season struct {
Name string `json:"name"`
Days [][]*calendarItem `json:"days"`
}
func (s *Season) Emoji() string {
if s.Name == "spring" {
return SPRING_EM... |
/**********************************************************************
* @Author: Eiger (201820114847@mail.scut.edu.cn)
* @Date: 2020/4/17 1:01
* @Description: The file is for
***********************************************************************/
package config
import (
"encoding/json"
"io/ioutil"
"log"
"net/h... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.