text stringlengths 11 4.05M |
|---|
package main
import (
"encoding/json"
"log"
"net/http"
"github.com/apparatno/sample-webservice/pets"
"github.com/apparatno/sample-webservice/repository"
)
func main() {
// ikke bruk default mux men lag din egen
mux := http.NewServeMux()
// opprett instanser av avhengigheter
data := make(map[int64]reposito... |
package pratice
import (
"fmt"
"time"
)
func asyncFunc(s string){
for i := 0; i < 5; i++ {
time.Sleep(100 * time.Millsecond)
fmt.Println(s)
}
}
// メイン関数
func pratice() {
// goルーチンの関数の実行
for i := 0 ; i < 3; i ++ {
str := fmt.Sprintf("Go routine (no: %v)", i)
go asyncFunc(str)
}
... |
package main
import (
"bytes"
"encoding/json"
"fmt"
"log"
"net/http"
"net/http/httptest"
"os"
"strconv"
"testing"
"github.com/joho/godotenv"
"github.com/seongminnpark/nooler-server/internal/app/nooler"
)
var app nooler.App
func TestMain(m *testing.M) {
err := godotenv.Load("../.env")
if err != nil {
... |
package auth
import (
"net/http"
"time"
"github.com/dgrijalva/jwt-go"
"github.com/jinzhu/gorm"
)
// Server provides an authentication layer, with auth tokens provided
// by a LoginHandler and sensitive
type Server struct {
KeyStore
db *gorm.DB
}
const (
// DefaultKeyStep instructs to generate a new key every... |
package lib
import (
"fmt"
"io"
"log"
"net/http"
"strings"
"time"
)
// Wrap wraps HTTP request handler
func Wrap(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch {
case eqauls(r, "/health"):
w.WriteHeader(http.StatusOK)
case eqauls(r, ... |
package main
import (
"fmt"
"math/rand"
)
func main() {
var plot [10][10]int
for i := 0; i < len(plot); i++ {
for j := 0; j < len(plot[i]); j++ {
plot[i][j] = rand.Intn(2)
}
fmt.Println(plot[i])
}
fmt.Println("-------------------------")
for i := 0; i < 20; i++ {
generateNewEpoch(&plot)
}
}
func ... |
// Copyright 2018 Kuei-chun Chen. All rights reserved.
package sim
import (
"bytes"
"encoding/json"
"fmt"
"log"
"sort"
"strconv"
"strings"
"time"
"github.com/simagix/gox"
anly "github.com/simagix/keyhole/analytics"
"github.com/simagix/keyhole/mdb"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo... |
package options
import "go.mongodb.org/mongo-driver/mongo/options"
type ClientOptions struct {
*options.ClientOptions
}
|
package main
import (
"log"
"math"
"github.com/veandco/go-sdl2/sdl"
)
type GridCell struct {
Cards []*Card
}
func NewGridCell() *GridCell {
return &GridCell{
Cards: []*Card{},
}
}
func (cell *GridCell) Contains(card *Card) bool {
for _, c := range cell.Cards {
if card == c {
return true
}
}
retu... |
/*
* @lc app=leetcode.cn id=1684 lang=golang
*
* [1684] 统计一致字符串的数目
*/
// @lc code=start
package main
func countConsistentStrings(allowed string, words []string) int {
byteList := make([]bool, 26)
count := 0
for i := 0; i < len(allowed); i++ {
byteList[allowed[i]-'a'] = true
}
for _, word := range words {
... |
package parcels
import (
"context"
"encoding/gob"
"fmt"
"sort"
"spWebFront/FrontKeeper/infrastructure/core"
"spWebFront/FrontKeeper/infrastructure/log"
"spWebFront/FrontKeeper/infrastructure/workflow/thread"
"spWebFront/FrontKeeper/server/app/domain/model"
"spWebFront/FrontKeeper/server/app/domain/repository"... |
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
"../link"
)
var exampleHTML = `
<html>
<body>
<h1>Hello!</h1>
<a href="/other-page">A link to one page</a>
<a href="/second-page">A link to two page</a>
</body>
</html>`
func main() {
// Parsing the HTML of the webpage
res, err := http.Get("... |
package sphinx
import (
"encoding/binary"
"io"
)
// ReplaySet is a data structure used to efficiently record the occurrence of
// replays, identified by sequence number, when processing a Batch. Its primary
// functionality includes set construction, membership queries, and merging of
// replay sets.
type ReplaySet... |
package internal
import (
"crypto/tls"
"time"
"github.com/5xxxx/pie/driver"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/event"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/mongo/readconcern"
"go.mongodb.org/mongo-driver/mongo/readpref"
"go.mongodb.org... |
// Copyright (c) 2015-2017 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package wtxmgr
import (
"fmt"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"gi... |
package service
import (
"context"
"time"
"github.com/dgrijalva/jwt-go"
todoErr "github.com/dheerajgopi/todo-api/common/error"
"github.com/dheerajgopi/todo-api/models"
"github.com/dheerajgopi/todo-api/user"
"golang.org/x/crypto/bcrypt"
)
type userService struct {
userRepo user.Repository
}
// New returns a ... |
package logger
import (
"bytes"
encjson "encoding/json"
"fmt"
"os"
"strings"
"syscall"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stripe/unilog/filters"
"github.com/stripe/unilog/json"
)
var shakespeare = []string{
"To be, or not to be, that is the question-",
"Whether 'tis Nobler in the ... |
package configuration
import (
"fmt"
"net/http"
"strings"
"time"
)
// Endpoint representa la configuración de un endpoint para notificaciones webhook
type Endpoint struct {
Name string `yaml:"name"` // nombre del endpoint
Disabled bool `yaml:"disabled"` // desabilita el endpoint
URL... |
package main
// This file contains the implementation of a set of functions that will on a
// regular basis output information about the runner that could be useful to observers
import (
"context"
"flag"
"fmt"
"net"
"net/http"
"strconv"
"time"
"github.com/SentientTechnologies/studio-go-runner/internal/runner... |
package http
// -> username string
// <- session-token string
import (
"github.com/gin-gonic/gin"
"net/http"
)
func (s *Server) createSession(ctx *gin.Context) {
username := ctx.GetString("username")
sessToken, err := s.sessionsManager.Add(username)
if err != nil {
ctx.JSON(http.StatusInternalServerE... |
package main
import (
"fmt"
"time"
)
func main() {
var mes, dia int
natal := time.Date(2016, 12, 25, 0, 0, 0, 0, time.UTC)
for {
_, err := fmt.Scanf("%d %d", &mes, &dia)
if err != nil {
break
}
dataAtual := time.Date(2016, time.Month(mes), dia, 0, 0, 0, 0, time.UTC)
if dataAtual.After(natal) {
... |
package main
import "fmt"
func main() {
/* 创建 map */
countryCapitalMap := map[string]string{
"France": "Paris",
"Italy": "Rome",
"Japan": "Tokyo",
"India": "New Delhi",
}
fmt.Println("原始 map")
/* 打印 map */
for country := range countryCapitalMap {
fmt.Println("Capital of", country, "is", countryCa... |
package requests
import "time"
type CreateTest struct {
}
type UpdateTest struct {
}
func (c *CreateTest) Valid() error {
return validate.Struct(c)
}
func (c *UpdateTest) Valid() error {
return validate.Struct(c)
}
|
package main
import "fmt"
import "os"
import "bufio"
import "strings"
func main() {
fmt.Println("Enter a noun: ")
reader := bufio.NewReader(os.Stdin)
var noun string
noun, _ = reader.ReadString('\n')
fmt.Println("Enter a verb: ")
verb, _ := reader.ReadString('\n')
fmt.Println("Enter a adjective:: ")
adj, _... |
// DO NOT EDIT. This file was generated by "github.com/frk/gosql".
package testdata
var _FilterEmbeddedRecords_colmap = map[string]string{
"fooField.barField.value": `n."foo_bar_baz_val"`,
"fooField.bazField.value": `n."foo_baz_val"`,
"barField.value": `n."foo2_bar_baz_val"`,
"bazField.value": `... |
package gsettings
import (
"testing"
)
func TestGet(t *testing.T) {
value, err := Get("key")
if err == nil {
t.Fatal()
}
if value != "" {
t.Fatal()
}
Set("key", "value")
value, err = Get("key")
if err != nil {
t.Fatal()
}
if value != "value" {
t.Fatal()
}
}
func TestSet(t *testing.T) {
Set("key"... |
package repository
import (
"net/http"
)
// Client is the interface for actions to talk to a package repository.
// The main need is to get information about a package.
// Typical implementations are Packagist (for PHP) or PyPI (Python)
type Client interface {
// GetPackageByName returns a package by name
GetPacka... |
// package requestWebRapl
package main
import (
// "encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"time"
//"os"
// "strconv"
)
func EnergyStatCheck() string {
Url, _ := url.Parse("http://localhost:8080")
Url.Path += "/energy/stats"
parameters := url.Values{}
// parameters.Add("duration", strcon... |
package controllers
import (
"fmt"
"github.com/kdada/tinygo"
"poster/services"
"poster/utils"
)
type OrderController struct {
tinygo.Controller
}
// 订单报表信息
// userOrderNo: 用户订单号
// return
// success
// code: 0
// message: ""
// data: 订单报表信息
// failure
// code: 错误代码
// message: 错误信息
// data: ... |
package s3object
import (
"context"
"sync"
"github.com/giantswarm/certs"
"github.com/giantswarm/microerror"
"github.com/giantswarm/operatorkit/controller/context/resourcecanceledcontext"
"github.com/giantswarm/randomkeys"
"golang.org/x/sync/errgroup"
"github.com/giantswarm/aws-operator/service/controller/clu... |
/*
package azuretexttospeech provides a client for Azure's Cognitive Services (speech services) Text To Speech API. Users of the client
can specify the locale (lanaguage), text in which to speak/digitize as well as the gender in which the gender should be rendered.
For Azure pricing see https://azure.microsoft.com/en-... |
/*
Description
The basic need for a binary-to-text encoding comes from a need to communicate arbitrary binary data over preexisting communications protocols that were designed to carry only English language human-readable text.
This is why we have things like Base64 encoded email and Usenet attachments - those media ... |
package main
import "net/http"
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
}
type Routes []Route
var routes = Routes{
Route{
"Deal",
"GET",
"/api/deal",
Deal,
},
Route{
"Hit",
"GET",
"/api/hit",
Hit,
},
Route{
"Stand",
"GET",... |
// Copyright 2020 Thomas.Hoehenleitner [at] seerose.net
// Use of this source code is governed by a license that can be found in the LICENSE file.
package decoder
import (
"fmt"
"io"
"github.com/rokath/trice/internal/id"
"github.com/rokath/trice/pkg/msg"
)
// Pack2 is the Decoder instance for bare encoded trice... |
// Main package to running BagIns from the commandline.
package main
import (
"bytes"
"fmt"
"os"
"path"
"strings"
)
type TagFile struct {
Filepath string // Filepath for tag file.
Data map[string]string // key value pairs of data for the tagfile.
}
// Writes key value pairs to a tag file.
func ... |
package navmap
import (
"bytes"
"fmt"
"image"
"image/color"
"image/jpeg"
"image/png"
"io"
"log"
"net/http"
"os"
"path/filepath"
"reflect"
"strconv"
"strings"
"sync"
"time"
"github.com/hpcloud/tail"
"github.com/lmittmann/ppm"
"github.com/rs/zerolog"
"github.com/simonswine/rocklet/pkg/api"
"github... |
package app
import (
"bytes"
"compress/gzip"
"context"
"errors"
"html/template"
"io/ioutil"
"net/http"
"os"
"os/signal"
"path"
"strings"
"syscall"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/go-chi/chi"
"githu... |
package restApi
import (
"code.google.com/p/gorest"
log "code.google.com/p/log4go"
"github.com/d-d-j/ddj_master/common"
"github.com/d-d-j/ddj_master/dto"
"fmt"
"strconv"
"strings"
"sort"
)
//Select Service definition
type SelectService struct {
gorest.RestService `root:"/" consumes:"application/jso... |
package messages
import (
"encoding/json"
"github.com/nats-io/go-nats"
"log"
"os"
)
type Service struct {
connectionN *nats.Conn
}
func Create(connN *nats.Conn) *Service {
return &Service{
connectionN: connN,
}
}
func (s *Service) PushMessage(message interface{}, subject string) error {
msg, err := json.M... |
package credential
import (
"github.com/giantswarm/microerror"
"k8s.io/api/core/v1"
apismetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"github.com/giantswarm/aws-operator/service/controller/legacy/v28patch1/key"
)
const (
// awsOperatorArnKey is the key in the Secret under which th... |
package main
import (
"fmt"
"io"
"log"
"net/http"
_ "net/http/pprof"
"os"
"testing"
"time"
)
func TestBufferCache_Read(t *testing.T) {
filename := "test_file_large"
fp, e := os.Open(filename)
if e != nil {
t.Errorf("failed to open test file: %s\n", filename)
return
}
defer func(fp *os.File) { _ = fp.... |
package main
import (
"fmt"
"net/mail"
"strings"
)
// extract header info and print it nicely
func printHeaderInfo(header mail.Header) {
// this works because we know it's a single address
// otherwise use ParseAddressList
toAddress, err := mail.ParseAddress(header.Get("To"))
if err == nil {
fmt.Printf("To:... |
/*
* EVE Swagger Interface
*
* An OpenAPI for EVE Online
*
* OpenAPI spec version: 0.4.1.dev1
*
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
package swagger
// 200 ok object
type GetFleetsFleetIdWings200Ok struct {
// id integer
Id int64 `json:"id,omitempty"`
// name string
Na... |
package providers
import (
"fmt"
"os"
"strings"
"github.com/Sirupsen/logrus"
"github.com/rancher/external-dns/dns"
gandi "github.com/prasmussen/gandi-api/client"
gandiDomain "github.com/prasmussen/gandi-api/domain"
gandiZone "github.com/prasmussen/gandi-api/domain/zone"
gandiZoneVersion "github.com/prasmusse... |
package game
import (
"github.com/golang/glog"
"github.com/noxue/utils/argsUtil"
"github.com/noxue/utils/fsm"
"qipai/dao"
"qipai/enum"
"qipai/model"
"qipai/utils"
"time"
)
func StateGameOver(action fsm.ActionType, args ...interface{}) (nextState fsm.StateType) {
if action != GameOverAction {
return
}
var... |
package main
import (
"log"
"net/http"
"./db"
"./router"
)
func main() {
db.Migrate()
handler := router.NewRouter()
log.Fatal(http.ListenAndServe(":8080", handler))
}
|
// Copyright 2018 The go-bindata Authors. All rights reserved.
// Use of this source code is governed by a CC0 1.0 Universal (CC0 1.0)
// Public Domain Dedication license that can be found in the LICENSE file.
package bindata
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
)
func TestScan(t *testing.T) {
cw... |
package main
import (
"github.com/modcloth/docker-builder/parser"
"github.com/modcloth/docker-builder/version"
)
import (
"fmt"
"os"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"github.com/kelseyhightower/envconfig"
"github.com/modcloth/kamino"
"github.com/modcloth/queued-command-runner"
"git... |
package validators
import (
"reflect"
"github.com/astronomer/helm-unittest/unittest/common"
"github.com/astronomer/helm-unittest/unittest/valueutils"
)
// EqualValidator validate whether the value of Path equal to Value
type EqualValidator struct {
Path string
Value interface{}
}
func (a EqualValidator) failI... |
package controllers
import (
"encoding/json"
"github.com/w2hhda/candy/models"
"github.com/astaxie/beego"
"github.com/astaxie/beego/validation"
"sync"
)
type GameController struct {
BaseController
}
func (c *GameController) URLMapping() {
c.Mapping("GameStart", c.GameStart)
c.Mapping("GameOver", c.GameOver)
}... |
package main
import (
"fmt"
"log"
"net/http"
"strings"
)
// User struct
type User struct {
login string
password string
isLogin bool
}
var database Cache
func main() {
database = InitCache()
http.HandleFunc("/", Home)
http.HandleFunc("/logoff", LogOff)
http.HandleFunc("/login", Login)
http.HandleFun... |
package modules
import (
"fmt"
"strings"
)
// Match is...
func Match(search, keyword string, tmpStore []string) {
strList := RemoveDuplicateValues(strings.Fields(keyword))
res, err := FuzzySearch(search, strList)
if err != nil {
fmt.Println(err)
} else if res == "" {
fmt.Printf("Book not found, search inst... |
package src
import (
"bufio"
"strings"
)
// Perhaps the reporter should point to the source string rather than
// holding it in the Reporter struct...
// represents a position in code
type Position struct {
// store a copy of the current line we are processing for reporting errors
Indent uint32
Line uint32
}
... |
package rest
import (
"net/http"
)
//api定义了一个中间件的stack和app
type Api struct {
stack []Middleware
app App
}
// NewApi 实例化一个新的Api对象。 the Middleware stack is empty, and the App is nil.
func NewApi() *Api {
return &Api{
stack: []Middleware{},
app: nil,
}
}
//use方法,向栈中压入多个中间件
func (api *Api) Use(middlewares ... |
package main
import (
"net/http"
"context"
"net/http/httptest"
"github.com/best-expendables/httpclient/middleware"
log "github.com/best-expendables/logger"
"net/url"
"strings"
)
func main() {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.Statu... |
package pgsql
import (
"github.com/go-pg/pg/v9"
"github.com/go-pg/pg/v9/orm"
"github.com/jpurdie/authapi"
"log"
"time"
)
type Invitation struct{
}
func (i Invitation) Create(db orm.DB, invite authapi.Invitation) error {
op := "Create"
_, trErr := db.Model(&invite).Returning("*").Insert()
if trErr != nil {
... |
package stack
const INIT_CAP = 10
// const INCRE_MENT = 5
type Elem int
type Stack struct {
top int
data [INIT_CAP]Elem
}
// InitStack 创建一个空栈
func InitStack(s *Stack) {
s.top = 0
}
// Push 增加一个栈元素
func Push(s *Stack, e Elem) bool {
if s.top > INIT_CAP {
return false
}
s.data[s.top] = e
s.top++
return t... |
package main
import (
"fmt"
)
func main() {
interpreterStringLiteral := "Olá, galerinha do Youtube!\nTudo bom com vocês??"
rawStringLiteral := `Essa é uma string crua
\n\n\n\t\t\t\t\t\t\n\n\n\n\n\n
Consigo fazer uma zona aqui.
`
fmt.Println(interpreterStringLiteral)
fmt.Println(rawStringLiteral... |
package gofifo_test
import (
"reflect"
"testing"
"time"
"github.com/dwburke/gofifo"
)
type Fuu struct {
Name string
Time time.Time
}
func TestSetRoom(t *testing.T) {
fifo, err := gofifo.NewFifo("test")
expect(t, err, nil, "")
defer fifo.Close()
fifo.Register(Fuu{})
rec := &Fuu{
Name: "foo",
Time: t... |
package handlers
import (
"database/sql"
"fmt"
"net/http"
"net/url"
"strings"
"github.com/google/uuid"
"github.com/ory/fosite"
"github.com/authelia/authelia/v4/internal/middlewares"
"github.com/authelia/authelia/v4/internal/model"
"github.com/authelia/authelia/v4/internal/oidc"
"github.com/authelia/authel... |
package bitcoin
import (
"testing"
)
func TestWallet(t *testing.T) {
assertBalanceEqual := func(t *testing.T, wallet Wallet, expected Bitcoin) {
t.Helper()
actual := wallet.Balance()
if expected != actual {
t.Errorf("Actual balance was %s but got %s", actual, expected)
}
}
assertError := func(t *tes... |
package main
import "net/http"
type apiServer struct {
// db *someDatabase
// router *httprouter.Router
router *http.ServeMux
}
|
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
type name struct {
fname string
lname string
}
func main() {
fmt.Print("Hello please write the name of a file:")
var filename string
fmt.Scan(&filename)
names := make([]name, 0)
file, _ := os.Open(filename)
scanner := bufio.NewScanner(file)
for... |
package websocket
import (
"KServer/library/kiface/iwebsocket"
"KServer/library/websocket/utils"
"fmt"
"github.com/gorilla/websocket"
"log"
"net/http"
"strconv"
)
//iServer 接口实现,定义一个Server服务类
type Server struct {
//服务器的名称
Name string
//服务器协议 ws,wss
Scheme string
//服务绑定的IP地址
IP string
//服务绑定的端口
Port int... |
// +build wasm
package main
import (
"github.com/maxence-charriere/go-app/v7/pkg/app"
)
func main() {
for path, new := range pages() {
app.Route("/"+path, new())
}
app.Run()
}
|
package main
import (
"fmt"
)
func main() {
number := -10
switch {
case number < 0:
fmt.Printf("%d %s\n", number, "is negative")
case number%2 == 0:
fmt.Printf("%d %s\n", number, "is even")
case number%2 != 0:
fmt.Printf("%d %s\n", number, "is odd")
}
}
|
package models
import (
"github.com/google/uuid"
"github.com/mixnote/mixnote-api-go/src/music/model"
"gorm.io/gorm"
"time"
)
type (
User struct {
ID uuid.UUID `sql:"primary_key;type:uuid;default:uuid_generate_v4()" json:"id"`
FirstName string `gorm:"type:varchar(50)" json:"first_name"... |
/*
Go Language Raspberry Pi Interface
(c) Copyright David Thorpe 2016-2017
All Rights Reserved
Documentation http://djthorpe.github.io/gopi/
For Licensing and Usage information, please see LICENSE.md
*/
package ener314rt
import (
"context"
"encoding/hex"
"fmt"
"strings"
"sync"
"time"
// Frameworks
"... |
// Copyright 2019 Kuei-chun Chen. All rights reserved.
package atlas
import (
"encoding/json"
"errors"
"fmt"
"github.com/simagix/gox"
)
// Project stores project info
type Project struct {
ID string
Name string
OrgID string
}
// GetGroups get processes of a user
func (api *API) GetGroups() (map[string]i... |
package main
import "fmt"
type human interface {
Name() string
Age() int64
}
type student struct {
name string
age int64
}
func (s student) Name() string {
return s.name
}
func (s student) Age() int64 {
return s.age
}
func main() {
var h human = student{name: "xiaoming", age: 18}
fmt.Printf("Interface im... |
package api
const (
DefaultFlavor = "ubuntu/bionic64"
DefaultWorkspace = "/tmp"
DefaultUsbBoot = true
DefaultReuse = false
DefaultTimeZone = "America/Toronto"
DefaultUsername = "imulab"
DefaultDomain = "home.local"
DefaultNetMask = "255.255.255.0"
DefaultNameServers = "8.8.8.8"... |
package messaging
import (
"bytes"
"testing"
)
type SerialiseStringResult struct {
s string
b []byte
expected bool
}
var serialiseStringResults = []SerialiseStringResult{
{"foobar", []byte{34, 102, 111, 111, 98, 97, 114, 34}, true},
{"", []byte{34, 34}, true},
}
func TestSerialiseString(t *test... |
package domain
type Status string
const (
StatusDeploying = "Deploying"
StatusUpdating = "Updating"
StatusDeleting = "Deleting"
StatusDeploymentError = "DeploymentError"
)
|
// Copyright 2019-present 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 agr... |
/*
Copyright 2022 The KubeVela 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 in writing, so... |
package logic
import (
"basic_blog_go/japerk"
"basic_blog_go/utils"
"fmt"
"net/http"
"strings"
"github.com/dghubble/go-twitter/twitter"
"github.com/dghubble/oauth1"
)
// TrendLogic defines a struct that will be associated to all operations
// related to Twitter trending topics
type TrendLogic struct {
DB ... |
package main
import "fmt"
func main() {
a := 1
p := &a
fmt.Println(a)
fmt.Println(p)
} |
package main
import (
"encoding/hex"
"errors"
"time"
"github.com/fiatjaf/go-lnurl"
"github.com/fiatjaf/lightningd-gjson-rpc/plugin"
)
var InvoiceWithDescriptionHashMethod = plugin.RPCMethod{
"invoicewithdescriptionhash",
"msatoshi label description_hash [expiry] [preimage]",
"Create an invoice for {msatoshi}... |
package validation
import (
"regexp"
"k8s.io/apimachinery/pkg/util/validation/field"
"github.com/openshift/installer/pkg/types/azure"
)
var (
// RxDiskEncryptionSetID is a regular expression that validates a disk encryption set ID.
RxDiskEncryptionSetID = regexp.MustCompile(`(?i)^/subscriptions/([0-9a-fA-F]{8}... |
package pr
import (
"github.com/abhinav/git-pr/gateway"
"github.com/abhinav/git-pr/service"
)
// ServiceConfig specifies the different parameters for a PR service.
type ServiceConfig struct {
GitHub gateway.GitHub
Git gateway.Git
}
// Service is a PR service.
type Service struct {
gh gateway.GitHub
git gat... |
package websocket
import (
"errors"
)
// Signals that the asynchronous conn.Read timed out
var receiveTimedOut = errors.New(
"websocket: Timed out waiting for the first few bytes of a message")
// Signals that the connection to the end-point was closed.
var connectionClosed = errors.New("websocket: Connection... |
package persistence
import (
"context"
"database/sql"
"fmt"
"time"
"github.com/dollarshaveclub/acyl/pkg/models"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
)
// Cleaner is an object that performs data model clean up operations
type Cleaner struct {
// DB must be an initialized SQL client
DB *sqlx.DB
... |
package handler
import (
"net/http"
"github.com/gitbufenshuo/relation/content"
"strconv"
"github.com/labstack/echo"
)
// /relation/add/:self/:up
func AddHandler(c echo.Context) error {
var self uint64
var up uint64
{
ss := c.Param("self")
if n, err := strconv.ParseUint(ss, 10, 64); err != nil {
retur... |
package x
// GENERATED BY XO. DO NOT EDIT.
import (
"errors"
"strings"
//"time"
"ms/sun/shared/helper"
"strconv"
"github.com/jmoiron/sqlx"
)
// (shortname .TableNameGo "err" "res" "sqlstr" "db" "XOLog") -}}//(schema .Schema .Table.TableName) -}}// .TableNameGo}}// PostPromoted represents a row from 'sun.post_p... |
/*
Write the shortest program that prints, in order, a complete list of iPhone iterations, according to this site:
iPhone
iPhone 3G
iPhone 3GS
iPhone 4
iPhone 4S
iPhone 5
iPhone 5c
iPhone 5s
iPhone 6
iPhone 6 Plus
iPhone 6s
iPhone 6s Plus
iPhone SE
iPhone 7
iPhone 7 Plus
iPhone 8
iPhone 8 Plus
iPhone X
iPhone XR
iPho... |
package main
import (
"bufio"
"encoding/json"
"fmt"
"log"
"math/rand"
"net"
"os"
"strconv"
"strings"
"github.com/JuanLeycal/TF_Concurrente/hotPotato/kmeans"
)
var bitacora []string //Ips de los nodos de la red
const (
puerto_registro = 8000
puerto_notifica = 8001
puerto_procesoHP = 8002
)
var direcci... |
package model
// 列表返回
type ReturnListData struct {
Items interface{} `json:"items"`
Pages interface{} `json:"pages"`
}
// 详情返回
type ReturnData struct {
Item interface{} `json:"item"`
Expand interface{} `json:"expand"`
}
// 错误信息
type ErrMessage struct {
Message string `json:"message"`
}
var ParamErr = &ErrM... |
package i18n
const ON = true
const OFF = false
|
package util
import (
"crypto/md5"
"crypto/sha256"
"errors"
"fmt"
"github.com/satori/go.uuid"
"strings"
)
// GetGUID 生成GUID
func GetGUID() (valueGUID string) {
objID, _ := uuid.NewV4()
objidStr := objID.String()
objidStr = strings.Replace(objidStr, "-", "", -1)
valueGUID = objidStr
return valueGUID
}
// s... |
package jsonproto
// NewRouter
func NewRouter(routes Routes) *ServeMux {
router := NewServeMux()
for _, route := range routes {
router.HandleFunc(route.Method, route.HandlerFunc)
}
return router
}
// Register and int path route to an existing router
func RegisterIntRoute(router *ServeMux, route IntRoute) {
rou... |
package keyValueData
type IKeyValueDatabase interface {
FindByKey(table string, key string) interface{}
Create(table string, model interface{}) interface{}
Delete()
}
|
package command
import "github.com/satori/go.uuid"
type AddSprint struct {
ID uuid.UUID `json:"id" example:"550e8400-e29b-41d4-a716-446655440000" format:"uuid"`
Name string `json:"name" example:"sprint name"`
}
|
package main
import (
"fmt"
)
func main() {
floatStruct := []float64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
fmt.Println("Sum:", sum(floatStruct...))
fmt.Println("Divide:", divideSum(sum, floatStruct...))
fmt.Println("Product:", divideProd(sum, floatStruct...))
}
func sum(x ...float64) float64 {
sum := 0.0
for _, v :=... |
package main
import "github.com/hegedustibor/htgo-tts"
import "dict"
func main() {
dict.Initi("/home/wurst/go/src/dict/syllables")
speech := htgotts.Speech{Folder: "audio", Language: "en"}
set:=dict.SetOfKeys()
for key:=0;key<len(set);key++{
speech.Speak(set[key])
}
} |
// DRUNKWATER TEMPLATE(add description and prototypes)
// Question Title and Description on leetcode.com
// Function Declaration and Function Prototypes on leetcode.com
//522. Longest Uncommon Subsequence II
//Given a list of strings, you need to find the longest uncommon subsequence among them. The longest uncommon su... |
package cli
import (
"fmt"
"github.com/irisnet/irishub/app/protocol"
"github.com/irisnet/irishub/app/v1/distribution"
"github.com/irisnet/irishub/client/context"
"github.com/irisnet/irishub/codec"
sdk "github.com/irisnet/irishub/types"
"github.com/spf13/cobra"
)
// GetWithdrawAddress returns withdraw address ... |
// 常量
package hello
import "fmt"
func test5() {
const a = 1
fmt.Println(a)
const (
b, c = 10, 20
d = false
)
fmt.Println(b, c, d)
}
|
// Package robustly provides code to handle (and create) infrequent panics.
package robustly
// Copyright (c) 2013 VividCortex, Inc. All rights reserved.
// Please see the LICENSE file for applicable license terms.
import (
"fmt"
"github.com/VividCortex/ewma"
"os"
"runtime/debug"
"time"
)
// Run runs the given ... |
package sketchy
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
/*
This is just an example to demonstrate a "sketchy" third-party handler module,
to demonstrate the "object capability" model for security.
Since nothing is passed in via arguments to the NewHandler constructor,
it cannot affect the handling of ot... |
package frac
// Add sums two fractions.
func Add(frac1 Frac, frac2 Frac) Frac {
// Adjust fractions to common denominator.
num := frac1.Num*frac2.Den + frac1.Den*frac2.Num
den := frac1.Den * frac2.Den
// Yield result.
return Frac{num, den}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.