text stringlengths 11 4.05M |
|---|
// 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 wmp
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/local/apps"
"chromiumos/tast/local/arc"
"chromiumos/tast/local/bundles/cros/wmp/wmput... |
package go2lua
import (
"bytes"
"encoding/json"
"reflect"
"testing"
"time"
lua "github.com/yuin/gopher-lua"
)
type testStructNest struct {
I8 int8
BP *bool
private string
}
type AnonType struct {
Ver int
}
type testStruct struct {
AnonType
I int `json:"i,omitempty"`
F float64
S ... |
package main
import "fmt"
func main() {
maxDen, max, cycle := 1, 0, 1
for i := 2; i < 1000; i++ {
cycle = calcCycle(i)
if cycle > max {
max = cycle
maxDen = i
}
}
fmt.Println("max:", maxDen, "cycle: ", max)
}
func calcCycle(den int) int {
numMap := make(map[int]int)
val, sub, count := 1, 1, 0
for ... |
package svg // import "github.com/tdewolff/minify/svg"
import (
"bytes"
"testing"
"github.com/tdewolff/parse/svg"
"github.com/tdewolff/parse/xml"
"github.com/tdewolff/test"
)
func TestBuffer(t *testing.T) {
// 0 12 3 4 5 6 7 8 9 01
s := `<svg><path d="M0 0L1 1z"/>text<tag/>text</s... |
package handler
import (
"context"
"encoding/json"
"github.com/sebsegura/onboarding-aws/insert-contact-aws-lambda/pkg/logger"
"github.com/sebsegura/onboarding-aws/insert-contact-aws-lambda/pkg/models"
"github.com/sebsegura/onboarding-aws/insert-contact-aws-lambda/pkg/repository"
"github.com/sebsegura/onboarding... |
package alert
import (
"context"
"encoding/json"
"fmt"
"strings"
"time"
"cloud.google.com/go/compute/metadata"
"cloud.google.com/go/pubsub"
"github.com/sirupsen/logrus"
"golang.org/x/oauth2/google"
"google.golang.org/api/compute/v1"
)
var (
_ Alerter = &GCloudAlerter{}
)
// OnGCE reports whether this pro... |
package buqi
import (
"encoding/binary"
"net"
)
// Server 服务端
type Server struct {
*Socket
}
// NewServer 新建一个服务端
func NewServer(password *Password, listenAddr *net.TCPAddr) *Server {
return &Server{
Socket: &Socket{
Cipher: NewCipher(password),
ListenAddr: listenAddr,
},
}
}
// Listen 服务端监听
func... |
package main
import (
"fmt"
)
func main() {
var s1 []int
fmt.Println(s1)
a := [10]int{1,2,3,4,5,6,7,8,9,10}
fmt.Println(a)
s2 := a[5:10]
fmt.Println(s2)
s3 := a[6:]
fmt.Println(s3)
s4 := make([]int, 3, 10)
fmt.Println(s4)
}
|
package main
func main() {
}
/**
* @param nums: An integer array
* @return: The second max number in the array.
*/
func secondMax(nums []int) int {
// write your code here
max, secMax := nums[0], nums[1]
if max < secMax {
max, secMax = secMax, max
}
for i, value := range nums {
if i > 1 {
if max < val... |
package semaphore
import (
"context"
"sync"
"github.com/upfluence/pkg/limiter"
)
type Limiter struct {
cond *sync.Cond
mu sync.Mutex
remaining int
}
func NewLimiter(size int) *Limiter {
var l = Limiter{remaining: size}
l.cond = sync.NewCond(&l.mu)
return &l
}
func (l *Limiter) release(n int) {
l.mu.... |
package advantage_shuffle
func minWindow(s string, t string) string {
if len(s) == 0 || len(t) == 0 {
return ""
}
//s 和 t 由英文字母组成
need := map[byte]int{}
window := map[byte]int{}
for i := range t {
need[t[i]]++
}
valid := 0
start := -1
slen := len(s) + 1
for left, right := 0, -1; left < len(s) && rig... |
package day1
import (
"fmt"
"io/ioutil"
"log"
"os"
"strconv"
"strings"
)
// Part1 does the first part.
func Part1() {
total := 0
freqs := readInput("2018/day1/input.txt")
for x := range freqs {
total += freqs[x]
}
fmt.Println(total)
}
// Part2 does the second part.
func Part2() {
hits := make(map[int... |
package main
import (
//"github.com/cmu440/airline/rpc/"
"github.com/cmu440/airline/rpc/storagerpc"
"net/rpc"
"os"
"fmt"
)
//args "host:port1 host:port2 ...."
//for example: "localhost:8080 localhost:8081"
func main(){
arg_num := len(os.Args)
//args start from 1, the 0th argument is the program name
for i := ... |
// 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 main
import "testing"
func TestStart(t *testing.T) {
if 1 == 0 {
t.Fatal("Start test failed.")
}
}
func TestStop(t *testing.T) {
if 0 == 1 {
t.Fatal("Stop test failed.")
}
}
|
package model
import "github.com/zhenghaoz/gorse/core"
import "github.com/zhenghaoz/gorse/base"
/* Base Model */
// BaseModel structure of all estimators.
type BaseModel struct {
Params base.Params // Hyper-parameters
UserIdSet base.SparseIdSet // Users' ID set
ItemIdSet base.Spa... |
package gservlet
import (
"github.com/jholowczak/guacamole_client_go/gnet"
"time"
)
/*GuacamoleHTTPTunnel ==> DelegatingGuacamoleTunnel
* Tracks the last time a particular GuacamoleTunnel was accessed. This
* information is not necessary for tunnels associated with WebSocket
* connections, as each WebSocket conn... |
package go_cmq
import (
"errors"
"time"
)
type QueueAPI interface {
CreateQueue(req QueueCreateReq) (*QueueCreateResp, error)
ListQueue(searchWord string, offset, limit int) (*ListQueueResp, error)
GetQueueAttributes(queueName string) (*QueueAttrResp, error)
SetQueueAttributes(req QueueUpdateReq) (*QueueAttrUpd... |
package cmd
import (
"fmt"
"os"
helpers "github.com/darkcl/jira/helpers"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// openCmd represents the open command
var openCmd = &cobra.Command{
Use: "open",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines ... |
package resources
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/alicebob/miniredis/v2"
"github.com/go-redis/redis/v8"
"github.com/labstack/echo/v4"
"github.com/pablocrivella/mancala/internal/engine"
"github.com/pablocrivella/mancala/internal/games"
"github.com/pablocrivella/mancala... |
// 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 routers
import (
"github.com/gin-gonic/gin"
"golangdemo/rps-game/configs/api"
LogConf "golangdemo/rps-game/configs/log-conf"
"golangdemo/rps-game/configs/system-code"
SystemPath "golangdemo/rps-game/configs/system-path"
"golangdemo/rps-game/controller"
"golangdemo/rps-game/helpers/logging"
"golangdemo/... |
// -*- Mode: Go; indent-tabs-mode: t -*-
//
// Copyright (C) 2019 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0
/* Apache v2 license
* Copyright (C) <2019> Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
package driver
const (
ControllerName = "ControllerName"
MaxWaitTimeForReq ... |
package db_test
import (
"os"
"testing"
"time"
"github.com/elanq/daily_tools/banker/db"
"github.com/elanq/daily_tools/banker/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"github.com/subosito/gotenv"
"gopkg.in/mgo.v2/bson"
)
type DriverSuite struct {
suite.Suite
DBName ... |
package main
import (
"context"
"fmt"
"io"
"log"
"time"
"github.com/dfreilich/grpc-samples/calculator/calculatorpb"
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
const address = "0.0.0.0"
const port = "50051"
func main() {
log.Println("R... |
// 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 go_dj
type Container struct {
items map[string]Item
cached map[string]Any
}
type Any interface {}
type ProviderFunc func(args ... Any) Any
func (c *Container) Provide(name string) (object Any, err error) {
item, exist := c.items[name]
if !exist {
return nil, newError("No such item in Container: " + nam... |
// +build !darwin
package kbmap
import (
"golang.org/x/mobile/event/key"
)
func isCopyModifier(e key.Event) bool {
return e.Modifiers&key.ModControl != 0
}
|
package ecspresso
import (
"fmt"
"strings"
"time"
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
"github.com/aws/aws-sdk-go/service/ecs"
)
var timezone, _ = time.LoadLocation("Local")
func arnToName(s string) string {
ns := strings.Split(s, "/")
return ns[len(ns)-1]
}
func formatDeployment(d *ecs.Deploy... |
package set
import (
"fmt"
"log"
"strings"
"github.com/lleo/go-functional-collections/key/hash"
)
// sparseTableInitCap constant sets the default capacity of a new
// sparseTable.
const sparseTableInitCap int = 2
type sparseTable struct {
nodes []nodeI
depth uint
hashPath hash.Val
nodeMap bitmap
}
f... |
package common
import (
"errors"
"fmt"
"log"
"os"
"sync"
"time"
)
type Rotator struct {
loggers []*LogFile
ticker *time.Ticker
running bool
updatelock sync.Mutex
period string
}
func (c *Rotator) Add(l *LogFile) error {
c.updatelock.Lock()
defer c.updatelock.Unlock()
for _, v := range ... |
// Copyright 2020 The Moov Authors
// Use of this source code is governed by an Apache License
// license that can be found in the LICENSE file.
package wire
import (
"encoding/json"
"strings"
"unicode/utf8"
)
// FIIntermediaryFIAdvice is the financial institution intermediary financial institution
type FIInterme... |
package service
import (
"context"
"github.com/zcong1993/ip2region-service/pb"
"github.com/zcong1993/ip2region-service/pkg"
)
type IP2RegionService struct {
client *ip2region.Ip2Region
}
func NewIP2RegionService(p string) *IP2RegionService {
c, err := ip2region.New(p)
if err != nil {
panic(err)
}
return &I... |
package goroutinePool
type Work struct {
pool *Pool
task chan f
}
|
package controller
import (
"testing"
)
func TestUser(t *testing.T) {
rul := NewRobotUserLogic()
rul.AddGroupImgUser(0, `浅浅<span class="emoji emoji1f601"></span><span class="emoji emoji1f602"></span>`)
}
|
package wrapper
import (
"testing"
"time"
"github.com/benbjohnson/clock"
)
func TestTimer(t *testing.T) {
ct := NewChargeTimer()
clck := clock.NewMock()
ct.clck = clck
ct.StartCharge(false)
clck.Add(time.Hour)
ct.StopCharge()
clck.Add(time.Hour)
if d, err := ct.ChargingTime(); d != 1*time.Hour || err !=... |
package main
import "fmt"
type Student struct {
name string
}
func (s Student) avg(math, english float64) float64 {
return (math + english) / 2
}
func main () {
a001 := Student{"sato"}
fmt.Println(a001.avg(80, 70))
} |
package main
import (
"fmt"
)
type i interface {
Host()
}
type Host struct {
Name string
}
func main() {
//var i interface{ Host() }
var a i = Host{"jeff"}
// Map["hosts"] = []Host{Host{"test.com"}, Host{"test2.com"}}
// hm := Map["hosts"].([]Host)
fmt.Println(t)
}
|
package repo
import (
db "intelliq/app/config"
"intelliq/app/enums"
"intelliq/app/model"
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
)
type testPaperRepository struct {
coll *mgo.Collection
}
//NewTestPaperRepository repo struct
func NewTestPaperRepository(groupCode string) *testPaperReposito... |
type I1 interface { // consumed by C1
M1()
M2()
M3()
}
type I2 interface { // consumed by C2 and C3
M3()
M4()
} |
package quantumwerewolf
import (
"database/sql"
"log"
"net/http"
"os"
"github.com/gin-gonic/gin"
)
var (
db *sql.DB
)
// SetupRoutes sets up the routes
func SetupRoutes() bool {
port := os.Getenv("PORT")
if port == "" {
log.Fatal("$PORT must be set")
}
var err error
db, err = sql.Open("postgres", os... |
// 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 models
import (
"time"
"github.com/kamalraimi/recruiter-api/config"
)
type Customer struct {
ID uint `gorm:"primary_key" form:"id" json:"id"`
Name string `gorm:"type:varchar(100);unique_index" form:"name" json:"name"`
Description string `gorm:"type:varchar(255);" form:"descrip... |
package client
import (
"github.com/achilleasa/usrv/encoding"
"github.com/achilleasa/usrv/transport"
)
// Option applies a configuration option to a client instance.
type Option func(s *Client) error
// WithTransport configures the client to use a specific transport instead
// of the default transport.
func WithTr... |
// 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 policy
import (
"context"
"time"
"chromiumos/tast/common/fixture"
"chromiumos/tast/common/pci"
"chromiumos/tast/common/policy"
"chromiumos/tast/common/policy/... |
package main
import (
"fmt"
"os"
"sort"
s "strings"
)
func main() {
//sort1()
//sort2()
//panic1()
//file()
//combination()
stringFunc()
}
func stringFunc() {
var p = fmt.Println
p("contains:", s.Contains("test", "es"))
p("count:", s.Count("test", "t"))
p("hasprefix:", s.HasPrefix("test", "te"))
p("ha... |
package main
import "fmt"
/*
This problem is an interactive problem new to the LeetCode platform.
We are given a word list of unique words, each word is 6 letters long, and one word in this list is chosen as secret.
You may call master.guess(word) to guess a word. The guessed word should have type string and must b... |
package main
import (
"net/http"
"os"
fazzkithttp "github.com/payfazz/fazzkit/server/http"
"github.com/go-chi/chi"
"github.com/oklog/oklog/pkg/group"
kitlog "github.com/go-kit/kit/log"
kithttp "github.com/go-kit/kit/transport/http"
foohttp "github.com/payfazz/fazzkit/examples/server/internal/foo/transport/... |
package grpc_client
import (
"context"
"github.com/golang/protobuf/ptypes"
"log"
"snippetBox-microservice/catalog/api/grpc/protobuffs"
"strconv"
"time"
)
func DoGetNews(c protobuffs.NewsServiceClient, id int32) *protobuffs.NewsSendResponse {
ctx := context.Background()
request := &protobuffs.NewsSendRequest{I... |
package main
import (
"github.com/aerospike/aerospike-client-go"
)
func ReadGenerator(client *aerospike.Client, keys KeyGenerator) func() {
var err error
policy := aerospike.NewPolicy()
return func() {
if k := keys.GetKey(); k != nil {
_, err = client.Get(policy, k)
statUpdate(&CURRENT_STATS.Reads, err)... |
package cmd
import (
"os"
"github.com/sirupsen/logrus"
"github.com/jeffguorg/blog.jeffthecoder.space/internal/logging"
"github.com/spf13/cobra"
)
var (
verbosity *string
)
var rootCmd = &cobra.Command{
Use: os.Args[0],
Short: "A simple blog daemon based on local git repository",
PersistentPreRunE: func(*... |
// Copyright 2021 Adobe. All rights reserved.
// This file is licensed to you 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 applicab... |
package redis
import (
_ "GoPass/config"
redisConfig "GoPass/config/redis"
"github.com/go-redis/redis"
"sync"
)
var redisDatabases sync.Map
func init() {
for k, v := range redisConfig.Config.OptionsConns {
client := redis.NewClient(&redis.Options{
Addr: v.Addr,
Password: v.Password,
DB: v.... |
package v1
type envKey = string
const (
envKeyCollectionEnv envKey = "COLLECTION_ENV"
envKeyFeatureV2 envKey = "FEATURE_V2"
envKeyFeatureV1Write envKey = "FEATURE_V1_WRITE"
envKeyStorage envKey = "STORAGE"
envKeySessionSecret envKey = "SESSION_SECRET"
envKeyClientID envKey = "CLIENT_ID"
envKeyClie... |
package main
// linke ref https://ithelp.ithome.com.tw/articles/10204662
// and https://medium.com/golang-%E7%AD%86%E8%A8%98/golang-interface-oo-note-14fb1cb76600
import (
"fmt"
"math"
)
// Define interface
// Shape -- area method
type Shape interface {
area() float64
}
// Circle --
type Circle struct {
x, y,... |
package version
import (
"strings"
goversion "github.com/hashicorp/go-version"
"github.com/tcnksm/go-latest"
)
// fixVersion fixes broken version strings.
func fixVersion(version string) string {
ver := strings.Replace(version, "v", "", 1)
for _, prerelease := range []string{"rc", "alpha", "beta"} {
prerelea... |
package main
import (
"os"
"fmt"
"strconv"
"io"
"bufio"
"math"
"gopkg.in/resty.v0"
"flag"
)
var filename string
var address string
var port int
var nlines int
const endpoint = "otafile"
func upload_files(list []string){
url_base := "http://" + address + ":" + strconv.Itoa(port) ... |
package labs31
import (
"math/rand"
"sort"
"testing"
"time"
)
var benchx int
func init() {
rand.Seed(time.Now().UnixNano())
benchx = rand.Intn(1 << 20)
}
func Test_All(t *testing.T) {
for i := 0; i < 1000000; i++ {
n := rand.Intn(1<<20) + 2
a := Normal(n)
b := Switch(n)
c := IF1(n)
d := IF2(n)
e ... |
package controller
import (
"github.com/case2912/go-curd-clean-architecture/application/usecase"
"github.com/case2912/go-curd-clean-architecture/domain"
"github.com/case2912/go-curd-clean-architecture/interface/adapter"
)
type UserController struct {
UserCreateUsecase usecase.UserCreateUsecase
}
func NewUserCont... |
package check
import (
"context"
"errors"
"sync"
"github.com/sirupsen/logrus"
)
var errInconsistent = errors.New("error compensating local status, the check state was left inconsistent")
// PersistenceUpdater defines a type that provides to the combined storage the ability to
// update in the persistence the st... |
package main
import (
"fmt"
"crews_mock_server/utils"
"sync"
"time"
"strconv"
)
func main() {
var crews = utils.ReadCrewsConfigs()
fmt.Println("LOADED CREWS:" + strconv.Itoa(len(crews)))
var wg sync.WaitGroup
wg.Add(len(crews))
for i := range crews {
var crew = crews[i]
go func() {
defer wg.Done... |
package lxn
import (
"fmt"
"unicode/utf8"
)
// Pos describes a position in the lxn file.
type Pos struct {
File string
Line int
Column int
Offset int
}
// String returns a string representation of the position.
func (p Pos) String() string {
prefix := ""
if p.File != "" {
prefix = p.File + ":"
}
retu... |
// Copyright (C) 2014 The Syncthing Authors.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
// Package config implements reading and writing of the syncthing co... |
// 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 controller
import (
"github.com/kataras/iris"
"github.com/kataras/iris/mvc"
"github.com/kataras/iris/sessions"
"irisDemo/CMSProject/service"
"irisDemo/CMSProject/utils"
)
type UserController struct {
Ctx iris.Context
Service service.UserService
Session sessions.Session
}
/**
* 获取用户总数
* /v1/users/... |
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"os"
"strings"
"sync"
"github.com/dutchcoders/go-clamd"
)
//ScanHandler handle uploading file
type ScanHandler struct {
uploadHandler func(http.ResponseWriter, *http.Request) ([]string, error)
clamd *clamd.Clamd
}
type Result struct {
F... |
package main
import "fmt"
// 切片slice
func main() {
//切片的定义
var s1 []int //定义一个存放int类型元素的切片
var s2 []string //定义一个存放string类型元素的切片
fmt.Println(s1, s2)
fmt.Println(s1 == nil) //true
fmt.Println(s2 == nil) //true
//初始化
s1 = []int{1, 2, 3}
s2 = []string{"沙河", "张江", "南京"}
fmt.Println(s1, s2)
fmt.Println(s1 =... |
// 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 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"
)
// GetFeaturesReader is a Reader for the GetFeatures structure.
type GetF... |
package main
import "fmt"
func main() {
var a,b int
// 阻塞等待用户输入
fmt.Scanf("%d", &a)
fmt.Scan(&b)
fmt.Println("a=",a,"b=",b)
} |
package liveupdate
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
)
// Each LiveUpdate has a monitor associated with it that
// tracks the history of updates.
//
// The monitor keeps track of:
// - The last known Spec
// - Every file change it has seen
// -... |
package interpreter
import (
"math"
"math/bits"
"github.com/pgavlin/warp/exec"
"github.com/pgavlin/warp/wasm/code"
)
func (f *frame) get(index uint32) uint64 {
return f.locals[int(index)]
}
func (f *frame) set(index uint32, v uint64) {
f.locals[int(index)] = v
}
func (f *frame) getI32(index uint32) int32 {
... |
// Copyright 2020-2021 Buf 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 law... |
package redis
import (
"context"
"fmt"
"github.com/garyburd/redigo/redis"
"time"
)
var (
redisConnects []*RedisComponent = make([]*RedisComponent, 16)
)
type RedisComponent struct {
pool *redis.Pool
debugFlag bool
}
type RedisStarter struct {
options *Options
}
func (s *RedisStarter) Init (ctx context.... |
// Copyright 2017 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, ... |
/*
Links
* http://ygymamofok.github.com/1.html
* http://ygymamofok.github.com/2.html
* http://ygymamofok.github.com/3.html
* http://ygymamofok.github.com/4.html
* http://ygymamofok.github.com/5.html
* http://ygymamofok.github.com/6.html
* http://ygymamofok.github.com/7.html
* http://ygymamofok.github.com/8.html
* http:... |
package main
//RESOURCE: the teacher's code for web development
//https://github.com/GoesToEleven/golang-web-dev/tree/master/040_json
//https://github.com/GoesToEleven/golang-web-dev/blob/master/040_json/README.html
//rawgit = end of life because malware and misuse of website. Closed down 10-2019.
//https://rawgit.com... |
/*
Package logger defines exported wrapper functions
allowing a single file access to all of the logging
utilities.
*/
package logger
import (
"log"
"github.com/jameOne/logger/action"
"github.com/jameOne/logger/error"
"github.com/jameOne/logger/input"
"github.com/jameOne/logger/output"
"github.com/jameOne/logge... |
package glyphs
import (
"image"
"github.com/llgcode/draw2d/draw2dimg"
"image/color"
"github.com/llgcode/draw2d"
"github.com/llgcode/draw2d/draw2dkit"
)
// draw_one_glyph draws the named glyph onto a image canvas.
//
// The glyph name is case-insensitive.
//
// Example:
// DrawOneGlyph("Enlightened")
func DrawOn... |
package main
import (
"fmt"
"sort"
)
func main() {
x := []int{4, 7, 3, 42, 99, 18, 16, 56, 12}
y := []string{"James", "Q", "M", "Moneypenny", "Dr. No"}
fmt.Println(x, y)
sort.Ints(x)
fmt.Println(x) // [3 4 7 12 16 18 42 56 99]
fmt.Println(sort.IntsAreSorted(x)) // true
sort.Strings(y)
fmt.Println(y) // [... |
package main
import (
"fmt"
"time"
"github.com/lack-io/vine/service/broker"
log "github.com/lack-io/vine/service/logger"
)
func main() {
topic := "go.vine.topic.foo"
b := broker.NewBroker()
if err := b.Init(); err != nil {
log.Fatalf("Broker Init error: %v", err)
}
if err := b.Connect(); err != nil {
... |
package runtime
//resource/object is split into groups
//resource/object will evolve with different version
//kind the the concrete type of resource
//url/endpoint for resource is
// /apis/<group>/<version>/namespaces/<namespace>/<kind-plural>
type Object interface {
GetObjectKind() ObjectKind
DeepCopyObject() Objec... |
// 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 agree... |
// Copyright 2018 The containerd Authors.
// 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//... |
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.
package override
import (
"fmt"
"strconv"
"github.com/DataDog/datado... |
// 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 heap
import "errors"
func NewCusHeapPlus(f func(interface{}, interface{}) bool) *CusHeapPlus {
return &CusHeapPlus{
data: make([]interface{}, 0),
size: 0,
idxMap: make(map[interface{}]int),
comp: f, //第一个排前面返回true
}
}
type CusHeapPlus struct {
data []interface{}
size int
idxMap map[int... |
package admin
import (
log "git.ronaksoftware.com/blip/server/internal/logger"
"git.ronaksoftware.com/blip/server/pkg/music"
"git.ronaksoftware.com/blip/server/pkg/store"
_ "github.com/go-sql-driver/mysql"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.uber.org/zap"
"net/url"
"sync/atomic"
)
/*
Creation ... |
// 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, ... |
/**
* Copyright (c) 2018-present, MultiVAC Foundation.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package txprocessor
import (
"bytes"
"sort"
"github.com/multivactech/MultiVAC/interface/itxprocessor"
"github.com/multivacte... |
package binarytreezigzaglevelordertraversal
import (
"github.com/ovsoil/leetcode/framework/structures"
)
// Use structures.TreeNode
type TreeNode = structures.TreeNode
/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/
func zigzag... |
package provider
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestName(t *testing.T) {
var n Name = "test"
assert.False(t, n.IsExternal())
n = Unknown
assert.False(t, n.IsExternal())
n = Google
assert.True(t, n.IsExternal())
assert.Equal(t, "google", n.String())
assert.Equal(t, "0990a1ac-... |
package main
import "fmt"
func main() {
// 整型切片初始化
s := []int{1, 2, 3, 4, 5}
s = make([]int, 0)
s = make([]int, 5, 10)
fmt.Println(s)
}
|
package assets
import (
"bytes"
"context"
"fmt"
"io"
"net"
"net/http"
"net/http/httputil"
"net/url"
"os"
"os/exec"
"strings"
"sync"
"syscall"
"github.com/pkg/errors"
"github.com/tilt-dev/tilt/pkg/logger"
"github.com/tilt-dev/tilt/pkg/model"
"github.com/tilt-dev/tilt/pkg/procutil"
)
const errorBodyS... |
// 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... |
/*
Copyright: PeerFintech. All Rights Reserved.
*/
package gohfc
import (
"fmt"
"math/rand"
"net"
"strconv"
"time"
)
func getChainCodeObj(args []string, transientMap map[string][]byte, channelName, chaincodeName string) (*ChainCode, error) {
if len(channelName) == 0 {
channelName = handler.client.Channel.Cha... |
package response
import (
"ktmall/app/models"
)
type AddressListResp []models.AddressSerializer
func BuildAddressListResp(ms []*models.ShipAddress) (list AddressListResp) {
list = make(AddressListResp, len(ms))
for i, o := range ms {
list[i] = o.Serialize()
}
return
}
|
package controllers
import (
"github.com/devmaufh/golang-api-rest/models"
"github.com/devmaufh/golang-api-rest/services"
"github.com/gin-gonic/gin"
)
//LoginController Defines an interface to consume login services
type LoginController interface {
Login(ctx *gin.Context) (int, map[string]string)
}
type loginCont... |
package main
import (
"net/http"
"strconv"
"github.com/satori/go.uuid"
"github.com/gin-gonic/gin"
"github.com/tuterdust/my-todo-list/src/model"
)
func pingServiceHandler(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"message": "pong"})
}
func getAllToDoListHandler(c *gin.Context) {
allList := make([]*model.... |
package main
import (
"bytes"
"io/ioutil"
)
func main() {
f, err := ioutil.ReadFile("./5.txt")
if err != nil {
panic(err)
}
numNiceStringsPt1 := 0
numNiceStringsPt2 := 0
for _, l := range bytes.Split(f, []byte{'\n'}) {
var li_1, li_2 byte
hasRepeat := false
hasBadString := false
hasPalindrome := fa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.