text stringlengths 11 4.05M |
|---|
/*
Copyright The containerd 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... |
/*-------------------------------------------------------------------------
*
* cpu.go
* Read cgroup cpu/memory metrics
*
*
* Copyright (c) 2021, Alibaba Group Holding Limited
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
... |
package units
import (
"go-account-api/controllers"
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/labstack/echo"
"github.com/stretchr/testify/assert"
)
func TestLoginWithValidAccount(t *testing.T) {
e := echo.New()
account := `{ "email": "r@s.com", "password": "123456789" }`
req := httptes... |
package arrays
import (
"math"
"strconv"
)
func main() {
crypt := make([]string, 3)
//crypt[0] = "SEND"
//crypt[1] = "MORE"
//crypt[2] = "MONEY"
//solution := make([][]string, 8)
//solution[0] = []string{"O", "0"}
//solution[1] = []string{"M", "1"}
//solution[2] = []string{"Y", "2"}
//solution[3] = []strin... |
// 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 conference
import (
"context"
"math/rand"
"strconv"
"strings"
"time"
"chromiumos/tast/errors"
"chromiumos/tast/testing"
)
// GoogleMeetConfig defines input ... |
package random
import (
"math/rand"
"time"
)
func BinaryString(n int, chanceOfAnyOnes float64) (string, int) {
individualChance := chanceOfAnyOnes / float64(n)
count := 0
randstr := make([]byte, n) // Random string to return
for i := 0; i < n; i++ {
randNum := rand.Float64()
if randNum < individualChance {... |
package document
import (
"strings"
"golang.org/x/net/html"
)
func FindFirstByTag(root *html.Node, tag string) (node *html.Node) {
check := func(n *html.Node) bool {
return n.Type == html.ElementNode && n.Data == tag
}
return FindFirst(root, check)
}
func FindByTag(root *html.Node, tag string) (nodes []*html... |
package main
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestCreateManifest(t *testing.T) {
const winOS = "2012R2"
const sha1 = "478da1732dba66e67e6a657fdf03b5614c513b04"
const version = "1200.1"
const expected = `---
name: bosh-azure-hyperv-windows2012R2-go_agent
version: '1200.1'
bosh_protoco... |
package main
import "fmt"
func main() {
// 不使用标记
fmt.Println("---- break ----")
for i := 1; i <= 3; i++ {
fmt.Printf("i: %d\n", i)
for i2 := 11; i2 <= 13; i2++ {
fmt.Printf("i2: %d\n", i2)
break
}
}
// 使用标记
fmt.Println("---- break label ----")
re:
for i := 1; i <= 3; i++ {
fmt.Printf("i: %d\n",... |
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
var size int
func main() {
fmt.Scan(&size)
existArr := map[int]int{}
scanner := bufio.NewScanner(os.Stdin)
scanner.Buffer(make([]byte, 12800000), 12800000)
scanner.Scan()
list := strings.Split(scanner.Text(), " ")
list = append(list, "")
... |
// 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 (
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
// gorm.DB
var Db *gorm.DB
// initialize for database migration
func Initialize() {
dsn := "user=root password=root dbname=todo host=psql port=5432 sslmode=disable"
Db, _ = gorm.Open(postgres.Open(dsn), &gorm.Config{})
Db.AutoMigrate(Todo{}, I... |
package main
import (
"encoding/json"
"fmt"
"html/template"
"net/http"
"github.com/olegsobchuk/go-pure/database"
)
// User struct
type User struct {
Name string
Age uint32
}
// SearchResult struct
type SearchResult struct {
Title string
Name string
Age uint8
Count uint8
}
func main() {
database.Ini... |
package edgediscovery
import (
"sync"
"github.com/rs/zerolog"
"github.com/cloudflare/cloudflared/edgediscovery/allregions"
"github.com/cloudflare/cloudflared/management"
)
const (
LogFieldConnIndex = "connIndex"
LogFieldIPAddress = "ip"
)
var errNoAddressesLeft = ErrNoAddressesLeft{}
type ErrNoAddressesLeft... |
// Copyright 2021 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 (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
sysruntime "runtime"
"github.com/golang/glog"
"github.com/gorilla/mux"
"github.com/spf13/pflag"
"github.com/urfave/negroni"
rbac "k8s.io/api/rbac/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s... |
package mock
import (
"sync"
"time"
)
// KVStore mocks github.KVStore.
type KVStore struct {
data map[string][]byte
reads int
updates int
m sync.Mutex
writeTokens chan struct{}
}
// NewKVStore creates new KVStore instance with given data
func NewKVStore(data map[string][]byte, write... |
package parser
import (
"testing"
"github.com/devandrewgeorge/config-generator/internal/pkg/plugins"
)
func TestParsePlugin (t *testing.T) {
test_string := "test"
t.Run("named plugins map is nil", func(t *testing.T) {
plugins, err := parsePlugins(nil);
if err != nil || len(plugins) != 0 {
t.Fail... |
package controllers
import (
"bookingSystem/models"
"github.com/astaxie/beego/orm"
"github.com/astaxie/beego/validation"
"time"
)
type BookingController struct {
Base
}
//新预约
// @router /booking/new [get]
func (c *BookingController) Show() {
o := orm.NewOrm()
var rooms []*models.Room
o.QueryTable("b_room").F... |
package schema
import (
"regexp"
"time"
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/google/uuid"
"github.com/lemon-mint/open-backend/auth/password"
)
// User holds the schema definition for the User entity.
type User struct {
ent.Schema
}
//... |
package main
import "github.com/spf13/cobra"
type dashboardFlags struct {
serverAddress string
refreshSeconds int
}
func (flags *dashboardFlags) addFlags(command *cobra.Command) {
command.Flags().StringVar(&flags.serverAddress, "server", defaultLocalServerAPI, "The provisioning server whose API will be queried."... |
// +build !prod
package testutils
import (
"github.com/joshprzybyszewski/cribbage/model"
"github.com/joshprzybyszewski/cribbage/server/interaction"
"github.com/joshprzybyszewski/cribbage/utils/rand"
)
func aliceAndBob() (a, b model.Player) {
alice := model.Player{
ID: model.PlayerID(rand.String(50)),
Name:... |
package managers
import (
"log"
"strconv"
"github.com/gin-gonic/gin"
"github.com/w-zengtao/socket-server/models"
"github.com/w-zengtao/socket-server/sockets"
)
func loadManager(c *gin.Context) *sockets.ClientManager {
var id, err = strconv.Atoi(c.Param("id"))
if err != nil {
log.Println(err)
return nil
}... |
package main
import (
"fmt"
)
// cap重新分配规律
func capRule() {
s := make([]int, 0, 1)
c := cap(s)
for i := 0; i < 50; i++ {
s = append(s, i)
if n := cap(s); n > c {
fmt.Printf("cap: %d -> %d\n", c, n)
c = n
}
}
}
//超出原 slice.cap 限制,就会重新分配底层数组,即便原数组并未填满。
func capOut() {
data := [...]int{0, 1, 2, 3, 4... |
package main
import "fmt"
func main() {
// Arrays
// 1, 1, 2, 3, 5, 8, 13
// var numeros = [7]int{1, 1, 2, 3, 5, 8}
numeros := []int{1, 1, 2, 3, 5, 8}
fmt.Println(numeros)
}
|
package handler
import (
"errors"
"net/http"
"github.com/gin-gonic/gin"
e "github.com/talesmud/talesmud/pkg/entities"
"github.com/talesmud/talesmud/pkg/service"
)
//UsersHandler ...
type UsersHandler struct {
Service service.UsersService
}
//GetUser returns the user info
func (handler *UsersHandler) GetUser(c... |
package main
import (
"bytes"
"context"
"fmt"
"log"
"net/http"
"net/http/httptest"
"net/url"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
"time"
)
func newBaseTLD() TLDef {
return TLDef{
Name: "Kohm Yah-man-yeh",
URL: "https://www.nps.gov/webcams-lavo/kyvc_webcam1.jpg?15893162... |
package divine
import (
"fmt"
"reflect"
)
type (
Dependent interface{}
Container interface {
Provide(item interface{}, as ...reflect.Type) error
ProvideLazily(factory Dependent)
ByType(need reflect.Type) (interface{}, error)
}
InjectError struct {
Requested reflect.Type
Err error
}
simple s... |
package ipfs
import (
"context"
"fmt"
"io/ioutil"
"os"
"path"
"reflect"
"strings"
"sync"
cid "gx/ipfs/QmTprEaAA2A9bst5XH7exuyi5KzNMK3SEDNN8rBDnKWcUS/go-cid"
mh "gx/ipfs/QmU9a9NV9RdPNwZQDYd5uKsm6N6LJLSvLbywDDYFbaaC6P/go-multihash"
blocks "gx/ipfs/QmVA4mafxbfH5aEvNz8fyoxC6J1xhAtw88B4GerPznSZBg/go-block-forma... |
package routers
import "github.com/gin-gonic/gin"
// Ping - Pong
func Ping(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
})
}
|
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
// "time" Депрекатед к концу главы
)
/* Old
func responseSize(url string){
fmt.Println("Getting", url)
response, err := http.Get(url)
if err != nil {
log.Fatal(err)
}
// Отложенно особождаем ресурсы,
// выделенные на сетевое подключение
defer resp... |
package tree
import "math"
// BstProperty returns true if tree has "Binary seach tree"
// property, false otherwise. Uses math.MinInt32 as minimum
// value for LHS of tree to be greater than, and math.MaxInt32
// as the value for RHS of tree to have values less than.
func BstProperty(root *NumericNode) bool {
return... |
package gotool
func intSliceDelete(slice []int, position int) (output []int) {
length := len(slice)
output = append(slice[0:position-1], slice[position:length]...)
return output
}
func stringSliceDelete(slice []string, position int) (output []string) {
length := len(slice)
output = append(slice[0:position-1], sl... |
package main
import (
"os"
"os/exec"
"syscall"
"github.com/fatih/color"
)
type Command struct {
*exec.Cmd
name string
args []string
}
func NewCommand(command ...string) (*Command, error) {
c := &Command{
name: command[0],
args: command[1:],
}
return c, c.Run()
}
func (c *Command) Restart() *Command... |
/*
* Copyright 2015 Canopy Services, 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 ... |
package routers
import (
"u3d_update/controllers"
"github.com/astaxie/beego"
)
func init() {
beego.Router("/", &controllers.MainController{})
u3d := new(controllers.U3DController)
beego.Router("/u3d3/ver/:platform", u3d, "get:GetVer")
}
|
package main
import (
"bufio"
"fmt"
"io"
"os"
"os/exec"
"io/ioutil"
)
type emp struct {
Num int
Name string
Grade float64
}
func main() {
var (
choice int
list []emp
new emp
scaner = bufio.NewScanner(os.Stdin)
)
file, err := os.OpenFile("D:\\Golang\\Project... |
package client
import (
"context"
"fmt"
"io"
"net/http"
"net/url"
)
// BundleManagerClient is the interface to the precise-code-intel-bundle-manager service.
type BundleManagerClient interface {
// BundleClient creates a client that can answer intelligence queries for a single dump.
BundleClient(bundleID int) ... |
// 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 payments
import "sync"
type inMemoryPaymentStore struct {
mutex *sync.Mutex
payments []*Payment
}
func NewInMemoryPaymentStore() *inMemoryPaymentStore {
return &inMemoryPaymentStore{
payments: []*Payment{},
mutex: &sync.Mutex{},
}
}
func (store *inMemoryPaymentStore) Create(payment *Payment) (... |
package auxiliar
import "fmt"
func Escrever2() {
fmt.Println("Escrevendo do auxliar 2")
}
|
package client
import (
"encoding/json"
"errors"
"fmt"
config "ontrack-cli/config"
resty "github.com/go-resty/resty/v2"
)
// GraphQLCall performs a GraphQL query/mutation to Ontrack
func GraphQLCall(cfg *config.Config, query string, variables map[string]interface{}, data interface{}) error {
// If config is d... |
package view
import (
"fmt"
termbox "github.com/nsf/termbox-go"
"github.com/borkshop/bork/internal/moremath"
"github.com/borkshop/bork/internal/point"
)
// Layout places Renderables in a Grid, keeping track of used left/right/center
// space to inform future placements.
type Layout struct {
Grid
// invariant... |
// Copyright © 2021. All rights reserved.
// Author: Ilya Stroy.
// Contacts: qioalice@gmail.com, https://github.com/qioalice
// License: https://opensource.org/licenses/MIT
package ekaerr
import (
"fmt"
"io/ioutil"
"runtime"
"testing"
"github.com/qioalice/ekago/v2/ekalog"
)
type T struct{}
func (T) String() ... |
package helper
import (
"sort"
"time"
)
var (
Format_DateTime_TimeZone = "2006-01-02 15:04:05-07:00"
Format_DateTime = "2006-01-02 15:04:05"
Format_Date = "2006-01-02"
Format_Time = "15:04:05"
)
//Try to parse string with specified layout, if not, return d
func TryParseTime(v... |
package dao
import (
"encoding/json"
"github.com/bitly/go-simplejson"
"github.com/go-errors/errors"
"go_gorm_demo/src/server/common"
)
type UserDao struct {
}
type User struct {
Id int64 `json:"id"`
Name string `json:"name"`
Age int64 `json:"age"`
Birthday string `json:"birthday"`
}
func (*... |
package main
import (
"database/sql"
"fmt"
"math/rand"
"strings"
"time"
)
// DBs represents a map of *sql.DB connections.
type DBs map[string]*sql.DB
// Get returns an *sql.DB from the DBs map by name.
func (d DBs) Get(dbName string) (*sql.DB, error) {
db, ok := d[dbName]
if !ok {
return nil, fmt.Errorf("un... |
package main
import (
"fmt"
"github.com/everfore/exc"
"github.com/toukii/oschat/peers"
"net"
"time"
)
var Conn_Keeper *peers.ConnKeeper
func init() {
Conn_Keeper = peers.NewConnKeeper()
}
func screen() {
cmd := exc.NewCMD("xwd -root -out screen.xwd").Debug()
cmd.ExecuteAfter(5)
cmd.Reset("convert screen.xw... |
package main
import "time"
type Stopwatch struct {
start, stop time.Time
}
func (self *Stopwatch) Start() {
self.start = time.Now()
}
func (self *Stopwatch) Stop() {
self.stop = time.Now()
}
func (self *Stopwatch) Milliseconds() uint32 {
return uint32(self.stop.Sub(self.start) / time.Millisecond)
... |
// Package producer allows to submit new messages to a message broker.
package producer
import (
"context"
"github.com/segmentio/kafka-go"
)
func New(address, topic string) *producer {
w := kafka.NewWriter(kafka.WriterConfig{
Brokers: []string{address},
Topic: topic,
Balancer: &kafka.LeastBytes{},
})
... |
package util
import (
"github.com/mozillazg/go-pinyin"
)
func GetFirstLetter(l string) string {
i := pinyin.Pinyin(l, pinyin.NewArgs())
return i[0][0][:1]
}
|
package main
import (
"fmt"
"io"
"net/http"
"os"
"strconv"
)
/**
1. 明确目标 Url
2. 发送请求,获取应答数据包。 http.Get(url)
3. 过滤 数据。提取有用信息。
4. 使用、分析得到数据信息。
https://tieba.baidu.com/f?kw=%E7%BB%9D%E5%9C%B0%E6%B1%82%E7%94%9F&ie=utf-8&pn=0 下一页 +50
https://tieba.baidu.com/f?kw=%E7%BB%9D%E5%9C%B0%E6%B1%82%E7%94%9F&ie=utf-8&p... |
package persistence
import (
"fmt"
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
"github.com/sandeepmuppirala/inventory-management/models"
log "github.com/sirupsen/logrus"
)
func ViewItemsInInventory() []models.Inventory {
db := getDatabaseConnection()
inventory := []models.Inventory{}
defer db.Close()
db.O... |
package geojson
import "github.com/paulmach/orb"
// BBox is for the geojson bbox attribute which is an array with all axes
// of the most southwesterly point followed by all axes of the more northeasterly point.
type BBox []float64
// NewBBox creates a bbox from a a bound.
func NewBBox(b orb.Bound) BBox {
return []... |
/*
* @lc app=leetcode.cn id=120 lang=golang
*
* [120] 三角形最小路径和
*/
// @lc code=start
func minimumTotal(triangle [][]int) int {
dp := make([]int,len(triangle)+1)
for i:=len(triangle)-1;i>=0;i-- {
for j:=0;j < len(triangle[i]);j++ {
dp[j] = min(dp[j],dp[j+1])+triangle[i][j]
}
}
return dp[0]
}
func mi... |
package http_simple_proxy
import (
"net/http"
"net/url"
"testing"
)
func TestPrint(t *testing.T) {
for i := 0; i < 20; i++ {
Print()
}
}
func TestNewMultiHostsRevsrseProxy(t *testing.T) {
proxy := NewMultiHostsRevsrseProxy([]*url.URL{
{
Scheme: "http",
Host: "localhost:9091",
},
{
Scheme: "h... |
package webhooks
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
"github.com/jrapoport/gothic/config"
"github.com/jrapoport/gothic/core/events"
"github.com/jrapoport/gothic/models/types"
)
// CallWebhook calls a webhook callback with an event and msg.
func CallWebhook(c config.Webhooks, evt events.Event, msg ... |
package indexer
import (
"fmt"
"strings"
)
const (
indexSelectorAggregate = "aggregate"
indexSelectorAll = "all"
)
func (s Selector) isAggregate() bool {
return s.selector == "" || s.selector == indexSelectorAggregate || s.selector == indexSelectorAll || strings.Contains(s.selector, ",")
}
type Selector ... |
package main
import "fmt"
func main() {
for a := 1; a <= 9; a++ {
for b := 0; b <= 9; b++ {
fmt.Printf("%d%d (a*b+1)=%d ", a, b, a*b+1)
if a*b+1 == 10*a+b {
fmt.Print("!!!!!!!!!zzzzzzzzzzzz!!!!!!!!!")
}
fmt.Println()
}
}
}
|
package main
import (
"fmt"
"time"
"net"
)
func main() {
fmt.Println((-1+3)%3)
a := 123
f := 1.23456
fmt.Printf("%+10d\n", a) //+123
fmt.Printf("%.10d\n", a) //+123
fmt.Printf("%.4f\n", f) //+000000123,利用0来补齐位数,而不是空格
fmt.Printf("%02d\n", 1)
fmt.Printf("%v", time.Second)
... |
package main
type ProcessorEnv struct {
Config map[string]interface{}
}
|
package leetcode
func findDuplicate(nums []int) int {
nmap := make(map[int]int)
length := len(nums)
var result int
for i := 0; i < length; i++ {
_, ok := nmap[nums[i]]
if ok {
nmap[nums[i]]++
} else {
nmap[nums[i]] = 1
}
}
for k, v := range nmap {
if v > 1 {
result = k
}
}
return result
}... |
package main
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
jira "github.com/andygrunwald/go-jira"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/pkg/errors"
"golang.org/x/oauth2"
"github.com/mattermost/mattermost-plugin-jira/server/utils"
"github.com/mattermost/matter... |
// Package tftp implements a hookable TFTP server.
// Clients need to provide an implementation of Handler,
// create a new Server with it, and call ListenAndServeUDP
package tftp
import (
"io"
"log"
"net"
)
// Handler is the interface to the filesystem served by a TFTP server.
// Implementations may return nil im... |
package codec
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"github.com/RussellLuo/kok/pkg/werror"
"github.com/RussellLuo/kok/pkg/werror/gcode"
)
type CodecMap struct {
Codecs map[string]Codec
Default Codec
}
func (cm CodecMap) EncodeDecoder(name string) Codec {
if c, ok := cm.Codecs[name]; ok {... |
package service
import (
"BiliBili.com/model"
"BiliBili.com/pkg/e"
"BiliBili.com/serializer"
"strconv"
)
type ShowCommentService struct {
PageSize int `json:"page_size" form:"page_size"`
PageNum int `json:"page_num" form:"page_num"`
}
type DeleteCommentService struct {
}
type DeleteReplyService struct {
}
... |
package queue
type Queue struct {
head *node
tail *node
}
type node struct {
Value int
Next *node
}
func (q *Queue) IsEmpty() bool {
return q.head == nil
}
func (q *Queue) Enqueue(v int) {
if q.head == nil {
q.head = &node{Value: v}
q.tail = q.head
} else {
q.tail.Next = &node{Value: v}
q.tail = q.t... |
package lang
import (
"jean/constants"
"jean/native"
"jean/rtda/heap"
"jean/rtda/jvmstack"
)
// javadoc:
// When the intern method is invoked,
// if the pool already contains a string equal to this String object as determined by the equals(Object) method,
// then the string from the pool is returned.
// Otherwise... |
// 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 cryptohome
import (
"bytes"
"context"
"io/ioutil"
"path/filepath"
"time"
uda "chromiumos/system_api/user_data_auth_proto"
cryptohomecommon "chromiumos/tast/c... |
package main
import (
"image"
"image/color"
"gocv.io/x/gocv"
)
var (
red = color.RGBA{255, 0, 0, 0}
green = color.RGBA{0, 255, 0, 0}
blue = color.RGBA{0, 0, 255, 0}
ContourColor = red
RectColor = blue
)
const (
ContourThickness = 1
RectThickness = 2
)
// MotionDetector
type MotionDetector struc... |
package config
import (
"time"
)
var (
cfg *DspConfig = nil
cfgFile string
)
type LogConfig struct {
Path string
Level string
}
type RedisConfig struct {
Addr string `yaml:"addr,flow"`
PoolNum int `yaml:"pool_num,flow"`
}
type MgtvConfig struct {
BidPath string `yaml:"bid_path"`
NoticeP... |
// Copyright 2021 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"
)
func main() {
var x, y int
fmt.Scan(&x, &y)
if z := x * y; z%2 == 0 {
fmt.Println("Even")
} else {
fmt.Println("Odd")
}
}
|
package search_test
import (
"fmt"
"testing"
"github.com/carolove/Golang/algorithms/datageneration"
"github.com/carolove/Golang/algorithms/search"
"github.com/carolove/Golang/algorithms/sort"
)
func TestBinSearch(t *testing.T) {
vec := datageneration.GenerationVector()
fmt.Println(search.BinSearch(vec, 45))
... |
package wallet
import (
"bytes"
"log"
"reflect"
"sync"
"github.com/kyos0109/test-wallet/modules"
kredis "github.com/kyos0109/test-wallet/redis"
)
// BuildRedisDataWithDelimiter create with : string
func BuildRedisDataWithDelimiter(args ...interface{}) string {
var buffer bytes.Buffer
for _, v := range args ... |
// Copyright (C) 2019 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 fsevent
import (
"time"
"github.com/tilt-dev/tilt/internal/watch"
"github.com/tilt-dev/tilt/pkg/logger"
)
type WatcherMaker func(paths []string, ignore watch.PathMatcher, l logger.Logger) (watch.Notify, error)
type TimerMaker func(d time.Duration) <-chan time.Time
func ProvideWatcherMaker() WatcherMaker... |
//go:generate wire
//+build wireinject
package app
import (
"PMSApp/app/basic"
"PMSApp/app/daos"
"PMSApp/app/models"
"PMSApp/app/utils"
"net/http"
"github.com/google/wire"
"PMSApp/app/config"
"PMSApp/app/controllers"
"PMSApp/app/routers"
)
func BuildInjector() *http.Server {
wire.Build(
config.NewConfig... |
package main
import (
"bufio"
"fmt"
"net"
)
var print = fmt.Println
var scan = fmt.Scanln
func main() {
var tcpAddr, _ = net.ResolveTCPAddr("tcp", "127.0.0.1:9999")
var conn, _ = net.DialTCP("tcp", nil, tcpAddr)
defer conn.Close()
print("connected to", conn.RemoteAddr().String())
go onMessageReceived(con... |
package helper
import (
"net/http"
)
// JSONHandler is set the header to have the content type of json
func JSONHandler(rw http.ResponseWriter, req *http.Request) {
rw.Header().Set("Content-Type", "application/json; charset=UTF-8")
}
|
// mymathTwo 註解here
package mymathTwo
import "fmt"
// Sum() 備註
func Sum(xi ...int) int {
sum := 0
fmt.Println("i am mymathTwo and u send:", xi)
for _, v := range xi {
sum += v
}
return sum
}
|
package gube
import (
. "github.com/afritzler/garden-examiner/pkg/data"
v1beta1 "github.com/gardener/gardener/pkg/apis/garden/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
)
type Profile interface {
GetName() string
GetManifest() *v1beta1.CloudProfile
GetInfrastructure() string
RuntimeObjectWrapper
GardenObject... |
package main
import ("fmt";"os";"strings";"bufio";"os/exec";"time";"strconv";"net/http";"io/ioutil")
var crontab = []string{"04:30:0","07:30:1","08:55:0","13:30:1","17:30:0","23:00:-1"}
var server = "http://10.26.4.121" // :8080 para Dinosol solamente
var media = "C:\\RSPS\\"
var winamp = `C:\Archivos de programa\RSP... |
package event
import (
"encoding/hex"
"github.com/xuperchain/xupercore/protos"
"testing"
"github.com/golang/protobuf/proto"
)
func TestRouteBlockTopic(t *testing.T) {
ledger := newMockBlockStore()
block := newBlockBuilder().Block()
ledger.AppendBlock(block)
router := NewRounterFromChainMG(ledger)
filter :... |
// Copyright 2019 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 controllers
import (
"github.com/astaxie/beego"
//指定驱动 一定别忘了
_ "github.com/go-sql-driver/mysql"
"github.com/astaxie/beego/orm"
"beedemo/models"
"strconv"
)
type OrmController struct {
beego.Controller
}
func (this *OrmController) InsertOrm() {
// 1.获取连接对象,rom
o := orm.NewOrm()
// 2.插入对象
user := m... |
package translated
import "github.com/stephens2424/php/passes/togo/internal/phpctx"
func Shell(ctx phpctx.PHPContext) {
ctx.Shell(`ls -al`)
}
|
package main
import (
"context"
"fmt"
"time"
"github.com/4726/discussion-board/services/posts/models"
pb "github.com/4726/discussion-board/services/posts/write/pb"
"github.com/golang/protobuf/proto"
"github.com/jinzhu/gorm"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
var (
PostDoesNotE... |
package internal
//func gcd(a,b int)int{
// if a%b==0{
// return b
// }
// return gcd(b,a%b)
//}
func gcd(a, b int) int {
for a%b != 0 {
a, b = b, a%b
}
return b
}
|
package main
import (
"bufio"
"context"
"fmt"
"net/http"
"os"
"os/signal"
"syscall"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"google.golang.org/grpc"
"github.com/johnnywidth/9ty/api"
"github.com/johnnywidth/9ty/client/handler"
"github.com/johnnywidth/9ty/client/service"
"github.com/johnn... |
package conf
type Configuration struct {
Host string `yaml:"host"`
Port string `yaml:"port"`
Credentials Credential `yaml:"credential"`
DatabaseConfig DatabaseConfig `yaml:"database-config"`
AccountsApi AccountsApi `yaml:"accounts-api"`
}
type AccountsApi struct {
URL string ... |
package expandurl
import (
"testing"
)
func TestCanExpandValidUrl(t *testing.T) {
result, err := Expand("http://bit.ly/2eXwN8A")
if err != nil {
t.Error("Should have successfully expanded URL")
}
if result != "http://robertgreiner.com/" {
t.Error("Returned incorrect URL")
}
}
func TestShouldReturnErrorOn... |
package services
import (
"strconv"
"time"
"strings"
"frank/src/go/helpers"
"frank/src/go/helpers/log"
"frank/src/go/models"
"frank/src/go/managers"
"github.com/tucnak/telebot"
)
type TelegramBotService struct {
Bot *telebot.Bot
config *models.HTTP
}
var TelegramBot TelegramBotService
func NewTelegramBot... |
package main
import (
"fmt"
"github.com/json-iterator/go"
)
type ColorGroup struct {
ID int `json:"id"`
Name string `json:"name"`
Colors []string `json:"colors"`
}
func t1() {
group := ColorGroup{
ID: 1,
Name: "Reds",
Colors: []string{"Crimson", "Red", "Ruby", "Maroon"},
}
b, _ := js... |
package main
func main() {
// TODO:
// nil everything
}
|
package ontap
import "encoding/xml"
type Base struct {
XMLName xml.Name `xml:"netapp"`
Version string `xml:"version,attr"`
XMLns string `xml:"xmlns,attr"`
}
|
package eventsourcing
import (
"context"
"strings"
"github.com/caos/zitadel/internal/errors"
es_models "github.com/caos/zitadel/internal/eventstore/models"
es_sdk "github.com/caos/zitadel/internal/eventstore/sdk"
org_es_model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
"github.com/cao... |
package main
import (
"fmt"
"os"
"strconv"
)
func main() {
a, b, c := 1, 2, 3
fmt.Printf("a=%d, b=%d, c=%d\n", a, b, c)
m, _ := strconv.Atoi(os.Args[1])
n, _ := strconv.Atoi(os.Args[2])
for i := 0 ; i < m ; i++ {
for j := 0 ; j < n ; j++ {
if a == 0 {
... |
// SPDX-License-Identifier: MIT
package core
import (
"github.com/issue9/localeutil"
"github.com/issue9/sliceutil"
"golang.org/x/text/message"
"github.com/caixw/apidoc/v7/internal/locale"
)
// HTTPError 表示 HTTP 状态码的错误
type HTTPError struct {
error
Code int
}
// Error 用于描述 apidoc 中的大部分错误信息
//
// 无论是配置文件的错误,还是... |
package db
import (
"time"
"github.com/gbolo/vsummary/common"
"github.com/gbolo/vsummary/crypto"
)
const (
insertPoller = `
INSERT INTO poller (
id,
vcenter_host,
vcenter_name,
enabled,
user_name,
encrypted_password,
interval_min,
internal
)
VALUES (
:id,
:vcenter_host,
:vcenter_name,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.