text stringlengths 11 4.05M |
|---|
/*
Copyright 2021 Dynatrace 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 by applicable law or agreed to in writing, software
... |
// 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 arc
import (
"context"
"strconv"
"time"
"chromiumos/tast/common/android/ui"
"chromiumos/tast/errors"
"chromiumos/tast/local/arc"
"chromiumos/tast/local/chrom... |
package db
import (
"main/app"
)
// GetTools ..
func GetTools(s string, args ...interface{}) (Tools []app.Tool, err error) {
sq := "SELECT `id`,`name`,`desc`,`link`,`logo`,`top` FROM tool LIMIT ?,?"
if s != "" {
sq = "SELECT `id`,`name`,`desc`,`link`,`logo`,`top` FROM tool WHERE " + s
}
rows, err := db.Query(s... |
package servers
import (
"net"
"fmt"
"encoding/binary"
)
type Proxy struct {
client1, client2 net.Conn
listener net.Listener
}
func NewProxy() *Proxy {
return &Proxy{nil, nil, nil}
}
//blocks
func (p *Proxy) Listen(l net.Listener) error {
c, err := l.Accept()
if err != nil {
return err
}
p.... |
package main
import (
"bytes"
"context"
"encoding/json"
"io/ioutil"
"log"
"net/http"
"strconv"
"strings"
"time"
"gopkg.in/yaml.v3"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client"
"github.com/martinlindhe/base36"
)
// Azure Sheduled Ev... |
package persistence
import (
"encoding/csv"
"fmt"
"os"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/kr/pretty"
"github.com/Okaki030/hinagane-scraping/domain/repository"
)... |
package assets
import "io/fs"
var (
// Web is the embedded dist file system
Web fs.FS
// I18n is the embedded i18n file system
I18n fs.FS
)
// Live indicates assets are passed-through from filesystem
func Live() bool {
return Web != nil
}
|
package common
type Stack interface {
Push(val interface{})
Pop() (interface{}, error)
Peek() (interface{}, error)
IsEmpty() bool
HasNext() bool
}
|
package main
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"regexp"
"strconv"
"strings"
"time"
log "github.com/Sirupsen/logrus"
"github.com/labstack/echo"
"github.com/labstack/echo/engine/standard"
"github.com/SUSE/stratos-ui/components/app-core/backend/repository/interfaces"
"github.co... |
package main
import (
"fmt"
"net/http"
"strconv"
"strings"
"time"
likes "github.com/4726/discussion-board/api-gateway/pb/likes"
postsread "github.com/4726/discussion-board/api-gateway/pb/posts-read"
postswrite "github.com/4726/discussion-board/api-gateway/pb/posts-write"
search "github.com/4726/discussion-bo... |
package scorer
import (
"math/rand"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/joshprzybyszewski/cribbage/model"
)
func BenchmarkHandPoints(b *testing.B) {
hands := make([][]model.Card, 10000)
for i := range hands {
hands[i] = randomHand(b, 5... |
package pathsum
// TreeNode is a definition for a binary tree node.
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func hasPathSum(root *TreeNode, sum int) bool {
if root == nil {
return false
}
return testSumPath(root, 0, sum)
}
func testSumPath(node *TreeNode, subTotal int, sum int) boo... |
package linqo
import (
"database/sql"
"fmt"
"math"
"strconv"
_ "github.com/mattn/go-sqlite3"
)
type customer struct {
lastName string
firstName string
totalSpending float64
}
func (c customer) String() string {
return fmt.Sprintf("%10s, %10s: $%7.2f", c.lastName, c.firstName, c.totalSpending)
}
f... |
// 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... |
// Copyright (C) 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed t... |
package main
import (
db "BarcodeApi/database"
"BarcodeApi/initRouter"
"fmt"
"github.com/gin-gonic/gin"
"gopkg.in/ini.v1"
"io"
"os"
)
func main() {
cfg, err := ini.Load("./conf/config.ini")
if err != nil{
fmt.Println("error: %d\n",err)
return
}
f, _ := os.Create("gin_log")
gin.DefaultWriter = io.MultiWriter(f... |
package iafon
import (
"net/http"
"strings"
"testing"
)
func TestServeHTTP(t *testing.T) {
var echo string
r := newRouter()
method := "GET"
path := "/func"
r.Handle(method, path, func(c *Context) {
echo = c.Req.URL.Path
})
req, _ := http.NewRequest(method, "http://localhost"+path, nil)
r.ServeHTTP(n... |
package datamodel
import (
"encoding/json"
"errors"
"fmt"
"github.com/TeoSocs/alisi-client/crypto"
"github.com/dgrijalva/jwt-go"
"github.com/op/go-logging"
"io/ioutil"
"os"
"path"
)
var log = logging.MustGetLogger("alisi")
const CLAIM_FOLDER = "claims"
func (c EncodedClaim) CreateAndStore() (err error) {
... |
// Defining the `storage` command.
package cmd
import (
"errors"
"fmt"
"strings"
"github.com/JosephLai241/shift/models"
"github.com/JosephLai241/shift/utils"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// storageCmd represents the storage command.
var storageCmd = &cobra.Command{
Use: "storage",
... |
package main
//147. 对链表进行插入排序
//插入排序算法:
//
//插入排序是迭代的,每次只移动一个元素,直到所有元素可以形成一个有序的输出列表。
//每次迭代中,插入排序只从输入数据中移除一个待排序的元素,找到它在序列中适当的位置,并将其插入。
//重复直到所有输入数据插入完为止。
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func insertionSortList(head *ListNode) *ListNode {... |
package LeetCode
import "fmt"
func Code46() {
nums := []int{1, 2, 3}
fmt.Println(permute(nums))
}
/**
给定一个没有重复数字的序列,返回其所有可能的全排列。
示例:
输入: [1,2,3]
输出:
[
[1,2,3],
[1,3,2],
[2,1,3],
[2,3,1],
[3,1,2],
[3,2,1]
]
```
*/
func permute(nums []int) [][]int {
var res [][]int
dfs_46(nums, []int{}, &res)
re... |
// Package zerokit helps with zero value related use-cases such as initialisation.
package zerokit
import (
"fmt"
"github.com/adamluzsi/frameless/pkg/internal/pointersync"
"reflect"
"sync/atomic"
)
// Coalesce will return the first non-zero value from the provided values.
func Coalesce[T any](vs ...T) T {
for _,... |
// Copyright (c) 2015 RightScale Inc, All Rights Reserved
package demo
import (
"github.com/zenazn/goji/web"
"github.com/zenazn/goji/web/middleware"
)
// NewMux returns a handler/mux for the demo requests and adds the local handlers to this mux
func NewMux() *web.Mux {
mx := web.New()
mx.Use(middleware.SubRouter... |
package gomc
import (
"fmt"
)
func TrialMain(args []string) {
fmt.Println(args)
var a int = 100
var b float64
var c string
var d bool
fmt.Printf("a: %d, b:%f, c:%s, d:%t\n", a, b, c, d)
} |
package util
import (
"bufio"
"io"
"io/ioutil"
"os"
"path/filepath"
)
// 列出指定目录下的所有文件
// 会通过 filterFn 传入的方法进行过滤
func ListFiles(dir string, filterFn func(file os.FileInfo) bool) ([]string, error) {
files, err := ioutil.ReadDir(dir)
if err != nil {
return nil, err
}
rc_files := make([]string, 0, 10)
for _... |
package ukpolice
import (
"context"
"encoding/json"
"fmt"
"net/http"
"reflect"
"testing"
)
var rawSearch = `
[
{
"age_range": "10-17",
"self_defined_ethnicity": "White - White British (W1)",
"outcome_linked_to_object_of_search": true,
"datetime": "2017-01-14T20:50:00+00:00",
"removal_of_more_t... |
package twitterstream
import (
"github.com/fallenstedt/twitter-stream/httpclient"
"net/http"
)
type (
// UnmarshalHook is a function that will unmarshal json.
UnmarshalHook func([]byte) (interface{}, error)
// IStream is the interface that the stream struct implements.
IStream interface {
StartStream(queryPa... |
package actions
import (
"log"
"os"
"path/filepath"
)
type releaseName struct {
Full string
Short string
}
var (
// TODO: https://github.com/deis/deisrel/issues/12
repoToComponentNames = map[string][]string{
"builder": {"Builder"},
"controller": {"Controller"},
"dockerbuilder": {"Dock... |
// 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... |
package gateway
import (
"fmt"
"io/ioutil"
"net/url"
"bytes"
"strings"
"net/http"
"encoding/json"
"net/http/httputil"
"errors"
"regexp"
"github.com/gorilla/mux"
"../util"
. "../types"
"../config"
)
type Server struct {
*config.Config
}
func (server *Server) Start() error {
router := mux.NewRouter()... |
package ingress
import (
"encoding/json"
"errors"
appCore "alauda.io/app-core/pkg/app"
"alauda.io/diablo/src/backend/api"
"alauda.io/diablo/src/backend/resource/common"
extensions "k8s.io/api/extensions/v1beta1"
metaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"... |
package pollslack_test
import (
"os"
"testing"
"github.com/wambosa/expect"
"github.com/wambosa/confman"
"github.com/wambosa/pollslack"
)
var userId string
func TestMain(m *testing.M){
conf, err := confman.LoadJson("conf.test")
if err != nil {panic(err)}
pollslack.Config... |
package main
import "fmt"
type stack []string
func (s stack) Push(v string) stack {
return append(s, v)
}
func (s stack) Pop() (stack, string) {
// FIXME: What do we do if the stack is empty, though?
l := len(s)
if l <= 0 {
return s, ""
}
return s[:l-1], s[l-1]
}
func evalBalance(cur string, prev string... |
package secret
import (
"fmt"
"strconv"
)
//Creates or tests the handshake
func Handshake(num uint) []string {
binary := strconv.FormatInt(int64(num), 2)
fmt.Println(binary)
return make([]string, 1)
}
|
package gdpr
import (
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/openrtb_ext"
)
// ConsentWriter implements the PolicyWriter interface for GDPR TCF.
type ConsentWriter struct {
Consent string
RegExtGDPR *int8
}
// Write mutates an OpenRTB bid request with the GDPR TCF consent.
f... |
package websteps
import "net/http"
// Websteps test helper spec messages:
// CtrlRequest is the request sent by the probe to the test helper.
type CtrlRequest struct {
// URL is the mandatory URL to measure.
URL string `json:"url"`
// Headers contains optional headers.
Headers map[string][]string `json:"headers... |
//灯杆管理
package controllers
import (
"fmt"
"strconv"
"smartCity/models"
)
type StrategyController struct {
BaseController
}
func (this *StrategyController) Prepare() {
this.headerFile = "include/header.html"
// this.sidebarFile = "include/strategySidebar.html"
this.footerFile = "include/footer.html"
this.layo... |
package models
import (
"fmt"
"github.com/go-playground/validator/v10"
"gopkg.in/yaml.v3"
"log"
"seeder/constants"
"seeder/utils"
)
type YamlConfig struct {
DeployPolicy string `yaml:"deploy_policy" validate:"required,oneof=fill robin random"`
AccessToken string `yaml:"access_token" validate:"required,mi... |
package logger
import (
"fmt"
"runtime"
"testing"
)
func TestFailLog(t *testing.T) {
fmt.Println(runtime.GOARCH)
}
|
package chi
import (
"context"
"log"
"net/http"
firebase "firebase.google.com/go"
firebaseAuth "firebase.google.com/go/auth"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/chi/v5"
"github.com/go-chi/cors"
admin "github.com/hi-sasaki/clean-architecture-golang-sample/pkg/adapter/controller/admin"
"gith... |
// Copyright (c) 2016-2019 Uber Technologies, 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... |
package player
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"regexp"
)
type UP_date struct {
UID string
Name string
Sex string
Face string
Follower string
Following string
}
//==================================================================================
//名字: GetUpDate(mid string)UP_date
//功能: 通过uid获取对... |
package justTest
func Liuxuan() {
Println("这是一个测试")
}
|
//
// Copyright (c) 2019-present Codist <countstarlight@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// Written by Codist <countstarlight@gmail.com>, March 2019
//
package main
import (
"fmt"
"github.com/countstarlight/homo/... |
/* project: gobyexample_cn
author:diogo
time: 2016/11/16-13:52
*/
/**
Go 闭包函数
Go支持匿名函数,匿名函数可以形成闭包。闭包函数可以访问定义闭包的函数定义的内部变量。
*/
/**
示例 02
package main
import "fmt"
func main() {
add10 := closure(10) //其实是构造了一个加10函数
fmt.Println(add10(5)) //15
fmt.Println(add10(6)) //16
add20 := closure(20)
fmt.Println(ad... |
package services
import (
"log"
"github.com/go-playground/locales/en"
"github.com/go-playground/locales/vi"
ut "github.com/go-playground/universal-translator"
"github.com/pkg/errors"
)
var Uni *ut.UniversalTranslator
// initialize uni
func init() {
fallback := en.New()
Uni = ut.New(fallback, fallback, vi.Ne... |
/**
* author: NoChopFoundation@gmail.com
*/
package topshot
import (
log "github.com/sirupsen/logrus"
"github.com/onflow/flow-go-sdk"
"github.com/onflow/flow-go-sdk/client"
)
type OnSaleMomentDetailsAvailableFunc func(*client.BlockEvents, MomentPurchasedListedChangedEvent, SaleMomentBatch)
type QueryTopShot_Bl... |
package configoration
import "fmt"
// ConfigMap extends map[string]interface{} with
// functionalities to merge two of them together.
type ConfigMap map[string]interface{}
// merge combines confMap with m by merging.
//
// Existing keys are owerwritten and non-
// existing keys are added to m.
func (m ConfigMap) mer... |
package main
import (
"fmt"
"math/big"
"time"
)
func main() {
time1 := time.Now()
fmt.Println(sum(1000000000).String())
time2 := time.Now()
fmt.Println(time2.Sub(time1))
}
// Calculates the sum of all numbers from 1 to x
func sum(x int64) *big.Int {
var i int64
var ret big.Int
for i = 1; i <= x; i++ {
re... |
// Copyright 2021 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() {
numbers := []int{1, 2, 3, 4, 5}
fmt.Println(Sum(numbers))
}
// Sum adds together all elements of the given array
func Sum(numbers []int) int {
sum := 0
for _, number := range numbers {
sum += number
}
return sum
}
// SumAll adds numbers in two slices and returns ... |
package generator
import (
"time"
)
// CurrentDateTime generates current datetime.
func CurrentDateTime() string {
return time.Now().Format(time.RFC3339)
}
|
package main
import ( //"fmt"
// Development version of Kivik
//"github.com/go-kivik/kivik"
"context"
"encoding/json"
"io/ioutil"
"net/http"
"github.com/flimzy/kivik"
_ "github.com/go-kivik/couchdb" // The CouchDB driver
"github.com/labstack/echo/v4"
)
func InitDBService(e *echo.Echo) {
e.GET("/db/:db/:id"... |
package main
import "fmt"
type person struct {
name string
}
func (p person) string() string {
return "the person name is:" + p.name
}
func (p person) modify() {
p.name = "李四"
}
func (p *person) modifyutpr() {
p.name = "李四"
}
func main() {
p := person{name: "张三"}
p.modify()
fmt.Println(p.string())
p.modi... |
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package codegen contains shared utilities for generating code.
package codegen
import (
"bytes"
"fmt"
"go/ast"
"go/format"
"go/token"
"go/... |
package main
import (
"encoding/json"
"fmt"
valid "github.com/asaskevich/govalidator"
"github.com/boltdb/bolt"
"github.com/bradialabs/shortid"
"github.com/julienschmidt/httprouter"
"log"
"net/http"
"strings"
)
var boltDBPath = "/db/url.db"
var shortUrlBkt = []byte("shortUrlBkt")
var dbConn *bolt.DB
type ... |
package backend_test
import (
"testing"
"github.com/raba-jp/primus/pkg/backend"
"github.com/raba-jp/primus/pkg/exec"
fakeexec "github.com/raba-jp/primus/pkg/exec/testing"
"github.com/spf13/afero"
)
func TestDetectOS(t *testing.T) {
tests := []struct {
name string
mockStdout string
mockFs func()... |
// Copyright (C) 2015 Foursquare Labs Inc.
package main
import (
"encoding/hex"
"log"
"math/rand"
"reflect"
"sort"
"sync"
"time"
"github.com/foursquare/fsgo/report"
"github.com/foursquare/quiver/gen"
"github.com/foursquare/quiver/util"
)
func renderErr(raw error) string {
msg := raw.Error()
switch e := ... |
package models
type Blood struct {
ID int `gorm:"AUTO_INCREMENT,primary_key" json:"id"`
Type string `json:"type"`
}
|
package gotham
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewRouterHandle(t *testing.T) {
r := New()
r.Handle("pb.Hello", func(c *Context) {})
assert.Equal(t, 0, len(r.groups))
assert.Equal(t, "pb.Hello", r.nodes[0].name)
r.Handle("pb.Bye", func(c *Context) {})
assert.Equal(t, 0, l... |
package types
// Helper functions for testing
import (
cmn "github.com/tendermint/go-common"
"github.com/tendermint/go-crypto"
)
// Creates a PrivAccount from secret.
// The amount is not set.
func PrivAccountFromSecret(secret string) PrivAccount {
privKey := crypto.GenPrivKeyEd25519FromSecret([]byte(secret))
pr... |
// Copyright (C) 2016 Space Monkey, 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... |
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
//go:build e2e
// +build e2e
package installation
import (
"github.com/mattermost/mattermost-cloud/e2e/workflow"
)
func versionedS3BucketInstallationLifecycleSteps(clusterSuite *workflow.ClusterSuite,... |
package parser
import (
"encoding/json"
"fmt"
"strings"
)
func ParseLine(input string) (*goTestJsonLogLine, error) {
// e.g. "go: downloading github.com/hashicorp/azure-sdk-for-go [..]"
if strings.HasPrefix(input, "go:") {
return nil, nil
}
var output goTestJsonLogLine
if err := json.Unmarshal([]byte(inpu... |
package main
import (
"io/ioutil"
)
var (
ignore = map[string]bool{
".DS_Store": true,
"node_modules": true,
"__pycache__": true,
"Machine Learning A-Z Template Folder": true,
"HandOnML": true,
"MLPro... |
// Copyright 2021 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 AzureDevopsClient
import (
"encoding/json"
"fmt"
"net/url"
"strings"
"time"
)
type ReleaseDeploymentList struct {
Count int `json:"count"`
List []ReleaseDeployment `json:"value"`
}
type ReleaseDeployment struct {
Id int64 `json:"id"`
Name string
Release struct {
Id int64
... |
// Written in 2014 by Petar Maymounkov.
//
// It helps future understanding of past knowledge to save
// this notice, so peers of other times and backgrounds can
// see history clearly.
package see
import (
// "fmt"
. "github.com/gocircuit/escher/image"
)
func SeeMatching(src *Src) (x Image) {
defer func() {
if... |
package main
import (
"os"
"fmt"
"log"
)
func Exists(name string) bool {
if _, err := os.Stat(name); err != nil {
if os.IsNotExist(err) {
return false
}
}
return true
}
func main() {
if len(os.Args) < 2 {
fmt.Println("need arg file!")
return
... |
package router
import (
"github.com/kataras/iris"
"go-iris-mv/config"
"go-iris-mv/controller"
"os"
)
func Routers() {
db := config.GetDatabaseConnection()
inDB := &controller.InDB{DB: db }
app := iris.Default()
// for / endpoint
app.Get("/", controller.WelcomeController)
// example group: v1
v1:= app.Part... |
package grizzly
import (
"fmt"
"strings"
"github.com/gobwas/glob"
)
// Provider describes a single Endpoint Provider
type Provider interface {
Group() string
Version() string
APIVersion() string
GetHandlers() []Handler
}
// ProviderSet records providers
type registry struct {
Providers []Provider
Handle... |
package ingester
import (
"context"
"fmt"
"math/rand"
"net/http"
"strconv"
"time"
gklog "github.com/go-kit/kit/log"
"github.com/google/uuid"
ot "github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
otlog "github.com/opentracing/opentracing-go/log"
"github.com/pkg/errors"
"gi... |
package framework
import (
"context"
"testing"
)
func Test_Framework_Resource_PatchNoPanic(t *testing.T) {
testCases := []struct {
ProcessMethod func(ctx context.Context, obj interface{}, rs []Resource) error
Resources []Resource
ErrorMatcher func(err error) bool
}{
// Test 0 ensures ProcessDelete re... |
package main
import (
"fmt"
"net/http"
flag "github.com/bborbe/flagenv"
"runtime"
"time"
"github.com/bborbe/backup/model"
backup_status_fetcher "github.com/bborbe/backup/status/client/fetcher"
"github.com/bborbe/backup/status/client/fetcher/cache"
backup_status_handler "github.com/bborbe/backup/status/cli... |
// 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 console
import (
"fmt"
"os"
"os/exec"
"runtime"
)
// Output implements the io.Writer interface. We use it to redraw the console.
type Output struct{}
// Write redraws the screen with the contents of p.
func (_ *Output) Write(p []byte) (int, error) {
switch runtime.GOOS {
case "darwin":
fallthrough
c... |
package main
// // This file shows how the generated lists are to be used in user-code.
// // For tests, see: list_test.go
// import (
// "list-tryout/gen-go/list"
// "log"
// )
// func main() {
// log.Println("Showing ListInt32.")
// {
// myListInt32 := list.NewListInt32()
// myListInt32.Push(42)
// myLis... |
package response
import (
"encoding/json"
"net/http"
)
type RetData struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
func MJson(w http.ResponseWriter, code int, msg string, data interface{}) {
//设置返回头信息
w.Header().Set("Content-Type", "application/json;cha... |
//+build e2e
// Copyright 2020-2021 Clastix Labs
// SPDX-License-Identifier: Apache-2.0
package e2e
import (
"context"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
... |
// 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 main
import (
"fmt"
"io"
"os"
"os/exec"
"os/signal"
"syscall"
)
var (
debug bool
)
func init() {
if os.Getenv("GINIT_DEBUG") != "" {
debug = true
}
}
func main() {
sigs := make(chan os.Signal, 1)
registerSignals(sigs)
if len(os.Args) <= 1 {
printf("Nothing to do.")
os.Exit(-1)
}
cmd :=... |
// Copyright 2015 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 model
import (
"errors"
"fmt"
"regexp"
"strconv"
"strings"
"github.com/7phs/coding-challenge-search/config"
"github.com/7phs/coding-challenge-search/errCode"
"github.com/7phs/coding-challenge-search/nlp"
"github.com/c2h5oh/datasize"
)
const (
limitWordsCount = 32
)
var (
filterAlphaNum = regex... |
package iterators_test
import (
"errors"
"io"
"testing"
"github.com/adamluzsi/frameless/ports/iterators"
"github.com/adamluzsi/testcase"
"github.com/adamluzsi/testcase/assert"
)
func TestWithCallback(t *testing.T) {
s := testcase.NewSpec(t)
s.Parallel()
s.When(`no callback is defined`, func(s *testcase.Sp... |
package configValidator
import "reflect"
import "fmt"
func validateField(field reflect.StructField, v reflect.Value) error {
if required, ok := field.Tag.Lookup("required"); ok {
if required == "true" {
value := v.FieldByName(field.Name)
isOk := false
switch field.Type.Name() {
case "string":
isOk... |
package lib
import (
"crypto/ecdsa"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"
"log"
"math/big"
"net"
"os"
"path"
"path/filepath"
"time"
)
func GenerateCertificates(config Configuration) error {
for _, certConfig := range config.Certificates {
if err := issueCer... |
package service
import (
"context"
"github.com/traPtitech/trap-collection-server/src/domain"
"github.com/traPtitech/trap-collection-server/src/domain/values"
)
//go:generate go run github.com/golang/mock/mockgen -source=$GOFILE -destination=mock/${GOFILE} -package=mock
type GameRoleV2 interface {
//EditGameMana... |
package artifact
import (
"bytes"
"encoding/json"
"fmt"
"github.com/gimlet-io/gimletd/dx"
"github.com/urfave/cli/v2"
"gopkg.in/yaml.v3"
"io/ioutil"
"strings"
)
var artifactAddCmd = cli.Command{
Name: "add",
Usage: "Adds items to a release artifact",
UsageText: `gimlet artifact add \
--field n... |
// factory generator with functional approach
package main
import "fmt"
type Employee struct {
Name, Position string
AnnualIncome int
}
// functional
func NewEmployeeFactory(position string, annualIncome int) func(name string) *Employee {
return func(name string) *Employee {
return &Employee{name, position, ... |
package controllers
import (
"net/http"
"strconv"
"time"
"github.com/gin-gonic/gin"
"github.com/go-ignite/ignite/models"
"github.com/go-ignite/ignite/ss"
)
func (router *MainRouter) ResetAccountHandler(c *gin.Context) {
uid, err := strconv.Atoi(c.Param("id"))
if err != nil {
resp := models.Response{Succes... |
package loginmodule
import (
"reflect"
"time"
"encoding/json"
"github.com/liasece/micchaos/ccmd"
"github.com/liasece/micchaos/playermodule/boxes"
"github.com/liasece/micserver/servercomm"
"github.com/liasece/micserver/session"
"github.com/liasece/micserver/util/math"
"github.com/liasece/micserver/util/monit... |
package lru_cache
import (
"time"
"github.com/minotar/imgd/pkg/cache"
memory_expiry "github.com/minotar/imgd/pkg/cache/util/expiry/memory"
"github.com/minotar/imgd/pkg/storage/lru_store"
)
type LruCache struct {
*lru_store.LruStore
*memory_expiry.MemoryExpiry
*LruCacheConfig
}
type LruCacheConfig struct {
c... |
package function
import (
"errors"
"github.com/hecatoncheir/Storage"
"testing"
)
// ------------------------------------------------------------------------------------------------------
func TestPriceCanBeCreated(t *testing.T) {
priceForCreate := storage.Price{ID: "0x12", Value: 0.0, IsActive: true}
executor :... |
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
)
// https://qiita.com/nayuneko/items/3c0b3c0de9e8b27c9548
type DownloadError struct {
StatusCode int
}
func (e *DownloadError) Error() string {
return "httpd error!"
}
type SaveError struct {
Filename, Message string
}
func (e *SaveE... |
package messagebox
type MessageList struct {
Id string `json:"id"`
Dt string `json:"datetime"`
Flags []string `json:"flags"`
}
|
// Copyright (c) 2016-2019 Uber Technologies, 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... |
package main
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"text/tabwriter"
"github.com/ghetzel/cli"
"github.com/ghetzel/go-stockutil/fileutil"
"github.com/ghetzel/go-stockutil/log"
"github.com/ghetzel/go-stockutil/typeutil"
)
func main() {
app := cli.NewApp()
app.Name = `pman`
app.Usage = `Like re... |
package main
import (
"fmt"
"golang.org/x/crypto/ssh"
"html/template"
"log"
"net"
"net/http"
)
//----------------------------------------------------------------------------------------------------------------------
type Data struct {
URL string
Port string
Login string
Password string
}
var da... |
package main
import (
"log"
"net/http"
"time"
)
func timeHandler(format string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
tm := time.Now().Format(format)
w.Write([]byte("The time is: " + tm))
}
}
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/time", timeHandler(t... |
// Copyright (c) KwanJunWen
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
package estemplate
import "fmt"
// TokenFilterWordDelimiter token filter that splits words into subwords and performs optional
// transformations on subword groups... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.