text stringlengths 11 4.05M |
|---|
package main
import "fmt"
//func (i int) PrintInt() {
// fmt.Println(i)
//}
type jason int
func (i jason) PrintInt() {
fmt.Println(i)
}
func main() {
//var i int = 1
//i.PrintInt()
var i jason = 1
i.PrintInt()
}
|
// Copyright 2020 Comcast Cable Communications Management, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required ... |
package mediators
import (
"app/models"
"github.com/gin-gonic/gin"
. "app/helpers"
"errors"
. "strconv"
"fmt"
)
type postMediator struct {
Post *models.Post
Context *gin.Context
}
func (self *postMediator) Find() (*R, error) {
var err error
self.Post, err = self.Post.Find()
return &R{... |
package engine
import (
"../fetcher"
"fmt"
"log"
)
func Run(seeds ...Request) {
var requests []Request
for _, e := range seeds {
requests = append(requests, e)
}
for len(requests) > 0 {
r := requests[0]
requests = requests[1:]
log.Printf("Fetching url: %s\n", r.Url)
body, err := fetcher.Fetch(r.Url... |
// Copyright 2017 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Package display wraps the chrome.system.display API.
//
// Functions require a chrome.Conn with permission to use the chrome.system.display API.
// chrome.Chrome.TestAPICo... |
package account
import (
. "ftnox.com/common"
. "ftnox.com/config"
"ftnox.com/db"
"ftnox.com/auth"
"ftnox.com/bitcoin"
"fmt"
)
// Master public key for generating account deposit addresses
var hotMPK *bitcoin.MPK
func init() {
hotMPK = bitcoin.SaveMPKIfNotExists(&bitcoin.MPK{
PubK... |
// 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 main
import (
"fmt"
"log"
"net/http"
"net/url"
)
func handler(w http.ResponseWriter, r *http.Request) {
//fmt.Fprintf(w, "%s\n", r.URL.RawQuery)
q := r.URL.RawQuery
m, err := url.ParseQuery(q)
if err != nil {
log.Fatal(err)
}
switch {
case len(m["name"]) > 0:
fmt.Fprintf(w, "Hello %s\n", m["nam... |
package main
import "fmt"
//golang by default passes values into
//funcs by value with no reference
//to the original memory address
//if you want to affect the original
//value you can pass in the memory address
//and derefernce that value and reset it
//to change the original
//this is not true for reference data ... |
// Copyright (C) 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed t... |
package main
import (
"log"
"math/rand"
"github.com/gorilla/websocket"
)
func joinGame(game *Game, playerName string, conn *websocket.Conn) *Player {
var player *Player
if game.gameStarted {
player = findPlayerInGame(game, playerName)
if player == nil || player.ws != nil {
sendErrorMessageToClient(conn, ... |
package model
import "time"
type Patient struct {
Model
PatientId string `json:"patient_id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
DateOfBirth time.Time `json:"date_of_birth"`
Gender string `json:"gender"... |
package controller
import (
"github.com/gin-gonic/gin"
"net/http"
)
func GetHomePage(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"message": "ok",
"data": "hello",
})
}
|
/**
* 功能描述: 自定义错误信息code
* @Date: 2019-04-16
* @author: lixiaoming
*/
package errno
// 错误码定义
// 第1位: 服务级别 1(系统级错误) 2(普通错误)
// 第2-3位: 服务模块 01(用户)
// 第4-5位: 错误码 01(具体错误代码)
var (
// 通用错误
OK = &Errno{Code: 0, Message: "OK"}
InternalServerError = &Errno{Code: 10001, Message: "Internal server... |
package grpc
import (
"context"
"encoding/json"
"github.com/sapawarga/userpost-service/endpoint"
"github.com/sapawarga/userpost-service/lib/convert"
"github.com/sapawarga/userpost-service/model"
"github.com/sapawarga/userpost-service/usecase"
kitgrpc "github.com/go-kit/kit/transport/grpc"
transportUserPost "... |
package schema
import (
"github.com/facebook/ent"
"github.com/facebook/ent/schema/field"
)
// Job holds the schema definition for the Job entity.
type Job struct {
ent.Schema
}
// Fields of the Job.
func (Job) Fields() []ent.Field {
return []ent.Field{
field.Int("id").Positive(),
field.String("name").Default... |
package pkgexample
func AddMulti(a int, b int) int {
sum := Add(a,b)
product := Multi(a,b)
return sum + product
}
|
// 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 pkcs11test
import (
"context"
"chromiumos/tast/common/pkcs11"
"chromiumos/tast/errors"
)
// SignAndVerify is just a convenient runner to test both signing and v... |
package pack
import (
"bytes"
"context"
"crypto/sha1"
"fmt"
"math/rand"
"reflect"
"testing"
"github.com/twcclan/goback/backup"
"github.com/twcclan/goback/proto"
"github.com/stretchr/testify/require"
)
// number of objects to generate for the tests
const numObjects = 1000
// average size of objects
const ... |
package config
import (
"github.com/7phs/coding-challenge-search/helper"
"github.com/c2h5oh/datasize"
log "github.com/sirupsen/logrus"
"gopkg.in/go-playground/validator.v9"
)
const (
EnvConfigAddr = "ADDR"
EnvConfigCors = "CORS"
EnvConfigStage = "STAGE"
EnvConfigDatabaseUrl = "DB_U... |
package grabber
import (
"fmt"
"github.com/inimbir/onpu-data-grabber/app/clients"
"github.com/inimbir/onpu-data-grabber/app/http"
)
type MainConfig struct {
ApplicationName string
ApplicationEnv string
ApplicationConfigPath string
ApplicationTasks []string
}
var config MainConfig
func Print... |
package cmd
import (
"os"
"path/filepath"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/elonzh/skr/pkg/utils"
)
var (
cfgFile = ""
rootCmd = &cobra.Command{
Use: "skr",
Short: "🏁 skr~ skr~",
}
v = viper.GetViper()
)
func Execute() {
if err := rootCmd.E... |
// Copyright 2018 SumUp Ltd.
//
// 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 ... |
/*******************************************************************************
* Copyright 2017 Samsung Electronics 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... |
package gui
import (
"fmt"
"path/filepath"
"strings"
"github.com/fatih/color"
"github.com/go-errors/errors"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazynpm/pkg/commands"
"github.com/jesseduffield/lazynpm/pkg/gui/presentation"
"github.com/jesseduffield/lazynpm/pkg/utils"
)
// list panel fu... |
package service
import "errors"
var (
ErrOverlapBetweenOwnersAndMaintainers = errors.New("overlap between owners and maintainers")
ErrOverlapInOwners = errors.New("overlap (in owners/between login user and owners)")
ErrOverlapInMaintainers = errors.New("overlap in maintainers")
Er... |
// 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"
"sync"
)
func printName(wg *sync.WaitGroup, name string) {
fmt.Println(name)
// Call Done to signal exit of go routine
defer wg.Done()
}
func printLocation(wg *sync.WaitGroup, loc string) {
fmt.Println(loc)
defer wg.Done()
}
func main() {
// Create a wait group
var wg sync.... |
package main
import (
"fmt"
"net"
"path"
"runtime"
"github.com/Gimulator/Gimulator/api"
"github.com/Gimulator/Gimulator/cmd"
"github.com/Gimulator/Gimulator/config"
"github.com/Gimulator/Gimulator/epilogues"
"github.com/Gimulator/Gimulator/manager"
"github.com/Gimulator/Gimulator/simulator"
"github.com/Gim... |
package main
import (
"github.com/go-kit/kit/log/level"
"fmt"
"time"
"database/sql"
"sort"
"bitbucket.org/garyyu/algo-trading/go-binance"
)
var (
LatestOrderID = make(map[string]int64)
)
type OrderData struct {
id int64 `json:"id"`
ProjectID int64 `json:"ProjectID"`
IsDone bool `json:"Is... |
package c2netapi
import (
"net/http"
)
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
}
type Routes []Route
var routes = Routes{
// All Tags Routes
Route{"AllAreas", "GET", "/allareas", AllSensorAreas},
Route{"NewArea", "POST", "/area", InsertSenso... |
package sort
import "testing"
func TestQuickSort(t *testing.T) {
var arr []int
arr = []int{1}
t.Logf("before: %v", arr)
quickSort(arr, len(arr))
t.Logf("after: %v", arr)
arr = []int{2, 1}
t.Logf("before: %v", arr)
quickSort(arr, len(arr))
t.Logf("after: %v", arr)
arr = []int{3, 1, 2}
t.Logf("before: %v"... |
// Copyright © 2019 Michael. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package app
import (
"context"
"flag"
"fmt"
"os"
"skygo/load"
"skygo/utils/log"
)
type build struct {
name string //top cmd name
NoDeps bool `flag:"... |
package logger_test
import (
"bytes"
"context"
"fmt"
"github.com/adamluzsi/frameless/pkg/iokit"
"github.com/adamluzsi/frameless/pkg/logger"
"github.com/adamluzsi/frameless/pkg/stringcase"
"github.com/adamluzsi/testcase"
"github.com/adamluzsi/testcase/assert"
"github.com/adamluzsi/testcase/random"
"os"
"runt... |
package cmd
import (
"github.com/khushmeeet/vc/vc"
"github.com/spf13/cobra"
)
// logCmd represents the log command
var logCmd = &cobra.Command{
Use: "log",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your co... |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
package rest
import (
"github.com/project-flogo/core/data/coerce"
)
type Settings struct {
Port int `md:"port,required"` // The port to listen on
EnableTLS bool `md:"enableTLS"` // Enable TLS on the server
CertFile string `md:"certFile"` // The path to PEM encoded server certificate
KeyFile ... |
package dao
import (
"crypto/rand"
"encoding/hex"
"time"
"websocket_test_1/models"
)
// CreateMessage creates a message with the provided details and returns the created message
func CreateMessage(senderID, recipientID, content string) (*models.Message, error) {
//Generate the messageId
b := make([]byte, 4)
... |
package http
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestHttpServer(t *testing.T) {
// This method is to handle the expected response
handler := func(w http.ResponseWriter, r *http.Request) {
// The expected response is from exter... |
// 7 july 2014
package ui
// Window represents a top-level window on screen that contains other Controls.
// Windows in package ui can only contain one control; the Stack, Grid, and SimpleGrid layout Controls allow you to pack multiple Controls in a Window.
// Note that a Window is not itself a Control.
type Window i... |
package invoice
import (
"github.com/boltdb/bolt"
"encoding/json"
"fmt"
"bytes"
"net/http"
"github.com/julienschmidt/httprouter"
"log"
"github.com/mpdroog/invoiced/invoice/camt053"
"github.com/mpdroog/invoiced/config"
"strings"
"io"
)
// Parse bankbalance in CAMT053-format
func Balance(w http.ResponseWrit... |
package main
import "fmt"
// for 结构
//func main() {
// for i := 0; i < 5; i++ {
// fmt.Printf("This is the %d iteration\n", i)
// }
//
// //for i := 0; i < 2; i++ {
// // for j := 0; j < 5; j++ {
// // println(j)
// // }
// //}
//
// str := "Go is a beautiful language!"
// fmt.Printf("The length of str is: %d\n", ... |
package chconn
import (
"context"
"errors"
"fmt"
"io"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/vahid-sohrabloo/chconn/v2/column"
"github.com/vahid-sohrabloo/chconn/v2/internal/helper"
)
func TestProfileReadError(t *testing.T) {
startValidReader ... |
package requests
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"github.com/atomicjolt/canvasapi"
"github.com/atomicjolt/canvasapi/models"
)
// ListFolders Returns the paginated list of folders in the folder.
// https://canvas.instructure.com/doc/api/files.html
//
// Path Parameter... |
package tests
import (
"reflect"
"testing"
ravendb "github.com/ravendb/ravendb-go-client"
"github.com/stretchr/testify/assert"
)
func ravendb9676canOrderByDistanceOnDynamicSpatialField(t *testing.T, driver *RavenTestDriver) {
var err error
store := driver.getDocumentStoreMust(t)
defer store.Close()
{
sess... |
// 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 consttypes
type String string
func (s String) String() string { return string(s) }
type Error string
// Error implement the error interface
func (err Error) Error() string { return string(err) }
|
package main
import (
"fmt"
"time"
_ "errors"
)
func test(){
defer func (){
err := recover()
fmt.Println(err)
}()
panic("hello")
}
func main() {
var now time.Time = time.Now()
fmt.Println(now.Year(), int(now.Month()), now.Day(), now.Hour(),
now.Minute(), now.Second())
test()
fmt.Println("hello11")
... |
package routes
import (
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/sessions"
)
var (
cookieNameForSessionID = "mycookiesessionnameid"
sess = sessions.New(sessions.Config{Cookie: cookieNameForSessionID})
)
func registerSessionRoute(app *iris.Application) {
app.Get("... |
package main
import (
"io/ioutil"
"os"
"fmt"
"log"
"time"
"path"
"strconv"
"encoding/json"
)
func competitionRoot(CompetitionId uint64) string {
return fmt.Sprintf("db/%d", CompetitionId)
}
func competitionPath(CompetitionId *uint64, name string) string {
if CompetitionId != nil {
return fmt.... |
package accounting
import (
"github.com/fanda-org/postmasters/database/models"
"github.com/fanda-org/postmasters/database/models/system"
)
// LedgerGroup model
type LedgerGroup struct {
models.Base
GroupCode string `gorm:"size:12;not null;unique_index:uix_ledger_group_code"` //A-00-0-00000 -> (A/L... |
package sorts
func Merge(s []int) {
if len(s) < 2 {
return
}
half := len(s) / 2
left, right := s[0:half], s[half:]
Merge(left)
Merge(right)
sortRelativeSortedSlices(left, right)
}
func sortRelativeSortedSlices(left, right []int) {
lLength, rLength := len(left), len(right)
totalLength := lLength + rLen... |
package resttest
import (
"encoding/json"
"github.com/stretchr/testify/suite"
"net/http"
"testing"
)
func TestRunnerTestSuite(t *testing.T) {
suite.Run(t, new(RunnerTestSuite))
}
type RunnerTestSuite struct {
suite.Suite
fixedSender string
runner *Runner
response *greetingResponse
}
func (s *Runner... |
package rickandmortyapiclient
import (
"strconv"
"strings"
)
// ParseURL is function for get id of schema and return
func ParseURL(url string) int {
if url != "" {
urlSplited := strings.Split(url, "/")
ID, errParse := strconv.Atoi(urlSplited[len(urlSplited)-1])
if errParse != nil {
panic(errParse)
}
r... |
package mci
import (
"fmt"
"os"
"reflect"
"regexp"
"github.com/bingoohuang/gou/reflec"
"github.com/jedib0t/go-pretty/v6/table"
)
// TablePrinter print table.
type TablePrinter struct {
dittoMark string
}
// Print prints the table.
func (p TablePrinter) Print(value interface{}) {
header := make(table.Row, 0)... |
// simple-authd project main.go
package main
import (
"encoding/base64"
"encoding/hex"
"flag"
"fmt"
"log"
"math/rand"
"net"
"net/http"
"strings"
"sync"
"time"
)
type stringList map[string]string
func (l *stringList) String() string {
return fmt.Sprintln(*l)
}
func (l *stringList) Se... |
// 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 externalmetrics
import (
"fmt"
"strconv"
apicommon "github.c... |
package main
import "fmt"
func main() {
truth := true
negate(&truth)
fmt.Println(truth)
lie := false
negate(&lie)
fmt.Println(lie)
}
func negate(myBool *bool) {
*myBool = !*myBool
}
|
package uuid
import (
"code.google.com/p/go-uuid/uuid"
"fmt"
)
func GenerateUuid() uuid.UUID {
uuid := uuid.NewRandom()
fmt.Println("Generated uuid:", uuid)
return uuid
}
|
package main
import "fmt"
func main() {
a := byte('A')
// showing print format specifier for decimal, octal, hex
// and binary.
fmt.Printf("%d %o %x %b \n", a, a, a, a)
// using only one argument with multiple format specifiers
fmt.Printf("%d %[1]o %[1]x %[1]b\n", a)
// let go implicity convert from a rune... |
package model
import (
"fmt"
"time"
"github.com/globalsign/mgo/bson"
"github.com/simplejia/clog/api"
)
func (stat *Stat) CleanNumDay() (err error) {
c := stat.GetC()
defer c.Database.Session.Close()
day := time.Now().Add(time.Hour * 24).Day()
field := fmt.Sprintf("num_day_%d", day)
sel := bson.M{
field:... |
package client
// Config - client configuration
type Config struct {
Addr string
Space string
}
|
// Copyright © 2019 Michael. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package pkg
import (
"os"
"path/filepath"
"skygo/utils"
"skygo/utils/log"
)
var pn = [...]string{
"usr/bin",
"usr/sbin",
"bin",
"sbin",
"usr/lib",
"lib"... |
package main
import "fmt"
func foldr3(f func(a,b []int) []int, z []int, list []int)[]int{
if len(list) == 0{
return z
}
return f(list[:1],foldr3(f,z,list[1:]))
}
func main() {
ilist := []int{1,2,3,4,5,6,7,8}
fn := func(a,b []int) []int {
b = app... |
// 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 wmp
import (
"context"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/chrome/ash"
"chromiumo... |
// Copyright (c) KwanJunWen
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
package estemplate
import "fmt"
// CharacterFilterHTMLStrip character filter that strips HTML elements from the text
// and replaces HTML entities with their decod... |
package main
import (
"bufio"
"fmt"
"log"
"os"
)
func powi(y, x int) int {
ret := 1
for x > 0 {
if x&1 > 0 {
ret *= y
}
y *= y
x >>= 1
}
return ret
}
func armstrong(n int) bool {
var e, t int
for a := n; a > 0; a /= 10 {
e++
}
for a := n; a > 0; a /= 10 {
t += powi(a%10, e)
}
return n ==... |
// 明确定义该模块需要的上下文信息,方便代码阅读和理解
package context
import (
"github.com/xuperchain/xupercore/kernel/common/xaddress"
xctx "github.com/xuperchain/xupercore/kernel/common/xcontext"
"github.com/xuperchain/xupercore/kernel/contract"
"github.com/xuperchain/xupercore/kernel/ledger"
"github.com/xuperchain/xupercore/kernel/net... |
package main
import (
"bytes"
"fmt"
"io"
"os"
)
var w io.Writer
func main() {
w = os.Stdout
f, ok := w.(*os.File)
fmt.Println(f, ok)
c, ok := w.(*bytes.Buffer)
fmt.Println(c, ok)
// rw := w.(io.ReadWriter)
// w = new(ByteCounter)
// rw = w.(io.ReadWriter)
}
|
// 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/rand"
"encoding/binary"
math_rand "math/rand"
)
func init() {
var b [8]byte
_, err := rand.Read(b[:])
if err != nil {
panic(err)
}
math_rand.Seed(int64(binary.LittleEndian.Uint64(b[:])))
}
func randomString(l int) string {
bytes := make([]byte, l)
for i := 0; i < l; i++ {
... |
// ===================================== //
// author: gavingqf //
// == Please don'g change me by hand == //
//====================================== //
/*you have defined the following interface:
type IConfig interface {
// load interface
Load(path string) bool
// clear interface
Clear()
}... |
package sml
import (
"fmt"
"regexp"
"strings"
"unicode"
"unicode/utf8"
)
// The design of this lexer is based on "Lexical Scanning in Go" by Rob Pike
// https://talks.golang.org/2011/lex.slide
// token represents a tokenized text string that a lexer identified.
type token struct {
typ tokenType // token type
... |
package week2
import (
"fmt"
"github.com/jinzhu/gorm"
"github.com/pkg/errors"
)
type User struct {
Id string `json:"id"`
Name string `json:"name"`
}
func GetUser(db *gorm.DB, id string) (*User, error) {
var user = &User{}
err := db.Table("users").Where("id = ?", id).First(user).Error
return user, errors.W... |
package main
import (
"io"
"os"
"reflect"
)
/*
go语言中每个变量都有唯一个静态类型。
interface的结构包含类型(type)和数据值(value):
无函数eface(interface{}):
type --> type类型对象
value --> data
有函数iface
type--> 静态类型 --> 静态类型
动态混合类型 --> 动态混合类型
方法集 --> 函数列表
value --> data
*/
//interface例子
func inter() {
/*
r --... |
package name
import (
"crypto/sha256"
"encoding/hex"
)
// KeyHash returns the first 12 hex characters of the hash of the first 100 chars
// of the input string
func KeyHash(s string) string {
if len(s) > 100 {
s = s[:100]
}
d := sha256.Sum256([]byte(s))
return hex.EncodeToString(d[:])[:12]
}
|
package pgygo
import (
"fmt"
"net/http"
"reflect"
)
/**
*
*/
type controllerInfo struct {
methods []int8 //HTTP方法
controllerType reflect.Type
name string //函数名称
typ reflect.Type //函数类型
pnames []string //函数参数名称列表
}
type routerRegistor struct {
routermap map[str... |
package models
// Direction 委托/持仓方向
type Direction int
const (
Buy Direction = iota // 做多
Sell // 做空
)
// OrderType 委托类型
type OrderType int
const (
OrderTypeMarket OrderType = iota // 市价单
OrderTypeLimit // 限价单
OrderTypeStopMarket // 市价止损单
OrderTypeS... |
package kubeobjects
import "os"
const (
platformEnvName = "PLATFORM"
openshiftPlatformEnvValue = "openshift"
kubernetesPlatformEnvValue = "kubernetes"
)
type Platform int
const (
Kubernetes Platform = iota
Openshift
)
func ResolvePlatformFromEnv() Platform {
switch os.Getenv(platformEnvName) {
c... |
package routes
import (
"github.com/iris-contrib/middleware/cors"
"github.com/kataras/iris"
"gotest/controllers"
)
type UserRouter struct {
uparty iris.Party
}
func (u *UserRouter) SetUserRouter(app *iris.Application, path string) {
crs := cors.New(cors.Options{
AllowedOrigins: []string{"*"}, // allows eve... |
// Copyright 2017 Intel Corporation.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"flag"
"github.com/intel-go/nff-go/flow"
"github.com/intel-go/nff-go/packet"
)
var (
load uint
loadRW uint
)
func main() {
flag.UintVar(&load, "... |
package models
type Conversation struct {
ID string `json:"_id,omitempty" bson:"_id,omitempty"`
IsGroupChat bool `json:"isGroupChat,omitempty" bson:"isGroupChat,omitempty"`
Parties []string `json:"parties,omitempty" bson:"parties,omitempty"`
Messages []_MessageObject `... |
package fileserver
import (
"net/http"
)
// Serve the directory `dir` using HTTP on the specified TCP address.
//
// `dir`: filepath to serve.
// `address`: TCP address (`"<host>:<port>"`). The host can be omitted.
// `cache`: If false, the browser is sent headers to prevent it from caching
// content.
func ServeDir... |
package helm
import (
"encoding/json"
"fmt"
"github.com/pkg/errors"
"io"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/manifest"
"k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/renderutil"
"log"
"net/http"
"os"
"path/filepath"
"strings"
)
type Client struct {
}
func Some() {
c, err := GetHelmArchive... |
package controller
import (
"log"
"os"
"fmt"
"gopkg.in/kataras/iris.v6"
"github.com/dgrijalva/jwt-go"
"github.com/jinzhu/gorm"
"golang.org/x/crypto/scrypt"
"github.com/filipbekic01/go-web-framework/models"
)
func Register(ctx *iris.Context) {
db, err := gorm.Open("mysql", "root:filip@/goback?charset=utf8&pa... |
package webbot
import (
"log"
"sync"
"time"
"util"
)
type InfoCap struct {
X int
Y int
Version int
Lable string
id uint32
version uint32
group uint32
revision uint64
callback func() (string, error)
interval time.Duration
logger *log.Logger
debug bool
}
func (ic *InfoCap)... |
// 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 textio
import (
"bytes"
"fmt"
"testing"
)
func TestPrefixWriter(t *testing.T) {
b := &bytes.Buffer{}
b.WriteByte('\n')
w1 := NewPrefixWriter(b, "\t")
w2 := NewPrefixWriter(w1, "\t- ")
fmt.Fprint(w1, "hello:\n")
fmt.Fprint(w2, "value: 1")
fmt.Fprint(w2, "\n")
fmt.Fprint(w2, "value: 2\nvalue: 3\n"... |
package factorlib
import (
"github.com/randall77/factorlib/big"
"github.com/randall77/factorlib/linear"
"log"
"math/rand"
"runtime"
)
func init() {
factorizers["mpqs"] = mpqs
}
// mpqs = Multiple Polynomial Quadratic Sieve
//
// define f(x) = (ax+b)^2 - n
//
// f(x) = a^2x^2+2abx+b^2-n
// = a(ax^2+2bx+c) ... |
package rest
import (
"encoding/json"
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmwasm/wasmd/x/wasm/internal/keeper"
"github.com/cosmwasm/wasmd/x/wasm/internal/types"
"net/http"
"strconv"
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/g... |
package area
import (
"fmt"
"net"
"sync"
"net/source/userapi"
"net/source/msg/msgproc"
"sync/atomic"
"net/source/proto/endpoint_poller"
)
type ServiceIOCenter struct {
}
var service ServiceIOCenter
func init() {
msgproc.GetAppTools().SvrIO = &service
}
func (s *ServiceIOCenter) ClearClient(c userapi.IClie... |
package daemonset
import (
"fmt"
"github.com/Dynatrace/dynatrace-operator/src/controllers/dynakube/connectioninfo"
"github.com/Dynatrace/dynatrace-operator/src/version"
)
func (dsInfo *builderInfo) arguments() []string {
args := make([]string, 0)
args = dsInfo.appendHostInjectArgs(args)
args = dsInfo.appendPr... |
package main
import (
"log"
"net"
)
func dealClient(conn *net.Conn) {
client := &XClient{client:conn}
client.Login()
}
func main() {
listener, err := net.Listen("tcp", ":8888")
if err != nil {
}
log.Println("")
for {
client, err := listener.Accept()
if err != nil {
log.Println("Accept failed.", err... |
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
//
package utility
import (
"fmt"
"strings"
"github.com/mattermost/mattermost-cloud/model"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
type velero struct {
cluster *model.Clust... |
package main
import (
"fmt"
"golang.org/x/tools/container/intsets"
"io/ioutil"
"log"
"strings"
)
type Units []rune
func loadFile(filename string) Units {
bytes, err := ioutil.ReadFile(filename)
if err != nil {
log.Fatal(err)
}
trimmedLine := strings.TrimSpace(string(bytes))
return []rune(trimmedLine)
}
... |
// 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 cuj contains fixtures, utils for cuj.
package cuj
import (
"context"
"fmt"
"regexp"
"strings"
"time"
"chromiumos/tast/common/action"
"chromiumos/tast/erro... |
package network
import (
"encoding/json"
"fmt"
"log"
"math/rand"
)
/*
Track defines common functionality for all kinds of tracks
*/
type Track interface {
Location
A() *Junction
B() *Junction
id() string
oppositeEnd(*Junction) *Junction
}
/*
baseTrack is a base struct representing a bidirectional track from... |
package structure_test
import (
"fmt"
"github.com/payfazz/ditto/structure"
"github.com/payfazz/ditto/structure/field"
"testing"
)
func TestRequiredAttrsField(t *testing.T) {
c1, err := structure.CreateComponent("text")
if nil != err {
t.Fatal(err)
}
fmt.Println(c1.RequiredAttrs())
c2, err := structure.Cre... |
package main
import (
"fmt"
)
func main(){
fmt.Print("mesa")
fmt.Print(" cadeira")
} |
package metrics_test
func (s *metrics) TestMemory() {
result, streamURL, err := s.metrics.Memory(nil)
if !s.NoError(err) {
return
}
s.Nil(streamURL)
if !s.NotNil(result) {
return
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.