text stringlengths 11 4.05M |
|---|
package api_test
import (
"encoding/json"
"net/http"
"strings"
"testing"
"github.com/porter-dev/porter/internal/kubernetes"
)
// ------------------------- TEST TYPES AND MAIN LOOP ------------------------- //
type reposTest struct {
initializers []func(tester *tester)
msg string
method string... |
package quark
import (
"bufio"
"errors"
"net"
"net/http"
)
type ResponseWriter interface {
http.ResponseWriter
http.Flusher
http.Hijacker
Written() bool
WrittenStatus() int
WrittenSize() int
BeforeWrite(func())
}
type responseWriter struct {
http.ResponseWriter
status int
size int
befores []func(... |
// 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 passpoint contains utilities for manipulating Passpoint credentials
// and access points during tests.
package passpoint
|
package roleserver
import (
// gp "code.google.com/p/goprotobuf/proto"
// "code.google.com/p/snappy-go/snappy"
"common"
// "github.com/garyburd/redigo/redis"
"logger"
//"math/rand"
"net"
"proto"
// "rpc"
"centerclient"
"rpcplus"
"runtime/debug"
"strconv"
"sync"
// "time"
)
const (
ROLE_MAIN_TALBE ... |
package Topic100
// A_Practice
// @author: liujun
// @date: 2022/4/2614:21
// @author—Email: ljfirst@mail.ustc.edu.cn
// @description:
// @blogURL:
type A_Practice struct {
}
func (p *A_Practice) funcName() {
}
|
package split
import (
"reflect"
"testing"
)
// 测试存在分隔符时的split函数
func TestSplit(t *testing.T) {
str := "a:b:c"
got := Split(str, ":")
want := []string{"a", "b", "c"}
if ok := reflect.DeepEqual(got, want); !ok {
t.Fatalf("want: %v, got: %v\n", want, got)
}
}
// 测试不存在分隔符时的split函数
func TestNonSplit(t *testing... |
/*
Copyright 2019 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... |
//Shows a dialog similar to the one shown when you exit a program without saving.
package main
import (
"github.com/matwachich/iup"
)
func main() {
iup.Open()
defer iup.Close()
switch iup.Alarm("IupAlarm Example", "File not saved! Save it now?", "Yes", "No", "Cancel") {
case 1:
iup.Message("Save File", "File ... |
/**********************************************************************
* @Author: Eiger (201820114847@mail.scut.edu.cn)
* @Date: 2020/4/17 7:11
* @Description: The file is for
***********************************************************************/
package main
import (
"fmt"
"github.com/azd1997/go-crawler2/domain... |
package api
import (
"fmt"
"github.com/dgrijalva/jwt-go"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/ssok8s/ssok8s/pkg/api/dtos"
"github.com/ssok8s/ssok8s/pkg/bus"
"github.com/ssok8s/ssok8s/pkg/components/simplejson"
m "github.com/ssok8s/ssok8s/pkg/models"
"github.com/ssok8s/ssok8s/pkg/settin... |
/*
Copyright 2020, 2021 The Flux 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, s... |
package sysmon
import (
"time"
linuxproc "github.com/c9s/goprocinfo/linux"
)
const (
LOADINFO_PATH = "/proc/loadavg"
)
var (
LOAD_MON_FIELDS = []string{
"last_1_min",
"last_5_min",
"last_15_min",
"num_curr_proc",
"num_total_proc",
}
)
type LoadMonitor struct {
startTime time.Time
values map[str... |
// Copyright 2020 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 main
import "fmt"
func main() {
var a,b,c,min int
fmt.Print("Enter first number:")
fmt.Scan(&a)
fmt.Print("Enter second number:")
fmt.Scan(&b)
if a < b {
min = a
} else {
min = b
}
fmt.Print("Enter third number:")
fmt.Scan(&c)
if min > c {
min = c
}
fmt.Printf("... |
package main
import (
"fmt"
"math"
)
func main() {
var input string
fmt.Scanln(&input)
len := len(input)
rows := int(math.Floor(math.Sqrt(float64(len))))
cols := int(math.Ceil(math.Sqrt(float64(len))))
if rows * cols < len {
if rows > cols {
cols += 1
} else {
rows += 1
}
}
var pos int
v... |
package interface_tester
import (
"bytes"
"io/ioutil"
"net/http"
)
func httpGet(url string) ([]byte, error) {
/* #nosec */
resp, err := http.Get(url)
if err != nil {
return nil, err
}
c, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
err = resp.Body.Close()
if err != nil {
retu... |
package main
import (
"bufio"
"fmt"
"os"
"os/exec"
"regexp"
"strings"
"sync"
"time"
"unicode/utf8"
"github.com/mattn/go-runewidth"
"github.com/nsf/termbox-go"
)
// BufferLineCount is the number of lines of buffer to keep in memory from logcat.
const BufferLineCount = 1000
// PreferredHorizontalThreshold ... |
// Copyright 2019 Yunion
//
// 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 writi... |
/*
* @lc app=leetcode.cn id=593 lang=golang
*
* [593] 有效的正方形
*/
package leetcode
import "reflect"
// @lc code=start
func abs(a int) int {
if a < 0 {
return -a
} else {
return a
}
}
func validSquare(p1 []int, p2 []int, p3 []int, p4 []int) bool {
if reflect.DeepEqual(p1, p2) || reflect.... |
package main
func main() {
// Generally speaking, constants are global variables, so you might rethink your approach
// if you find yourself defining too many constant variables with a local scope.
// NOTE: Strictly speaking, the value of a constant variable is defined at compile time not at run time.
const HEIGHT... |
package normalizer
import "github.com/TrueGameover/RestN/rest"
func Init() {
Reset()
rest.RegisterNormalizer(RestResponseNormalizer{})
rest.RegisterNormalizer(LocaleNormalizer{})
rest.RegisterNormalizer(RestErrorNormalizer{})
rest.RegisterNormalizer(FieldValidationErrorNormalizer{})
rest.RegisterNormalizer(Val... |
package main
import (
"context"
"os"
"strings"
"github.com/regclient/regclient/regclient"
"github.com/regclient/regclient/regclient/types"
"github.com/spf13/cobra"
)
var completionCmd = &cobra.Command{
Use: "completion [bash|zsh|fish|powershell]",
Short: "Generate completion script",
Long: `To load comple... |
package queue
import (
"sync"
)
type Queue struct {
mutex *sync.Mutex
queue []interface{}
}
func NewQueue() *Queue {
q := &Queue{mutex: &sync.Mutex{}}
return q
}
func (q *Queue) Push(item interface{}) {
q.mutex.Lock()
q.queue = append(q.queue, item)
q.mutex.Unlock()
}
func (q *Queue) Len() int {
q.mutex.L... |
package main
import (
"fmt"
"unicode/utf8"
)
func main() {
s := "hello,wold"
fmt.Println(len(s)) // 10
fmt.Println(s[0], s[7]) // 104 111
f := "hello,世界"
fmt.Println(len(f)) // 12
fmt.Println(f[0], f[7]) // 104 184
fmt.Println("substring ---------- ")
fmt.Println(s[0:5]) // hello
fmt.Println(s[:5... |
package main
import (
"fmt"
)
func main() {
// // Normal for loop
for i := 0; i < 10; i++ {
fmt.Println("i:", i)
}
// // for without init & post == while loop
// i := 0
// for i < 10 {
// fmt.Println("i:", i)
// i++
// }
// // for without any condition == forever loop
// i := 0
// for {
// fmt.Pr... |
package listing_test
import (
"os"
"testing"
"github.com/elhamza90/lifelog/internal/store/memory"
"github.com/elhamza90/lifelog/internal/usecase/listing"
)
var lister listing.Service
var repo memory.Repository
func TestMain(m *testing.M) {
repo = memory.NewRepository() // Work with In-Memory DB
lister = ... |
/*
Copyright 2014 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 law or agreed to in ... |
// 动作服务
package service
import (
"beego.demo/models/entity"
)
// 系统动作
type actionService struct {
}
func (this *actionService) table() string {
return tableName("action")
}
// 添加记录
func (this *actionService) Add(action, actor, objType string, objId int, extra string) bool {
act := new(entity.Action)
act.Action ... |
// Copyright 2020 The VectorSQL Authors.
//
// Code is licensed under Apache License, Version 2.0.
package datablocks
func (block *DataBlock) Limit(offset, limit int) (cutOffset, cutLimit int) {
preRows := block.NumRows()
st := offset
ed := limit + offset
if ed > preRows {
ed = preRows
}
if st > preRows {
... |
package main
import (
"bufio"
"fmt"
"net"
"os"
"os/exec"
)
func main() {
listen,err:=net.Listen("tcp","localhost:8000")
if err!=nil{
fmt.Println(err)
}
for{
connect,err:=listen.Accept()
if err!=nil{
fmt.Println(err)
break
}
go recv(connect)
}
//out, err := exec.Command("cmd","/C", "dir").Ou... |
package go_ratelimit
import (
"fmt"
"github.com/go-redis/redis/v7"
"github.com/go-redis/redis_rate/v8"
"os"
"testing"
"time"
)
func Test_テスト1(t *testing.T) {
rh := os.Getenv("REDIS_HOST")
rdb := redis.NewClient(&redis.Options{
Addr: rh + ":6379",
})
_ = rdb.FlushDB().Err()
limiter := redis_rate.NewLim... |
package build
import (
"github.com/zouyx/gopt/input"
"os"
"fmt"
"github.com/zouyx/gopt/message"
)
type DirBuilder struct {
}
// dir build method
func (this *DirBuilder) Build(params *input.Params) {
fullPath := getFullPath(params)
err := os.MkdirAll(fullPath, os.ModePerm)
if err!=nil{
message.FormatError(... |
package kubernetessecrets
import (
"context"
"fmt"
"strings"
plugin_v1 "github.com/cyberark/secretless-broker/internal/plugin/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
typedv1 "k8s.io/client-go/kubernetes/typed/core/v1"
)
// Provider provides data values from Kuber... |
package lang
import (
"bytes"
"fmt"
"io"
"strconv"
"strings"
)
func ParseString(in string) (*AST, []error) {
return parse("", in)
}
func ParseReader(name string, in io.Reader) (*AST, []error) {
buf := new(bytes.Buffer)
buf.ReadFrom(in)
src := buf.String()
return parse(name, src)
}
func parse(filepath stri... |
// Copyright 2019, 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 ag... |
package gourm
import (
"fmt"
"log"
"testing"
)
type TestStruct struct {
Model `table:"sw_user" primary_key:"id"`
ID int `col:"id"`
Username string `col:"username"`
Realname string `col:"realname"`
LastLogin string `col:"lastlogin"`
}
func TestWhich(t *testing.T) {
db, err := New("postgres", ... |
package folder2
import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
)
// F2Chaincode definition
type F2Chaincode struct {
}
// F2Method1 returns a successful message from the current method
func (t *F2Chaincode) F2Method1(stub shim.ChaincodeStubInterf... |
package lexers
import (
. "github.com/alecthomas/chroma/v2" // nolint
)
// Typoscript lexer.
var Typoscript = Register(MustNewLexer(
&Config{
Name: "TypoScript",
Aliases: []string{"typoscript"},
Filenames: []string{"*.ts"},
MimeTypes: []string{"text/x-typoscript"},
DotAll: true,
Priority: 0.1... |
// +build storage_sqlite
package cmd
import (
auth "github.com/go-ap/auth/sqlite"
"github.com/go-ap/fedbox/internal/config"
"github.com/go-ap/fedbox/storage/sqlite"
)
var (
bootstrapFn = func(conf config.Options) error {
if err := auth.Bootstrap(auth.Config{Path: conf.BaseStoragePath()}, nil); err != nil {
... |
package model
import (
"net"
"reflect"
"testing"
)
func TestAuthRequest_IsValid(t *testing.T) {
type fields struct {
ID string
AgentID string
BrowserInfo *BrowserInfo
ApplicationID string
CallbackURI string
Request Request
}
tests := []struct {
name string
fields fie... |
package main
import "fmt"
type Num interface {
number()
}
func sumOfNum(n []Num) (Int, Real) {
var (
sumI Int = 0
sumR Real = 0.0
)
for _, x := range n {
switch v := x.(type) { // ?メソッドレシーバをポインタにしてここも *type にしたらエラーになった。なんで?
// 構造体やインターフェースじゃなく、既存の型を再定義するときはポインタ不可ってこと?
case Int:
sumI += v
case Re... |
/*
Copyright 2019 Adobe
All Rights Reserved.
NOTICE: Adobe permits you to use, modify, and distribute this file in
accordance with the terms of the Adobe license agreement accompanying
it. If you have received this file from a source other than Adobe,
then your use, modification, or distribution of it requires the pri... |
package main
import (
"fmt"
"io"
"math"
"os"
"strings"
"time"
)
const Pi = 3.14
const (
Big = 1 << 100
Small = Big >> 99
)
func needInt(x int) int { return x*10 + 1 }
func needFloat(x float64) float64 { return x * 0.1 }
func swap(x, y string) (string, string) {
return y, x
}
func add(x, y int... |
// Copyright 2020 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 applicabl... |
/*
Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.
The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
For example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
return its depth = 3.
*/
pack... |
/*
Copyright © 2020 NAME lflxp <382023823@qq.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 applicable law or agreed to in w... |
package main
import "fmt"
func dfs(n int, k int, now int, nowlen int, res []int, ans *[][]int) {
if nowlen == k {
co := make([]int, k)
copy(co, res)
*ans = append(*ans, co)
return
}
if now > n {
return
}
res[nowlen] = now
dfs(n, k, now+1, nowlen+1, res, ans)
dfs(n, k, now+1, nowlen, res, ans)
}
func... |
package main
import "fmt"
type TimesMatcher struct {
base int
}
func NewTimesMatcher(base int) *TimesMatcher {
return &TimesMatcher{base: base}
}
// Go语言的内存回收机制规定,只要有一个指针指向引用一个变量,那么这个变量就不会被释放(内存逃逸),因此在 Go 语言中返回函数参数或临时变量是安全的。
func main() {
p := NewTimesMatcher(3)
fmt.Println(p)
}
|
package models
import(
"encoding/json"
)
/**
* Type definition for NasProtocolEnum enum
*/
type NasProtocolEnum int
/**
* Value collection for NasProtocolEnum enum
*/
const (
NasProtocol_KNFS3 NasProtocolEnum = 1 + iota
NasProtocol_KCIFS1
)
func (r NasProtocolEnum) MarshalJSON() (... |
package tools
import (
"poetryAdmin/worker/app/redis"
"reflect"
)
type Lock struct {
}
func NewLock() *Lock {
return &Lock{}
}
func (l *Lock) AddKey(key interface{}) bool {
////test
//return true
////test
if _, err := redis.Set(key, 1); err != nil {
return false
}
return true
}
func (l *Lock) DelKey(key... |
package main
import "fmt"
func main() {
switch {
case false:
fmt.Println("it's false")
case true:
fmt.Println("it's true")
}
}
|
package main
import (
"log"
"net/http"
"os"
"github.com/gorilla/mux"
"github.com/jmoiron/sqlx"
_ "github.com/mxk/go-sqlite/sqlite3"
"github.com/rs/cors"
)
const (
DSN = "data.db"
)
func main() {
log.SetOutput(os.Stdout)
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
// Bootstrap the sqlite3 databa... |
package backend
import (
"github.com/leachim2k/go-shorten/pkg/cli/shorten/options"
"github.com/leachim2k/go-shorten/pkg/dataservice/interfaces"
"github.com/leachim2k/go-shorten/pkg/models"
"github.com/mrcrgl/pflog/log"
logOriginal "log"
"os"
"time"
)
type dbBackend struct {
}
func NewDBBackend() interfaces.Ba... |
package acceptance_test
import (
"strings"
"time"
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
const Timeout_Push = 5 * time.Minute
const Timeout_Short =... |
package main
func Sum(numbers []int) (sum int) {
for _, num := range numbers {
sum += num
}
return
}
func SumAll(numbersToSum ...[]int) (sums []int) {
for _, nums := range numbersToSum {
sums = append(sums, Sum(nums))
}
return
}
func SumAllTails(numbersToSum ...[]int) (tailSums []int) {
for _, ... |
package core
import (
"regexp"
"bytes"
)
var Config struct{
ListenAddr string
HTTPAddr string
HTTPHostReplace string
SSLAddr string
SSHAddr string
RDPAddr string
VNCAddr string
SOCKS5Addr string
HTTPProxyAddr string
DefaultAddr string
}
var RegExpMap map[string]*regexp.Regexp
var RegExp_HostRpl *regexp.R... |
package main
import "fmt"
func main() {
// 1. variabel manifest typing
var firstName string = "razzi"
var lastName string
lastName = "tirta"
// fungsi fmt.Printf
fmt.Printf("hallo %s %s!\n", firstName, lastName)
fmt.Printf("hallo razzi tirta!\n")
fmt.Println("hallo",firstName, lastName + "!")
// 2. variab... |
package main
import (
"log"
"math/rand"
"net/http"
"os"
"time"
"github.com/go-echarts/go-echarts/charts"
)
// https://github.com/go-echarts/go-echarts/blob/master/docs/docs/line.md
const (
host = "http://127.0.0.1:8081"
maxNum = 50
)
var (
nameItems = []string{"0", "1", "2", "3", "4", "5"}
)
var seed =... |
// Copyright 2020 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package arcappcompat will have tast tests for android apps on Chromebooks.
package arcappcompat
import (
"context"
"time"
"chromiumos/tast/common/android/ui"
"chromi... |
package main
import (
"fmt"
"github.com/joho/godotenv"
"github.com/kelseyhightower/envconfig"
)
type config struct {
Env string `default:"development"`
MySQL struct {
Host string `required:"true"`
Port uint `required:"true"`
User string `required:"true"`
Pass string `required:"true"`
D... |
package lc
import (
"strconv"
"strings"
)
// Time: O(n)
// Benchmark: 0ms 2.2mb | 100% 37%
func areNumbersAscending(s string) bool {
var last int
s2 := strings.Split(s, " ")
for _, x := range s2 {
if x[0] >= 'a' && x[0] <= 'z' {
continue
}
n, _ := strconv.Atoi(x)
if n <= last {
return false
}
... |
package leetcode_go
func preorderTraversal(root *TreeNode) []int {
path := []int{}
stack := []*TreeNode{}
cur := root
for cur != nil || len(stack) > 0 {
for cur != nil {
path = append(path, cur.Val)
stack = append(stack, cur)
cur = cur.Left
}
if len(stack) > 0 {
tmp := stack[len(stack)-1]
sta... |
package operations
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
)
// CreateScheduleJobsOnceNowReader is a Reader for the CreateScheduleJobs... |
package arm7
import "log"
// SvcRegisters define the Registers for the SVC CPU Mode
type SvcRegisters struct {
// Banked Supervisor Calls (SVC) mode Registers
R13 uint32
R14 uint32
Spsr uint32
}
func (svcRegisters *SvcRegisters) getRegister(register uint32) uint32 {
switch register {
case 13:
return svcReg... |
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
class Solution
{
static void Main(string[] args)
{
i... |
package service
import (
"log"
"github.com/xssnick/goeasy"
"github.com/xssnick/goeasy/simply"
)
type ExitChat struct {
*Service
}
func (s *ExitChat) OnProcess(flow goeasy.Flow, p interface{}) interface{} {
uid := flow.Context().Value("user_id").(uint64)
err := s.Matchmaker.ExitMatch(uid)
if err != nil {
l... |
/*
* Copyright (c) zrcoder 2019-2020. All rights reserved.
*/
package binary_tree_preorder_traversal
/*
144. 二叉树的前序遍历 https://leetcode-cn.com/problems/binary-tree-preorder-traversal
给定一个二叉树,返回它的 前序 遍历。
示例:
输入: [1,null,2,3]
1
\
2
/
3
输出: [1,2,3]
进阶: 递归算法很简单,你可以通过迭代算法完成吗?
*/
type TreeNode st... |
package main
import "fmt"
func main() {
fmt.Println("向 Markdown 程序员致敬!")
}
|
package model
import (
es_models "github.com/caos/zitadel/internal/eventstore/models"
"github.com/golang/protobuf/ptypes/timestamp"
)
type Application struct {
es_models.ObjectRoot
AppID string
State AppState
Name string
Type AppType
OIDCConfig *OIDCConfig
}
type ApplicationChanges stru... |
package command
import (
"context"
"flag"
"fmt"
"net/http"
"os"
"sort"
"strings"
"sync"
"time"
prompt "github.com/c-bata/go-prompt"
"github.com/mesos/mesos-go/api/v1/lib/backoff"
"github.com/mlowicki/rhythm/command/apiclient"
"github.com/mlowicki/rhythm/model"
)
// ClientCommand implements interactive c... |
package handler
import (
"encoding/json"
"net/http"
"github.com/lillilli/logger"
)
const (
internalErrPrefix = "internal error: "
)
// BaseHandler - base http handler
type BaseHandler struct {
Log logger.Logger
}
// SendBadRequestError - send http response with 400 status and specified message
func (h BaseHan... |
package codebuild
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
// コードのテスト
func TestSum(t *testing.T) {
assert := assert.New(t)
sum := Sum(1, 2)
assert.Equal(3, sum)
}
// 環境変数のテスト
func TestEnv(t *testing.T) {
assert := assert.New(t)
assert.Equal("codebuild", os.Getenv("MY_ENV"))
}
|
package main
import (
"crypto/sha1"
"encoding/base64"
"flag"
"fmt"
"log"
"net/http"
"os"
"strconv"
"strings"
"time"
)
const PORT_PARAM string = "port"
const DEFAULT_PORT_NUMBER string = "8080"
const PORT_NUMBER_PARAM_MSG string = "Port number to be used"
const PASSWORD_RESPOND_TIME_LIMIT_SECS float64 = 5
t... |
// Put documentation here
package servicediscover
import (
"sync"
"time"
"github.com/hashicorp/consul/api"
)
// Short description
type Address struct {
IP string
Port int
}
// Short Description
var (
ConsulServices = make(map[Address]string)
mutex sync.Mutex
)
func getServices(consul *api.Client)... |
package graphql
import (
"github.com/graphql-go/handler"
)
func MakeHandler() *handler.Handler {
schema := MakeSchema()
h := handler.New(&handler.Config{
Schema: &schema,
GraphiQL: true,
Pretty: true,
})
return h
}
|
package gorm
import (
"github.com/porter-dev/porter/internal/models"
"github.com/porter-dev/porter/internal/repository"
"gorm.io/gorm"
ints "github.com/porter-dev/porter/internal/models/integrations"
)
// KubeIntegrationRepository uses gorm.DB for querying the database
type KubeIntegrationRepository struct {
db... |
package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"net/http"
"time"
//_ "net/http/pprof"
"os"
"path/filepath"
"strconv"
"sentry-picam/broker"
h "sentry-picam/helper"
"sentry-picam/raspivid"
"github.com/gorilla/mux"
"github.com/gorilla/websocket"
)
// ProductName string
const ProductName = "se... |
package server
import (
pb "github.com/1851616111/xchain/pkg/protos"
cm "github.com/1851616111/xchain/pkg/server/connection_manager"
"sync"
"time"
)
var (
singleton sync.Once
node *Node
//开发环境时为20秒
develop_Ping_Duration time.Duration = time.Second * 60
done struct{} = struct{}{}
)... |
package handlers_test
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"server/handlers"
"server/handlers/test/data"
"server/store/snow"
"testing"
)
func TestHandler_ListHandler(t *testing.T) {
listHandler := &handlers.Handler{}
// failure case
content := `{
"Name": "ServiceNo... |
package notificationview
import (
"testing"
"github.com/herb-go/notification"
)
type nopView struct{}
//View render notification with given data
func (r nopView) Render(Message) (*notification.Notification, error) {
return nil, nil
}
func TestViewCenter(t *testing.T) {
ac := NewAtomicViewCenter()
r, err := ac... |
// 14 august 2014
/*
[this is being written]
notes:
- default behavior of event handlers is to do nothing
- default behavior of event handlers that return bool is to do nothing but return false
- passing nil to an event handler set function restores default behavior
- only functions safe for calling outside Do() are ... |
package main
import "fmt"
type person struct {
firstName string
lastName string
contactInfo
}
type contactInfo struct {
email string
zipcode int
}
func main() {
salt := person {
firstName: "Salt",
lastName: "Theni",
contactInfo: contactInfo{
email: "test@va.com",
zipcode: 625531},
}
salt.... |
package request
type UpdateUserRequest struct {
Email string `json:"email"`
Username string `json:"username"`
Password string `json:"password"`
Balance float64 `json:"balance"`
Admin bool `json:"admin"`
}
|
package controller
// User ...
type User struct {
ID string
Name string
}
// GetUsers return list user
func GetUsers() []*User {
users := []*User{
{ID: "1", Name: "11"},
{ID: "2", Name: "22"},
{ID: "3", Name: "33"},
{ID: "4", Name: "44"},
{ID: "5", Name: "55"},
}
// user := User{ID: "1", Name: "AAAA"... |
package kayzen
import (
"encoding/json"
"testing"
"github.com/prebid/prebid-server/openrtb_ext"
)
var validParams = []string{
`{ "zone": "dc", "exchange": "ex" }`,
}
func TestValidParams(t *testing.T) {
validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
if err != nil {
t.Fa... |
// 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 arcappcompat will have tast tests for android apps on Chromebooks.
package arcappcompat
import (
"context"
"strings"
"time"
"chromiumos/tast/common/action"
... |
package function
import (
"errors"
"testing"
)
// ------------------------------------------------------------------------------------------------------
func TestPageInstructionCanBeAddedToInstruction(t *testing.T) {
PageInstructionTestID := "0x12"
InstructionTestID := "0x13"
executor := Executor{
Store: Mock... |
/*
genaccessor is accsessor generator for Go.
```go
type Foo struct {
key string `getter:"[alias,]..." setter:"[alias,]..."`
}
```
with `go generate` command
```go
//go:generate go-genaccessor
```
*/
package genaccessor
import (
"bytes"
"go/ast"
"go/format"
"io"
"os"
"reflect"
"strings"
... |
/*
Copyright 2020 Docker Compose CLI 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 a... |
// 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 retry
import (
"chromiumos/tast/errors"
)
// Loop is a representation of retry loop state for a test.
type Loop struct {
Attempts int
MaxAttempts int
DoRetri... |
package manifest
import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/SUSE/go-patch/patch"
"github.com/pkg/errors"
boshtpl "github.com/cloudfoundry/bosh-cli/director/template"
)
// InterpolateFromSecretMounts reads explicit secrets from a folder and writes an interpolated manifest... |
package main
import (
"github.com/alberliu/gn/util"
"log"
"net"
"strconv"
"time"
)
var codecFactory = util.NewHeaderLenCodecFactory(2, 1024)
func main() {
var conns []net.Conn
for i := 0; i < 20000; i++ {
conn, err := net.Dial("tcp", "172.16.58.235:80")
if err != nil {
log.Println("error dialing", err.... |
package builder
import (
corev1 "k8s.io/api/core/v1"
kubevirtv1 "kubevirt.io/client-go/api/v1"
)
const (
CloudInitTypeNoCloud = "noCloud"
CloudInitTypeConfigDrive = "configDrive"
CloudInitDiskName = "cloudinitdisk"
)
type CloudInitSource struct {
CloudInitType string
UserDataSecretName s... |
package fibonacci
import (
"testing"
"math/big"
)
func TestSetGet(t *testing.T) {
fibContract := NewFibonacci()
for i := 0; i < 10; i++ {
bigI := big.NewInt(int64(i))
ithFib := fib(i);
bigFibFor := fibContract.FibFor(bigI)
if ithFib != bigFibFor.Int64() {
t.Fatalf("%dth for fibonacci returned %d in... |
/*
* Copyright IBM Corporation 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 o... |
// +build !race
package hrtime_test
import (
"testing"
"time"
"github.com/loov/hrtime"
)
func TestCountCalibration(t *testing.T) {
if !hrtime.TSCSupported() {
t.Skip("Cycle counting not supported")
}
start := hrtime.TSC()
for i := 0; i < 64; i++ {
empty()
}
stop := hrtime.TSC()
if stop-start < hrtim... |
package main
import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"strconv"
"github.com/urfave/cli"
"gitlab.com/byzantine-lab/tan-monitor/monitor"
)
var app *cli.App
func init() {
app = cli.NewApp()
app.Name = filepath.Base(os.Args[0])
app.Usage = "Tangerine Newtwork Monitor"
app.Commands = []cli.Comma... |
package main
import "fmt"
func main() {
numbers := []int{14, 33, 27, 10, 35, 19, 42, 44}
sortedNums := selectionSort(numbers, 0)
fmt.Println(sortedNums)
}
func indexOfSmallestNumInList(numbers []int, index int) int {
smallestNumberIndex := index
for i := index; i < len(numbers); i++ {
if numbers[i] < numbers[... |
package model
type RechargeConfirmParam struct {
Uniacid int `json:"uniacid" form:"uniacid" bind:"required"`
Openid string `json:"openid" form:"openid" bind:"required"`
Logno string `json:"logno" form:"logno" bind:"required"`
}
|
package main
import (
"os"
"fmt"
"encoding/csv"
)
func main() {
f, err := os.Open("../../Environmental_Data_Deep_Moor_2015.txt")
if err != nil {
panic(err)
}
defer f.Close()
rdr := csv.NewReader(f)
rdr.Comma = '\t'
fmt.Println(rdr.TrimLeadingSpace)
rdr.TrimLeadingSpace = true
fmt.Println(rdr.TrimLeadin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.