text stringlengths 11 4.05M |
|---|
/*
Copyright © 2019 BlackRock 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 in writing, softwar... |
package routers
import (
"github.com/astaxie/beego"
"quickstart/controllers"
)
func init() {
beego.Router("/datagrid",&controllers.EasyController{},"*:DataGrid")
beego.Router("/data",&controllers.EasyController{})
beego.Router("/editgrid",&controllers.EasyController{},"*:EditDatagrid")
beego.Router("/save",&con... |
// Copyright 2014 David Persson. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
)
func inspectJob(id uint64) (err error) {
body, err := conn.Peek(id)
stats, _ := conn.StatsJob(id)
if err != nil {
retur... |
package middleware
import "net/http"
func NoCache(inner http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Cache-Control", "no-store")
w.Header().Add("Cache-Control", "no-cache")
inner.ServeHTTP(w, r)
})
}
|
/*
* Copyright 2018- The Pixie 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 ag... |
package notifications
import (
"fmt"
log "github.com/sirupsen/logrus"
)
type Action uint
const (
Drain = Action(iota)
Reboot
)
type Notifier interface {
Notify(action Action) error
}
type ShoutrrrNotifier struct {
NotifyURL string
DrainMsg string
RebootMsg string
}
func (shtrn ShoutrrrNotifier) Notify(a... |
package main
import (
"fmt"
"github.com/k8s-utils/pod"
)
func main() {
// only for test
fmt.Println(pod.IsPodReady(nil))
}
|
package clubs
import "github.com/anihouse/bot"
var _module module
func init() {
bot.Modules.Register(_module.ID(), &_module)
}
|
package metrics
import (
"fmt"
"io/ioutil"
"log"
"plugins"
"strings"
)
// PLATFORMS
// Linux
func (display *DisplayStats) createPayload(r *plugins.Result) error {
if !display.continue_gathering {
return nil
}
content, err := ioutil.ReadFile("/sys/class/switch/hdmi/state")
if nil != err {
log.Printf("F... |
package main
import (
"io/ioutil"
"fmt"
"os"
)
func main() {
open()
}
func read() {
data, err := ioutil.ReadFile("EXAMPLE_WORKS/read.txt")
if err != nil {
panic(err)
}
fmt.Println(string(data))
}
func write() {
mydata := []byte("We’ll use Go’s while loop equivalent of a for loop without any parameters to... |
package slice
import "reflect"
func Foreach(slice interface{}, f func(i int, v interface{})) {
foreach(valueOf(slice), f)
}
func foreach(sv reflect.Value, f func(i int, v interface{})) {
for i := 0; i < sv.Len(); i++ {
f(i, sv.Index(i).Interface())
}
}
// reflect.ValueOf for slice, compared to reflect.ValueOf,... |
package company
import (
"gitlab.com/username/online-service-and-customer-care/entity"
)
// CompanyRepository specifies company related database operations
type CompanyRepository interface {
Companies() ([]entity.Company, []error)
Company(id uint) (*entity.Company, []error)
UpdateCompany(company *entity.Company) ... |
package rtmp
import (
"github.com/ubinte/livego/av"
"github.com/ubinte/livego/protocol/rtmp/core"
log "github.com/sirupsen/logrus"
)
type Client struct {
handler av.Handler
getter av.GetWriter
}
func NewClient(h av.Handler, getter av.GetWriter) *Client {
return &Client{
handler: h,
getter: getter,
}
}
... |
package main
type node uint
type edge struct {
First node
Second node
}
type graph struct {
Input []edge
Result []edge
}
func edgesEqual(a []edge, b []edge) bool {
if len(a) != len(b) {
return false
}
for i, v := range a {
if v != b[i] {
return false
}
}
return true
}
|
package main
import "math"
type Camera interface {
ray(rnd Rnd, u float64, v float64) *Ray
}
type FullyFletchedCamera struct {
origin Vector
lowerLeftCorner Vector
horizontal Vector
vertical Vector
u, v, w Vector
lensRadius float64
}
func MakeCamera(lookFrom, lookAt, up Vect... |
/*
* EVE Swagger Interface
*
* An OpenAPI for EVE Online
*
* OpenAPI spec version: 0.2.2
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obta... |
package web_dao
import (
"2021/yunsongcailu/yunsong_server/dial"
"2021/yunsongcailu/yunsong_server/web/web_model"
)
type ArticleDao interface {
// 获取某一大类文章(主要用于第一个大类的文章 最先展示)
QueryIndexArticle(menuId int64,count,start int) (articles []web_model.ArticleModel,err error)
// 获取各大类首页展示文章
QueryMenuIndexArticle(menuId... |
package handler
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/stretchr/objx"
)
// MainPageHandler -- top page handler
func MainPageHandler(c echo.Context) error {
auth, err := c.Cookie("auth")
if err != nil {
return c.Render(http.StatusOK, "welcome", map[string]interface{}{
"title": "Welcom... |
package websocket
import (
"crypto/tls"
"fmt"
"github.com/pkg/errors"
"net"
"sync"
)
// Ugly (and probably non-convetional) interface that exports the only public
// functions of connections to clients.
// None of these are thread-safe. However, since they should only be called from
// the gorouti... |
package util
import "encoding/hex"
func Bytes2Hex(data []byte) string {
enc := make([]byte, len(data)*2+2)
copy(enc, "0x")
hex.Encode(enc[2:], data)
return string(enc)
}
|
package dbtest
import (
"math/rand"
"sync"
"testing"
"time"
"github.com/stretchr/testify/assert"
)
const collectionname = "users"
func TestConcurrentCreateUser(t *testing.T) {
db, err := initializeTestEnv(collectionname)
defer db.Disconnect()
assert.Nil(t, err)
userDB := db.ToUserDB(Database, collectionn... |
package getui_model
import (
"bytes"
"crypto/sha256"
"encoding/json"
"fmt"
"ibgame/logs"
"io/ioutil"
"net/http"
"strconv"
"time"
)
func PushSingel(param Single) (ret string, err error) {
if len(param.Cid) == 0 {
return "", fmt.Errorf("[PushToSingle] 错误的目标设备, cid 与 alias 任选且必选一个")
}
param.Requestid = str... |
package cmd
import (
"fmt"
"os"
"strconv"
"strings"
"github.com/spf13/cobra"
)
// Create the add command
var cmdAdd = &cobra.Command{
Use: "add [WORKFLOW]",
Short: "Add jobs to or create a workflow",
Long: `Add jobs to or create a Swif workflow.
The workflow is created if it does not already exist.
A JSO... |
package kucoin
import (
"testing"
"time"
)
func TestApiService_Symbols(t *testing.T) {
s := NewApiServiceFromEnv()
rsp, err := s.Symbols("")
if err != nil {
t.Fatal(err)
}
l := SymbolsModel{}
if err := rsp.ReadData(&l); err != nil {
t.Fatal(err)
}
for _, c := range l {
t.Log(ToJsonString(c))
switch ... |
package commands
import (
"github.com/c0caina/inaWarp/global"
"github.com/df-mc/dragonfly/server/cmd"
"github.com/df-mc/dragonfly/server/player"
)
type WarpTp struct {
Tp tp
Name string
}
func (wt WarpTp) Run(source cmd.Source, output *cmd.Output) {
XYZ, err := global.WarpSqlite.SelectName(wt.Name)
if err !... |
package _40_Combination_Sum_2
import "testing"
func TestCombinationSum(t *testing.T) {
var (
candidates []int
target int
ret [][]int
)
candidates = []int{10, 1, 2, 7, 6, 1, 5}
target = 8
ret = combinationSum2(candidates, target)
t.Log(ret)
candidates = []int{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,... |
/**
* @Author: yanKoo
* @Date: 2019/3/11 11:16
* @Description:
*/
package customer
import (
cfgComm "configs/common"
"database/sql"
"log"
"model"
"server/common/src/db"
"strconv"
"time"
)
var dbConn = db.DBHandler
// 增加用户
func AddAccount(a *model.CreateAccount) (int, error) {
tx, err := dbConn.Begin();
if e... |
package main
import "fmt"
func main() {
fmt.Println("Enter a number, enter 0 to quit")
total := 0
for {
n := 0
fmt.Scanf("%d", &n)
if n > 0 {
total += n
} else {
break
}
}
fmt.Println("Total =",total)
}
|
package main
import (
"crypto/md5"
"encoding/hex"
"errors"
"time"
"github.com/golang/glog"
)
type Manager struct {
Topic string
Group string
Url string
workers []*Worker
superviseInterval time.Duration
config *CallbackItemConfig
}
func NewManager... |
package utils
import (
"fmt"
"github.com/sotomskir/mastermind-server/dto"
"io/ioutil"
"log"
"os"
)
func HandleError(err error, message string) {
if err != nil {
log.Fatalf("%s: %s", message, err)
}
}
func WriteKey(id uint, content string) error {
if err := os.MkdirAll("storage/keys", 0700); err != nil {
... |
/*
* Copyright 2018, CS Systemes d'Information, http://www.c-s.fr
*
* 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 requir... |
package lru
import (
"container/list"
"github.com/tochka/tcached/cache"
)
func NewCache(maxEntries int) *Cache {
return &Cache{
MaxEntries: maxEntries,
l: list.New(),
m: make(map[string]*list.Element),
}
}
type entry struct {
key string
value cache.Value
}
type Cache struct {
MaxEn... |
package main
import (
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
)
type Officer struct {
Officerid int64 `gorm:"primary_key;type:int(11) auto_increment;not null"`
Name string `gorm:"type:varchar(64);not null"`
Gender int `gorm:"type:tinyint(1)"`
IdentityCard string ... |
package handlers
import (
"errors"
"time"
"github.com/authelia/authelia/v4/internal/configuration/schema"
"github.com/authelia/authelia/v4/internal/middlewares"
"github.com/authelia/authelia/v4/internal/regulation"
"github.com/authelia/authelia/v4/internal/utils"
)
// FirstFactorPOST is the handler performing ... |
package main
import (
"reflect"
"github.com/spf13/cobra"
)
// deepCopy is a helper function for deeply copying a Cobra command.
func deepCopy(cmd *cobra.Command) *cobra.Command {
newCmd := &cobra.Command{}
*newCmd = *cmd
return newCmd
}
// setProperty takes a struct pointer and searches for its "toml" tag with... |
package tx_test
import (
"math/rand"
"reflect"
"testing/quick"
"github.com/renproject/surge"
"github.com/renproject/surge/surgeutil"
"github.com/renproject/tx"
"github.com/renproject/tx/txutil"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Transactions", func() {
t := reflect.... |
package code
import "fmt"
//nolint: golint
var (
// Common errors
OK = &Errno{Code: 0, Message: "OK"}
InternalServerError = &Errno{Code: 10001, Message: "Internal server error"}
ErrBind = &Errno{Code: 10002, Message: "Error occurred while binding the request body to the struct."}
Err... |
package main
import (
"errors"
"flag"
"fmt"
"net/url"
"os"
"strings"
"sync"
"time"
)
var (
// Using two maps, with mutexes to protect them from concurrent updates
// - one to prevent double-fetching
// - one for persistent storage of parent/child relationships between pages
// TODO: time permitting, conso... |
package common
import (
"encoding/json"
"flag"
. "os"
log "github.com/sirupsen/logrus"
)
type LoggingString struct {
Data string `json:"data"`
}
type LoggerConfig struct {
FilePath string
}
func InitializeLogger(config *LoggerConfig) {
flag.Parse()
var file, err1 = OpenFile(config.FilePath, O_RDWR|O_CREATE... |
package controller
import (
"fmt"
"math/rand"
"net/http"
"../model"
"../service"
"../util"
)
var userService service.UserService
func UserRegisterHandle(writer http.ResponseWriter, request *http.Request) {
request.ParseForm()
mobile := request.PostForm.Get("mobile")
password := request.PostForm.Get("passwo... |
package operations
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/api/equality"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)
// StatusOperationsInterface bulabula
type StatusOperationsInterface interface {
Update(ctx context.... |
// Copyright 2020 Kuei-chun Chen. All rights reserved.
package mdb
import (
"encoding/json"
"errors"
"fmt"
"regexp"
"strings"
"github.com/simagix/gox"
)
// Logv2 stores logv2 info
type Logv2 struct {
Attributes struct {
Command map[string]interface{} `json:"command" bson:"command"`
Milli ... |
package sessions_test
import (
"context"
"errors"
"fmt"
"net/http"
"net/http/httptest"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/pomerium/pomerium/internal/encoding/jws"
"github.com/pomerium/pomerium/internal/sessions"
"github.com/pomerium/pomerium/internal/sessions/mock"
"github.com/pomerium/p... |
// RAINBOND, Application Management Platform
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your opt... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//274. H-Index
//Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-... |
package stank
// Version is semver.
const Version = "0.0.24"
|
/*
Copyright 2021 RadonDB.
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
distri... |
package main
import (
"image"
"image/color"
"image/draw"
"image/png"
"log"
"math/rand"
"os"
"strconv"
"time"
"fmt"
"sort"
"github.com/jessemillar/gautomata/cells"
"github.com/jessemillar/gautomata/tools"
"gopkg.in/alecthomas/kingpin.v2"
)
var automata = map[string]func(image.RGBA, int, int, []color.R... |
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use ... |
package leetcode
func getRow(rowIndex int) []int {
var f [2][1000000]int
f[0][0] = 1
f[1][0] = 1
f[1][1] = 1
for i := 2; i <= rowIndex; i++ {
for j := 0; j <= i; j++ {
var l = 0
if j > 0 {
l = f[1 - (i & 1)][j - 1]
}
var r = f[1 - (i & 1)][j]
f[i & 1][j] = l + r
}
}
return f[rowIndex & 1... |
package staticdata
type Vip_Data struct {
ID int
Level int
FreeMoney int
Discount float32
Icon int
}
func (self *Vip_Data) GetName() string {
return "vip"
}
func (self *Vip_Data) GetFilePath() string {
return "csv/vip_data.csv"
}
|
package Utils
import (
"encoding/json"
"fmt"
"github.com/stretchr/testify/assert"
"io/ioutil"
"os"
"testing"
)
func TestFilterData(t *testing.T) {
jsonFile, err := os.Open("../test.json")
if err != nil {
panic(err)
}
fmt.Println("File opened successfully")
defer func(jsonFile *os.File) {
err := json... |
package TmxProperties
import (
"encoding/xml"
)
type EmbedTmxProperties struct {
Properties TmxProperties `xml:"properties"`
}
type TmxProperties struct {
// <properties>
// ------------
XMLName xml.Name `xml:"properties"`
// Wraps any number of custom properties. Can be used as a child of the
// ``map``, ``... |
package main
import (
"fmt"
)
func main() {
var s1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
for i:=0; i<len(s1); i++ {
// println(s1[i], s1[i:i+1])
}
HasPrefix("North London", "North")
HasPrefix("North London", "South")
HasSuffix("North London", "North")
HasSuffix("North London", "L... |
package lcr
// Game struct will represent the game
// should init the game using NewGame()
type Game struct {
players []*Player
turn *Player
}
// Join add new player to the Game
func (g *Game) Join(playerName string) *Player {
// create new player
p := Player{
name: playerName,
tokens: 3,
}
playersCou... |
package repositories
import (
"database/sql"
"github.com/shitakemura/myapi/models"
)
const (
articleNumPerPage = 5
)
func InsertArticle(db *sql.DB, article models.Article) (models.Article, error) {
const sqlStr = `
insert into articles (title, contents, username, nice, created_at)
values (?, ?, ?, 0, now())... |
package model
type AnalyticsOperator string
// List of AnalyticsOperator
const (
AnalyticsOperator_EQ AnalyticsOperator = "EQ"
AnalyticsOperator_NE AnalyticsOperator = "NE"
AnalyticsOperator_LT AnalyticsOperator = "LT"
AnalyticsOperator_LTE AnalyticsOperator = "LTE"
AnalyticsOperator_GT AnalyticsOperator = "GT"
... |
package models
import (
"time"
)
type OfflineMsg struct {
// Id string
Fromuser string ;
Touser string ;
Msgdate time.Time ;
Msgtype int ;
Msgbody []byte ;
}
|
package e2e
import (
"bytes"
"os/exec"
"strings"
"testing"
"github.com/10gen/realm-cli/internal/utils/test/assert"
"github.com/AlecAivazis/survey/v2/core"
"github.com/Netflix/go-expect"
)
// TestCLI is responsible for ensuring each command can successfully compile and execute
func TestCLI(t *testing.T) {
co... |
package main
import (
"bytes"
"crypto/md5"
"fmt"
"log"
"net/http"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
"github.com/afex/hystrix-go/hystrix"
)
const DefaultPort = ":3000"
const EnvPort = "PORT"
func main() {
os.Exit(realMain())
}
func realMain() int {
// Send all output to stdout
log.SetOu... |
// Copyright 2023 Google LLC. 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 applica... |
package main
import (
"fmt"
"os/exec"
"strings"
log "github.com/Sirupsen/logrus"
"github.com/quilt/quilt/api"
"github.com/quilt/quilt/api/client/getter"
)
func main() {
clientGetter := getter.New()
clnt, err := clientGetter.Client(api.DefaultSocket)
if err != nil {
log.WithError(err).Fatal("FAILED, coul... |
package db
import (
"context"
"emailSender/global"
"github.com/jackc/pgx/v4"
)
type aInfo struct {
Password string
Firstname string
Lastname string
Id string
}
func AddAuthor(email, firstname, lastName, password string) error {
_, err := global.Dbpool.Exec(context.Background(), "INSERT INTO authors (email,fi... |
package fetcher
import (
"context"
"fmt"
"log"
"github.com/pkg/errors"
"github.com/pmenglund/gcp-folders/tree"
"golang.org/x/oauth2/google"
crm "google.golang.org/api/cloudresourcemanager/v2beta1"
)
type Config struct {
Verbose bool
Root string
MaxDepth int
}
type Fetcher struct {
Config
ctx contex... |
package cmd
import (
"fmt"
"os"
"text/template"
"github.com/spf13/cobra"
)
const versionTplt = `
Clairctl version {{.}}
`
var version string
var templ = template.Must(template.New("versions").Parse(versionTplt))
var versionCmd = &cobra.Command{
Use: "version",
Short: "Get Versions of Clairctl and underlyi... |
package kubedatasource
import (
"context"
"fmt"
"sort"
"strings"
"time"
"github.com/sirupsen/logrus"
"github.com/vmware/kube-fluentd-operator/config-reloader/config"
kfoListersV1beta1 "github.com/vmware/kube-fluentd-operator/config-reloader/datasource/kubedatasource/fluentdconfig/client/listers/logs.vdp.vmwar... |
package api
import "github.com/gin-gonic/gin"
func Login(ctx *gin.Context) {
}
func Logout(ctx *gin.Context) {
}
func RegisterUser(ctx *gin.Context) {
}
func DisableUser(ctx *gin.Context) {
}
func DeleteUser(ctx *gin.Context) {
}
func ActivateUser(ctx *gin.Context) {
}
func ChangePassword(ctx *gin.Context) {
}
... |
package mocks
import (
"bytes"
"github.com/liquidm/llsr"
"github.com/liquidm/llsr/decoderbufs"
)
type DummyConverter struct{}
func (*DummyConverter) Convert(change *decoderbufs.RowMessage, enums llsr.ValuesMap) interface{} {
var buf bytes.Buffer
switch change.GetOp() {
case decoderbufs.Op_INSERT:
buf.Write... |
package infr
import (
"math"
"math/cmplx"
)
func Integrate(c []complex128, nn int, dt, v0 float64) []complex128 {
s := make([]complex128, nn)
nfold := nn / 2
pn := math.Pi / float64(nn)
cr := 2.0 * pn * v0 / dt
for k := 1; k < nfold; k++ {
cr = cr - 2.0 * imag(c[k]) / float64(k)
s[k] = complex(pn, 0.0) * ... |
package main
import (
"bufio"
"flag"
"fmt"
"github.com/blang/semver"
"github.com/bzumhagen/gitchanges/version"
"github.com/hoisie/mustache"
"github.com/spf13/viper"
"gopkg.in/src-d/go-billy.v4/osfs"
"gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/object"
"g... |
package http
// CreateTaskResponse represents response for POST /tasks API
type CreateTaskResponse struct {
Task *TaskData `json:"task"`
}
// ListTaskResponse represents response for GET /tasks API
type ListTaskResponse struct {
Tasks []*TaskData `json:"tasks"`
}
|
package main
// 计算两个整数值的的最大公约数(GCD-greatest common divisor)
func gcd(x, y int) int {
for y != 0 {
x, y = y, x%y
}
return x
}
func main() {
x, y := 2, 4
// 得到返回的最大公约数
res := gcd(x, y)
// 进行打印
println(res)
}
|
package fakes
import "github.com/cloudfoundry-incubator/notifications/models"
type FakePreferencesRepo struct {
NonCriticalPreferences []models.Preference
FindError error
}
func NewFakePreferencesRepo(nonCriticalPreferences []models.Preference) *FakePreferencesRepo {
return &FakePreferencesR... |
package frontparser
// const validFrontmatterSample string = `
// ---
// title: ceci est un titre
// template: fancy.tmpl
// ---
// # Markdown title
// This is some content.
// ## A Subtitle
// Some more content.
// `
// // missing heading delimiter
// const invalidFrontmatterSample1 string = `
// ---
// `
// fu... |
// Copyright 2019 PingCAP, 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 i... |
/*
# -*- coding: utf-8 -*-
# @Author : joker
# @Time : 2020-04-20 14:21
# @File : main.go
# @Description :
# @Attention :
*/
package main
import (
"gocv.io/x/gocv"
)
//
/**
docker run -v "$GOPATH":/Users/joker/go --rm -v "$PWD":/Users/joker/go/src/examples/opencv -w /Users/joker/go/src/examples/opencv -e GOOS=... |
package state
import (
"bytes"
"fmt"
"github.com/iotaledger/wasp/packages/dbprovider"
"io"
"github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/balance"
valuetransaction "github.com/iotaledger/goshimmer/dapps/valuetransfers/packages/transaction"
"github.com/iotaledger/hive.go/kvstore"
"github.com/io... |
package main
import "fmt"
/*
引用数据类型需要先分配内存,make或new
*/
func func3() {
a := 33
b := &a
fmt.Println(a)
*b = 99
fmt.Println(a)
fmt.Println(*b)
}
func main() {
a := 33
b := &a
fmt.Printf("%v -- %T -- %p\n", a, a, &a)
fmt.Printf("%v -- %T -- %p -- %v\n ", b, b, &b, *b)
func3()
//var user1 map[string]string ... |
package dcmdata
import (
"os"
"reflect"
"testing"
"github.com/grayzone/godcm/ofstd"
"github.com/grayzone/godcm/util"
)
func TestNewDcmFileProducer(t *testing.T) {
cases := []struct {
in_1 string
in_2 int64
want *DcmFileProducer
}{
{"", 0, &DcmFileProducer{status_: ofstd.MakeOFCondition(OFM_dcmdata, 18... |
// Copyright 2021 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package definition
import (
"fmt"
"strings"
"testing"
"github.com/franela/goblin"
)
// TestUnitCassandra test cases
func TestUnitCassandra(t *testing.T) {
g := gob... |
package db
import (
"database/sql"
"strings"
"GoVideo/com/env"
"fmt"
)
//定义全局变量
var DbConn *sql.DB;
type ComDb struct {
dbDriver string;
dbUser string;
dbName string;
dbPwd string;
dbPort string;
dbHost string;
maxIdle int;
maxOpen int;
}
func (this *ComDb) New(){
this.dbDriver =env.New("DB... |
package model
import (
"encoding/binary"
"fmt"
"ipv4"
"net"
)
type IpPacket struct {
Ipheader ipv4.Header
Payload []byte
}
func MakeIpPacket(message []byte, protocol int, src VirtualIp, dst VirtualIp) IpPacket {
h := ipv4.Header{
Version: IP_VERSION,
Len: IP_DEFAUTL_HEADER_LEN,
TOS: IP_DEFAU... |
package arp
import (
"bytes"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"github.com/iesreza/netconfig"
"net"
)
var defaultSerializeOpts = gopacket.SerializeOptions{
FixLengths: true,
ComputeChecksums: true,
}
type Address struct {
IP ne... |
package controllers
import (
"encoding/json"
"net/http"
"github.com/raykanavheti/LetsworkBackend/controllers/util"
"github.com/raykanavheti/LetsworkBackend/models"
)
//EducationController interface
type EducationController struct{}
// CreateEducations creates a new education for a user
func (catCntrl *EducationC... |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//494. Target Sum
//You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, ... |
package transport
import blog "github.com/atymkiv/echo_frame_learning/blog/model"
// Post create request
// swagger:parameters postCreate
type swaggPostReq struct {
// in:body
Body createReq
}
// Post model response
// swagger:response postResp
type swaggPostResponse struct {
//in:body
Body struct{
*blog.Post
... |
package run
import (
"testing"
floc "gopkg.in/workanator/go-floc.v1"
"gopkg.in/workanator/go-floc.v1/guard"
)
func TestRepeat(t *testing.T) {
// Construct the flow control object.
flow := floc.NewFlow()
defer flow.Release()
// Construct the state object which as data contains the counter.
state := floc.NewS... |
package main
import (
"github.com/ChimeraCoder/anaconda"
"bytes"
"context"
"fmt"
"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
"os"
"strconv"
"time"
)
func main() {
src := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: os.Getenv("GITHUB_API_TOKEN")},
)
... |
package crs
// newLFUItem ...
func newLFUItem(content interface{}) *LFUItem {
return &LFUItem{
Val: content,
}
}
// LFUItem ...
type LFUItem struct {
ID Snowflake
Val interface{}
counter uint64
}
func (i *LFUItem) increment() {
i.counter++
}
|
// Copyright (c) 2018 Intel Corporation
//
// 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 ag... |
package storage
import (
"context"
"fmt"
"os"
"github.com/go-redis/redis/v8"
)
var redisClient redis.UniversalClient
var ctx context.Context
// Setup Setup redis client
func Setup() error {
redisClient = redis.NewClient(&redis.Options{
Addr: os.Getenv("REDIS_SERVER"),
DB: 0,
Password: os.Geten... |
package main
import (
blc "bkc/c02-bck/BLC"
"fmt"
)
func main() {
// block := blc.NewBlock(1, nil, []byte("the first block testing"))
// fmt.Printf("the first block : %v\n", block)
bc := blc.CreateBlockChainWithGenesis()
//fmt.Printf("blockchain:%v\n", bc.Blocks[0])
bc.AddBlock(bc.Blocks[len(bc.Blo... |
package main
import (
"fmt"
"io"
"os"
"path/filepath"
"sort"
)
func dirTree(out io.Writer, path string, printFiles bool) error {
return printTree(out, path, printFiles, "")
}
func getOnlyDirs(files []os.FileInfo) []os.FileInfo {
onlyDirs := make([]os.FileInfo, 0)
for _, file := range files {
if file.IsDir(... |
package ctx
import (
"net/http"
helpers "github.com/robitx/inceptus/helpers"
)
type ctxKeyRequestID struct{}
// GetRequestID reads requestID from context, header or generates new one
func GetRequestID(headerName string, r *http.Request) string {
// check context
if requestID, ok := getStr(ctxKeyRequestID{}, r);... |
package main
import (
"bufio"
"context"
"flag"
"io"
"log"
"net/http"
"os"
"path/filepath"
"runtime"
"strconv"
"time"
"github.com/Code-Hex/pget"
"github.com/cheggaaa/pb"
)
// BufSize is size of buffer of a channel.
const BufSize = 1024
var proc int
// File is file object.
type File struct {
SavePath s... |
package gost512_test
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/number571/tendermint/crypto"
"github.com/number571/tendermint/crypto/gost512"
)
const (
TEST_SUBJECT = "subject"
TEST_PASSWORD = "password"
)
func TestSignAndValidateGost512(t *tes... |
package pool
import (
"github.com/barakb/go-rpc"
"time"
)
type Server struct {
*tcpTransport
}
func NewServer(logger rpc.Logger) *Server {
return &Server{NewTCPTransport(":0", time.Second, NewConnectionPool(4), logger)}
}
type EchoRequest struct {
Msg string
}
type EchoResponse struct {
Msg string
}
func (s... |
package main
import (
"context"
"fmt"
"log"
"sync"
"time"
"github.com/brigadecore/brigade-foundations/os"
"github.com/brigadecore/brigade/sdk/v3"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes"
)
type observerConfig struct {
delayBeforeCleanup time.Duration
healthcheckInterval time.Duration
ma... |
package controller
import (
"net/http"
"net/url"
"strconv"
"posthis/utils"
"github.com/gorilla/context"
"github.com/gorilla/mux"
)
//Handlers
func GetSearch() http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
searchModel := SearchModel{Model: Model{Scheme: r.URL.Scheme,... |
package bitmap
import (
"math/rand"
"testing"
"time"
"github.com/ohpkg/bitmap/word"
)
func (i *Index) Bits() []uint64 {
return i.bits
}
func RandIndex(l int) *Index {
ws := make([]uint64, rand.Intn(l))
p := 0
for i := 0; i < len(ws); i++ {
ws[i] = word.Rand64()
p += word.Weight(ws[i])
}
return NewInde... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.