text stringlengths 11 4.05M |
|---|
package main
import (
"github.com/atymkiv/sa/cmd/subscribers/service"
"github.com/atymkiv/sa/pkg/utl/config"
"github.com/atymkiv/sa/pkg/utl/nats"
"sync"
)
func main() {
cfg, err := config.Load("./config/subscribers.yaml")
checkErr(err)
natsClient, err := nats.New(cfg.Nats)
checkErr(err)
service.Subscriber(... |
// 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 rule
import (
"sync"
"go.uber.org/atomic"
)
// A node containing information about a domain component.
type node struct {
// The domain component's value.
Value string
// Whether or not this domain component is blocked.
Blocked *atomic.Bool
// The complete domain which this domain component is a par... |
// 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 (
"crypto/tls"
"io"
"log"
"time"
)
//时间数据做了一点改动,因为毫秒总会有误差
var stimes = [25]int{122, 163, 204, 205, 245, 246, 247, 248, 249, 250, 251, 252,
285, 286, 287, 288, 289, 290, 291, 325, 326, 327, 328, 759, 844,
}
//var stimes = [25] int {122, 163, 204, 205, 245, 246, 247, 248, 249, 250, 251, 252,
/... |
// Copyright 2018 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
package main
import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/keybase/kbfs/libpages/config"
"github.com/stretchr/testify/require"
"gol... |
package ginlogruslogstash
import (
"bytes"
"fmt"
"log"
"math"
"net"
"net/http"
"time"
logrustash "github.com/bshuster-repo/logrus-logstash-hook"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)
var timeFormat = "02/Jan/2006:15:04:05"
type bodyLogWriter struct {
gin.ResponseWriter
body *bytes.Bu... |
package orm
import (
"fmt"
"github.com/muidea/magicOrm/builder"
"github.com/muidea/magicOrm/model"
"github.com/muidea/magicOrm/util"
)
type resultItems []interface{}
func (s *impl) querySingle(vModel model.Model, filter model.Filter, deepLevel int) (ret model.Model, err error) {
var queryValue resultItems
fun... |
package routing
import (
"github.com/gin-gonic/gin"
"github.com/kamalraimi/recruiter-api/controllers"
"github.com/kamalraimi/recruiter-api/middlewares"
)
func Routes(route *gin.Engine) {
//route.Use(middlewares.CORSMiddleware()) // CORS
route.POST("/recruiter-api/login", middlewares.GinJwtMiddlewareHandler().L... |
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package main
import (
"github.com/mattermost/mattermost-cloud/model"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
func newCmdSubscription() *cobra.Command {
cmd := &cobra.Command{
Use: "su... |
package main
import (
"assignments-tichx/servers/gateway/models/users"
"assignments-tichx/servers/gateway/sessions"
"assignments-tichx/servers/handlers"
"database/sql"
"fmt"
"log"
"net/http"
"net/http/httputil"
"net/url"
"os"
"strings"
"time"
"github.com/go-redis/redis"
)
//main is the main entry point ... |
package gostringutil
import "testing"
func assertReverse(t *testing.T, input, got, expected string) {
if got != expected {
t.Errorf("Reverse(%q) == %q, expected %q", input, got, expected)
}
}
func TestSimpleReverse(t *testing.T) {
input := "Hello Go!"
expected := "!oG olleH"
got := Reverse(input)
... |
package main
import (
"bufio"
"fmt"
"net"
"os"
"strings"
)
func checkErr(err error) {
if err != nil {
panic(err)
}
}
func main() {
conn, err := net.Dial("tcp", "127.0.0.1:8088")
checkErr(err)
defer conn.Close()
go msgSend(conn) //发送消息
buf := make([]byte, 1024)
for {
length, err := conn.Read(buf) /... |
package controller
import (
"bytes"
"fmt"
"reflect"
"testing"
"time"
"k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
core "k8s.io/client-go/testing"
platform "kolihub.io/koli/pkg/apis/core/v1alpha1"
"kolihu... |
package simple_test
//START, OMIT
import (
"testing" //OMIT
"github.com/stretchr/testify/assert" // HL
)
func TestGetData(t *testing.T) {
data := GetData()
assert.Len(t, data, 1) // HL
assert.Contains(t, data, 10) // HL
}
//STOP, OMIT
//STARTCONTAINS10, OMIT
func TestGetData_Contains10(t *testing.T) {
... |
// Copyright (C) 2016-Present Pivotal Software, Inc. All rights reserved.
// This program and the accompanying materials are made available under the terms of the 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 Licen... |
// 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, ... |
// 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... |
// 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.
// This file implements implements interfaces and generic structs for power measurement
package power
import (
"time"
"chromiumos/tast/remote/firmware/suspend"
)
// Res... |
// The package implements a minimal set of Azure Event Hubs functionality.
//
// We could use https://github.com/Azure/azure-event-hubs-go but it's too huge
// and also it has a number of dependencies that aren't desired in the project.
package eventhub
import (
"context"
"crypto/rand"
"crypto/tls"
"encoding/hex"
... |
package main
import (
"flag"
"fmt"
"github.com/KarmaPenny/pdfparser/pdf"
"os"
)
// print help info
func usage() {
fmt.Fprintln(os.Stderr, "PDF Parser - decodes a pdf file")
fmt.Fprintf(os.Stderr, "https://github.com/KarmaPenny/pdfparser\n\n")
fmt.Fprintf(os.Stderr, "usage: pdfparser [options] file\n\n")
fmt.F... |
package releaser
import (
"fmt"
"github.com/aevea/release-notary/internal/github"
"github.com/aevea/release-notary/internal/gitlab"
"github.com/aevea/release-notary/internal/release"
)
// Service describes the basic usage needed from a service such as Github
type Service interface {
LatestRelease() (*release.Re... |
package arrays
import "testing"
func TestArrayIntOne(t *testing.T) {
var v []int
if err := Unmarshal([]byte("{1}"), &v); err != nil {
t.Fatalf("Unexpected error, %v", err)
}
if expected := 1; len(v) != expected {
t.Errorf("Expected array to have length %d, got %d", expected, len(v))
}
if expected := 1; v... |
package ravendb
import (
"net/http"
"reflect"
"strconv"
)
var (
_ IOperation = &GetCompareExchangeValuesOperation{}
)
type GetCompareExchangeValuesOperation struct {
Command *GetCompareExchangeValuesCommand
_clazz reflect.Type
_keys []string
_startWith string
_start int // -1 for unset
_pageSize in... |
package repository
import (
"model"
"github.com/jmoiron/sqlx"
"github.com/hashicorp/go-multierror"
)
type ICategoryRepository interface {
FindAllCategories() (*[]model.Category, error)
FindCategoryById(id int) (*model.Category, error)
CreateCategory(category model.Category) (int, error)
UpdateCategory(category... |
package pokergame
//冒泡排序法对整数排序
func BubbleSortIntMin2Max(ints []int){
length := len(ints)
for i :=0;i<length;i++{
for j := i;j < length;j++{
if ints[i] > ints[j]{
ints[i],ints[j] = ints[j],ints[i]
}
}
}
}
|
/*
Copyright 2017 The Kubernetes 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, ... |
package keepassrpc
import (
"crypto/sha256"
"fmt"
)
// MsgKey represents various stages of the challenge/response protocol
type MsgKey struct {
SecurityLevel int `json:"securityLevel"`
SC string `json:"sc,omitempty"` // Server challenge
CC string `json:"cc,omitempty"` // Client challenge
SR s... |
package service
import (
"bytes"
"context"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"encoding/pem"
log "github.com/sirupsen/logrus"
"way-jasy-cron/common/email"
"way-jasy-cron/user/ecode"
"way-jasy-cron/user/internal/model/ent"
)
func (svc *Service) Register(ctx context.Context, user *ent... |
package proxy
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"os"
"time"
myhttp "github.com/Everbridge/go-proxy/http"
"github.com/Everbridge/go-proxy/mapping"
"github.com/Everbridge/go-proxy/statistics"
)
// StartProxyServer starts the proxy server
func StartProxyServer() error {
certFile := os.Getenv("GO_P... |
// 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, ... |
// Copyright © 2020. All rights reserved.
// Author: Ilya Yuryevich.
// Contacts: qioalice@gmail.com, https://github.com/qioalice
// License: https://opensource.org/licenses/MIT
package ekasys
import (
"os"
)
var (
posixCachedUid = uint32(os.Getuid())
posixCachedGid = uint32(os.Getgid())
)
func PosixCachedUid() ... |
// 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, ... |
// Copyright 2020 cloudeng llc. All rights reserved.
// Use of this source code is governed by the Apache-2.0
// license that can be found in the LICENSE file.
package subcmd_test
import (
"context"
"flag"
"fmt"
"runtime"
"strings"
"testing"
"cloudeng.io/cmdutil/subcmd"
"cloudeng.io/errors"
)
func ExampleCo... |
package main
func typecast_expr() {
var a int
var b int
b = int(a)
b = (int)(a)
type num int
var c num
c = num(a)
c = (num)(a)
}
|
package graphite
import (
"io"
"log"
"net"
"strings"
"github.com/influxdb/influxdb"
)
const (
udpBufferSize = 65536
)
// UDPServer processes Graphite data received via UDP.
type UDPServer struct {
writer SeriesWriter
parser *Parser
database string
Logger *log.Logger
}
// NewUDPServer returns a new i... |
package git
import (
"context"
"encoding/json"
"errors"
"fmt"
"github.com/fatih/color"
"sync"
"time"
github "github.com/google/go-github/v29/github"
)
const (
perPage = 100
parallelSize = 20
requestTimeout = time.Second * 10
)
type Readme struct {
Owner string `json:"readme,omitempty"`
Repo ... |
package main
import "fmt"
func main() {
bob := []string{"Bob", "IT guy"}
alice := []string{"Alice", "Instagirl"}
fmt.Println(bob)
fmt.Println(alice)
coop := [][]string{bob, alice}
fmt.Println(coop)
}
|
package main
import (
"flag"
"io/ioutil"
"gopkg.in/yaml.v2"
"goreav/gen"
)
type CliArgs struct {
Generator string
File string
}
var args CliArgs
func init() {
flag.StringVar(&args.File, "f", "", " config")
}
func check(err error) {
if err != nil {
panic(err)
}
}
func main() {
flag.Parse()
//Loa... |
package httpx
import (
"slices"
"net/http"
)
// Controller implements the pattern in
// https://choly.ca/post/go-experiments-with-handler/
type Controller func(w http.ResponseWriter, r *http.Request) http.Handler
func (c Controller) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if h := c(w, r); h != nil {
... |
package leetcode71
import "testing"
func TestSimplifyPath(t *testing.T) {
tests := []struct {
input string
want string
}{
{"/home/", "/home"},
{"///home/", "/home"},
{"/a/./b/../../c/", "/c"},
{"/a/../../b/../../../c", "/c"},
}
format := "simplifyPath(%q) = %q\n"
for _, test := range tests {
got ... |
package main
import (
"fmt"
"github.com/xackery/queryservgo/packet"
"github.com/xackery/queryservgo/queryserv"
"time"
)
var qs *queryserv.QueryServ
func main() {
var err error
/*scm := &packet.ServerChannelMessage{
//DeliverTo: "",
//To: "",
From: "Xuluu_[ShinTwo]",
FromAdmin: 0,
NoReply:... |
package main
import "fmt"
// map 删除和清空
// map 删除 使用delete
func main() {
scene := make(map[string]int)
scene = map[string]int{"route": 66, "brazil": 4, "china": 960}
delete(scene, "route")
//value: 960
//value: 4
for _, i := range scene {
fmt.Printf("value: %d \n", i)
}
// 清空 map 中的所有元素
// Go语言中并没有为 map 提... |
package server
import (
"context"
"encoding/json"
"errors"
"net/http"
kithttp "github.com/go-kit/kit/transport/http"
"github.com/gorilla/mux"
v1 "github.com/turao/go-worker/api/v1"
)
func makeHandler(svc Service) http.Handler {
r := mux.NewRouter()
var opts []kithttp.ServerOption
dispatchHandler := kithtt... |
package requests
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/url"
"strings"
"github.com/google/go-querystring/query"
"github.com/atomicjolt/canvasapi"
"github.com/atomicjolt/canvasapi/models"
"github.com/atomicjolt/string_utils"
)
// CreateGroupCategoryCourses Create a new group category
// https://can... |
package store
import (
"errors"
"strings"
"os"
"fmt"
"bytes"
"io/ioutil"
"compress/gzip"
"github.com/PuerkitoBio/goquery"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
"github.com/astaxie/beego"
)
//OSS配置【这个不再作为数据库表,直接在oss.conf文件中进行配置】
type Oss struct {
EndpointInternal string //内网的endpoint
EndpointOute... |
package controllers
import (
"crypto/md5"
"encoding/base64"
"github.com/astaxie/beego"
"fmt"
)
var (
shortyLookup *beego.BeeCache
)
const DONT_EXPIRE = 0
func init() {
shortyLookup = beego.NewBeeCache()
shortyLookup.Every = DONT_EXPIRE
shortyLookup.Start()
beego.AddFuncMap("printShorties", printShort... |
// 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 pre
import (
"archive/zip"
"context"
"fmt"
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"strings"
"time"
"github.com/golang/protobuf/ptypes/empty"
"chr... |
package consul
import (
"fmt"
"net/http"
consulApi "github.com/hashicorp/consul/api"
)
const (
agentDeregisterAfter = 45
agentCheckInterval = 15
agentCheckTimeout = 5
)
// AgentConfig returns new consul agent config
func (c *Config) AgentConfig() *consulApi.AgentServiceRegistration {
return &consulApi.A... |
package main
import (
"fmt"
"unicode/utf8"
)
//字符串是一种值类型,且值不可变,即创建某个文本后将无法再次修改这个文本的内容,
//更深入地讲,字符串是字节的定长数组。
func main() {
// 使用""来定义字符串 字符串可以使用转义符实现换行缩进等效果 常见的转义符如下所示
// \n 换行 \r 回车符 \t tab键 \u Unicode字符 \\ 反斜杠本身
str := "Java\nGo"
fmt.Println(str)
// 字符串拼接使用+
msg := "一个消息:" + "好消息"
fmt.Println(msg)
// 字... |
package ssh
import (
"crypto"
"crypto/x509"
"encoding/pem"
"io"
"io/ioutil"
"os"
"time"
"golang.org/x/crypto/ssh"
"github.com/pkg/errors"
"github.com/pkg/sftp"
)
type Dialer interface {
Dial(address, username string, timeout time.Duration) (Connection, error)
}
type Connection interface {
UploadFile(pat... |
package main
import (
"fmt"
)
func main() {
nums := []int{9,8,6,3,6,1,2}
fmt.Println(mergeSort(nums))
}
func mergeSort(nums []int) []int {
if len(nums) < 2 {
return nums
}
half := len(nums) / 2
l := mergeSort(nums[:half])
r := mergeSort(nums[half:])
return merge(l,r)
}
func merge(a, b []int) []int {
ret... |
package service
import (
"fmt"
//"time"
"github.com/Caroline1997/Service-Agenda/cli/entity"
)
// log's command
// Login POST /v1/user/login
func Login(name string, password string) (err error) {
var flag bool
flag, err = entity.Check_Login()
if err != nil {
return err
}
if flag == true {... |
package storage
import (
"errors"
pb "github.com/xuperchain/xupercore/kernel/consensus/base/driver/chained-bft/pb"
)
var _ QuorumCertInterface = (*QuorumCert)(nil)
var (
ErrNoValidQC = errors.New("target qc is empty")
ErrNoValidParentId = errors.New("parentId is empty")
)
// 本文件定义了chained-bft下有关的数据结构和接口
... |
/*
trader strategy
*/
package strategy
import (
"config"
"db"
"logger"
"sync"
"trade_service"
"util"
)
var buy_queue_mutex = &sync.Mutex{}
var buy_total_amount float64
var sell_queue_mutex = &sync.Mutex{}
var sell_total_amount float64
var buy_limit float64
var sell_limit float64
func initTotalReadyAmount(... |
package entity
// TODO: для описания типов использовать https://github.com/jackc/pgtype
import (
"context"
"github.com/jackc/pgx/v4"
"github.com/pkg/errors"
)
// Suggestion описывает предложения.
type Suggestion struct {
EntryID int `sql:"entry_id" json:"entry_id"`
ExtDB string `sql:"ext_db" json:"ext_d... |
package main
type X struct {
Xa int
Xb int
}
func (x X) foo() {
return
}
func main() {
x := X{
}
|
package main
import (
"book/goroutines/channels/counter/counter"
"book/goroutines/channels/counter/squarer"
"fmt"
)
func main() {
fmt.Println("Initializing....")
natural := make(chan int)
squares := make(chan int)
go counter.Counter(natural)
go squarer.Squarer(squares, natural)
printer(squares)
}
func print... |
package main
import (
"fmt"
)
type ColorError interface {
error
ColorError() string
}
type checkError struct {
coord Coord
msg string
colorMsg string
}
func newCheckError(coord Coord, format, colorFormat string, args ...interface{}) (err checkError) {
return checkError{
coord: coord,
msg: ... |
package pack
import (
"bufio"
"bytes"
"encoding/binary"
"errors"
"io"
)
type IndexFile []IndexRecord
var indexEndianness = binary.BigEndian
// increment when you make backwards-incompatible changes
var indexFileMagicBytes = []byte("GOBACKIDX_0001")
var errIndexHeaderMismatch = errors.New("received unexpected i... |
// 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, ... |
// date: 2019-03-15
package main
func main() {
}
|
package main
import (
"flag"
pb "github.com/lintflow/core/proto"
"golang.org/x/net/context"
"fmt"
"google.golang.org/grpc"
"google.golang.org/grpc/grpclog"
"io"
"strconv"
)
var DefaultInspector string = `localhost:4568`
var (
uri = flag.String(`repo`, `https://github.com/lintflow/golang-test-project.git... |
package util
func Add( a, b int) int {
return a + b
}
|
package main
import (
"day_daily/day_proficient/day_9/chatroom/server/model"
"fmt"
"net"
"time"
)
//处理客户端通信
func process(conn net.Conn) {
//这里需要延时关闭
defer conn.Close()
processor := &Processor{
Conn : conn,
}
err := processor.process2()
if err != nil {
fmt.Println("客户端和服务器的通讯协程错误err: ", err)
return
}
... |
package usecase
import (
"github.com/shiv3/slackube/app/adapter/k8s"
"github.com/shiv3/slackube/app/adapter/registory/gcr"
gcr2 "github.com/shiv3/slackube/app/usecase/gcr"
k8susecase "github.com/shiv3/slackube/app/usecase/k8s"
)
type UsecasesImpl struct {
*k8susecase.K8sUseCaseImpl
*gcr2.UseCaseImpl
}
func New... |
/*
B1 Yönetim Sistemleri Yazılım ve Danışmanlık Ltd. Şti.
User : ICI
Name : Ibrahim ÇOBANİ
Date : 16.08.2019 10:15
Notes :
*/
package models
import (
"encoding/json"
"fmt"
bolt "go.etcd.io/bbolt"
"log"
"time"
)
type LocationTable struct {
Language string `jso... |
package metadata_test
import (
"net/http"
"net/http/httptest"
"net/url"
"github.com/digitalocean/go-metadata"
)
var opts = stubMetadata()
func stubMetadata() metadata.ClientOption {
srv := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
rw.Write([]byte(`{"interfaces":{"p... |
package hash
import (
"testing"
"github.com/stretchr/testify/assert"
)
var (
// Excerpt from `All Watched Over by Machines of Loving Grace` (1967)
// by Richard Brautigan
poem = []byte(`I like to think
(it has to be!)
of a cybernetic ecology
where we are free of our labors
and joined back to nature,
returned to... |
package pipe
type Pipelines []Pipeline
type Stream struct {
nodes []Pipeline
}
func New() *Stream {
return &Stream{}
}
// Use appends a pipeline processor to the Stream pipeline stack.
func (s *Stream) Use(nodes ...Pipeline) {
s.nodes = append(s.nodes, nodes...)
}
// chain builds a Connector composed of an inli... |
package finddisappearednumbers
import (
"reflect"
"testing"
)
func TestFindDisappearedNumbers(t *testing.T) {
var result, expect []int
result = findDisappearedNumbers([]int{4, 3, 2, 7, 8, 2, 3, 1})
expect = []int{5, 6}
if reflect.DeepEqual(result, expect) != true {
t.Errorf("Get %v, Expect %v", result, expec... |
package client
import (
"errors"
"fmt"
"github.com/kuaidaili/golang-sdk/api-sdk/kdl/endpoint"
"github.com/kuaidaili/golang-sdk/api-sdk/kdl/signtype"
"github.com/kuaidaili/golang-sdk/api-sdk/kdl/utils"
)
// GetKps 获取独享代理
// return: 代理slice
func (client Client) GetKps(num int, signType signtype.SignType, kwargs m... |
// 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 firmware
import (
"context"
"github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/empty"
"github.com/golang/protobuf/ptypes/wrappers"
"google.... |
package sort
import (
"reflect"
"testing"
)
type res struct {
l1 *ListNode
l2 *ListNode
exp *ListNode
}
func buildWithSlice(a []int) *ListNode {
var h, c *ListNode
for _, v := range a {
n := &ListNode{v, nil}
if c != nil {
c.Next = n
}
if h == nil {
h = n
}
c = n
}
return h
}
func TestM... |
// 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 enterprisecuj contains the test code for enterprise CUJ.
package enterprisecuj
import (
"context"
"time"
"chromiumos/tast/common/perf"
"chromiumos/tast/ctxut... |
package app
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"github.com/MakeNowJust/heredoc"
go_version "github.com/hashicorp/go-version"
"github.com/spf13/viper"
"github.com/dikaeinstein/godl/internal/pkg/version"
"github.com/dikaeinstein/godl/pkg/text"
)
type Asset struct {
Name string `json:"... |
package configmap
import (
"context"
"testing"
"github.com/stretchr/testify/require"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/pointer"
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
"github.com/tilt-dev/tilt/internal/controllers/fake"
"github.com/ti... |
// 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 spanner
import (
"context"
"reflect"
"time"
lib_errors "github.com/tomwangsvc/lib-svc/errors"
lib_json "github.com/tomwangsvc/lib-svc/json"
lib_log "github.com/tomwangsvc/lib-svc/log"
lib_misc "github.com/tomwangsvc/lib-svc/misc"
)
type CarCustomerAssociation struct {
CarId string `json:... |
package service
import (
"fmt"
"github.com/thisiserico/golabox/domain"
)
func (srv *Service) GetOrder(oID domain.OrderId) (*domain.Order, error) {
order := srv.queryRepo.GetOrder(oID)
if order == nil {
return nil, fmt.Errorf("Non existing order %s", oID)
}
return order, nil
}
|
package server
import (
"fmt"
"mall/app/api/admin/user/conf"
"mall/app/api/admin/user/model"
"mall/app/api/admin/user/service"
serviceUserModel "mall/app/service/main/user/model"
"mall/lib/net/http/middleware/auth"
"mall/lib/net/http/middleware/cors"
"github.com/gin-gonic/gin"
"github.com/jinzhu/gorm"
)
var... |
// Copyright 2016 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, ... |
//go:generate protoc -I ./rpc --go_out=plugins=grpc:./rpc ./rpc/chat.proto
package main
import (
"log"
"net"
pb "./protobufs"
"fmt"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
"os"
)
const defaultPort = ":50051"
func main() {
port := getEnv("PORT", defaultPort)
... |
package apiserver
import (
"github.com/fission/fission-workflows/pkg/api"
"github.com/fission/fission-workflows/pkg/api/aggregates"
"github.com/fission/fission-workflows/pkg/api/store"
"github.com/fission/fission-workflows/pkg/fes"
"github.com/fission/fission-workflows/pkg/types"
"github.com/fission/fission-work... |
package tyVpnServer
import (
"crypto/tls"
"fmt"
"github.com/tachyon-protocol/udw/tyTlsPacketDebugger"
"github.com/tachyon-protocol/udw/tyVpnProtocol"
"github.com/tachyon-protocol/udw/udwBinary"
"github.com/tachyon-protocol/udw/udwBytes"
"github.com/tachyon-protocol/udw/udwLog"
"github.com/tachyon-protocol/udw/... |
package main
//Valid
//The block of if can shadow the init variables
func f () {
if a:=0; a < 10 {
a := "gg"
} else {
}
} |
package main
import (
"fmt"
)
// 汉诺塔游戏
// n个盘子 start() end() temp()
// n-1 start -> end -> temp
// start -> end
// n-1 temp -> start -> end
// 终止条件 1 -> start -> end
func tower(start string, end string, temp string, layer int) {
if (layer == 1) {
fmt.Println(start, "->", end)
return
}
tower(start, temp, end... |
package pp
import (
"context"
"fmt"
"cloud.google.com/go/bigquery"
)
func RunQuery(ctx context.Context, projectID string, query string) error {
// Создаём клиента для BigQuery
client, err := bigquery.NewClient(ctx, projectID)
if err != nil {
return fmt.Errorf("bigquery.NewClient: %v", err)
}
// Вызываем q... |
package problem0206
// ListNode is a struct
type ListNode struct {
Val int
Next *ListNode
}
func reverseList(head *ListNode) *ListNode {
var prev, curr *ListNode
curr = head
for curr != nil {
nextTemp := curr.Next
curr.Next = prev
prev = curr
curr = nextTemp
}
return prev
}
|
/*
* Copyright 2018, Oath Inc.
* Licensed under the terms of the MIT license. See LICENSE file in the project root for terms.
*/
package config
import (
"fmt"
"log"
"regexp"
)
var endpointPattern = regexp.MustCompile(`^(\S+?)://(.*)$`)
var addressPattern = regexp.MustCompile(`^(\S+):(\d+)$`)
type Endpoint int... |
package interfaces
import (
"github.com/aswinda/notifyme/application/api/models"
)
type IUserRepository interface {
GetUserDetail(userId int) (models.UserModel, error)
}
|
package main
import (
"./handler"
"fmt"
"log"
"net/http"
)
func staticDirHandler(mux *http.ServeMux, prefix string, staticDir string) {
mux.HandleFunc(prefix, func(w http.ResponseWriter, r *http.Request) {
file := staticDir + r.URL.Path[len(prefix)-1:]
fmt.Println(file)
http.ServeFile(w, r, file)
})
}
fu... |
package client
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"
"github.com/G-Research/armada/pkg/api"
)
func TestCreateChunkedSubmitRequests(t *testing.T) {
requestItems := createJobRequestItems(MaxJobsPerRequest + 1)
result := CreateChunkedSubmitRequests("queue", "jobs... |
package main
import (
"fmt"
)
func main() {
v1 := struct {
doors int
price int
lux bool
}{
doors: 4,
price: 100000,
lux: false,
}
fmt.Println(v1)
}
|
package utils
import (
"net/http"
"io/ioutil"
"encoding/json"
"encoding/xml"
"fmt"
"strings"
)
func RemoteFile (url string, headers map[string]string, body map[string]interface{}) []byte {
client := &http.Client{}
req, err := http.NewRequest("POST", url, strings.NewReader( MapToUrl(body) ))
PanicIf(... |
package main
import "fmt"
import "os"
import "reflect"
type Node struct {
Value int
Left *Node
Right *Node
}
func insert(curr *Node, val int) *Node {
if curr == nil {
return &Node{Value: val}
}
if val == curr.Value {
return curr
} else if val > curr.Value {
curr.Right = insert(curr.Right, val)
} else ... |
// 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... |
// gopup.go
// a go implementation of a pack unpack utility for byte buffers
|
// 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 webhooks
type List struct {
Meta struct {
Count int `json:"count"`
PageCount int `json:"pageCount"`
TotalCount int `json:"totalCount"`
Next interface{} `json:"next"`
Previous interface{} `json:"previous"`
Self string `json:"self"`
First strin... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.