text stringlengths 11 4.05M |
|---|
// Copyright 2022 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... |
package main
// Character with a name, description you can fight and talk to.
type Character struct {
name string
description string
conversation Action
battle Action
}
// Name the character.
func (char *Character) Name() string {
return char.name
}
// Describe the look of the character.
func (ch... |
package virtualnode
import (
"context"
appmesh "github.com/aws/aws-app-mesh-controller-for-k8s/apis/appmesh/v1beta2"
"github.com/aws/aws-app-mesh-controller-for-k8s/pkg/equality"
"github.com/aws/aws-app-mesh-controller-for-k8s/pkg/k8s"
"github.com/aws/aws-sdk-go/aws"
appmeshsdk "github.com/aws/aws-sdk-go/service... |
package school
import (
"sort"
)
type School struct {
grades map[int][]string
}
type Grade struct {
grade int
students []string
}
func New() *School {
return &School{grades: map[int][]string{}}
}
func (school *School) Enrollment() []Grade {
return school.sortedListOfGrades()
}
func (school *School) sortedLi... |
package controller
import (
"encoding/json"
"fmt"
"github.com/AnaMijailovic/NTP/arf/model"
"github.com/AnaMijailovic/NTP/arf/service"
"net/http"
"strconv"
"time"
)
func Serve() {
http.HandleFunc("/api/fileTree", GetFileTree)
http.HandleFunc("/api/chartData", GetChartData)
http.HandleFunc("/api/delete", Del... |
package api
type GetDimensionsResponse struct {
Dimensions []string `json:"dimensions,omitempty"`
}
type DimensionResponse struct {
Index int `json:"index"`
Name string `json:"name"`
Code string `json:"code"`
} |
package literals
//http://unicode-table.com
var (
SYMBOL_GRASS_BLANK string = " "
SYMBOL_GRASS_LIGHT string = string([]byte{226, 150, 145})
SYMBOL_GRASS_MEDIUM string = string([]byte{226, 150, 146})
SYMBOL_GRASS_DARK string = string([]byte{226, 150, 147})
SYMBOL_POINT string = string([]byte{226, 173, 1... |
// 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... |
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
)
/*
This application uses some of the previous concepts to calculate the size of a directory or a bunch of directories
given as input.
*/
func main() {
var verbose = flag.Bool("v", false, "show verbose progress messages")
var start,... |
package index
import (
"errors"
"fmt"
"github.com/MintegralTech/juno/datastruct"
"github.com/MintegralTech/juno/debug"
"github.com/MintegralTech/juno/document"
"github.com/MintegralTech/juno/helpers"
"github.com/MintegralTech/juno/log"
"github.com/easierway/concurrent_map"
"github.com/sirupsen/logrus"
"strco... |
package day18
import (
"fmt"
"strconv"
"strings"
"text/scanner"
)
func Run(lines []string) error {
sum, err := SumAll(lines, EqualPrecedence)
if err != nil {
return err
}
fmt.Println("Part 1:", sum)
sum, err = SumAll(lines, AdvancedPrecedence)
if err != nil {
return err
}
fmt.Println("Part 2:", sum)
... |
package main
import (
"fmt"
. "github.com/little-go/learn-go/structure"
"unicode/utf8"
)
func main() {
A1()
M1()
fmt.Println(LengthOfNonRepeatingSubStr("abcasbcs"))
fmt.Println(LengthOfNonRepeatingSubStr("你好呀"))
fmt.Println("Rune count:", utf8.RuneCountInString("s"))
bytes := []byte("water")
for len(bytes) ... |
package peach
import (
"fmt"
"testing"
"github.com/zdao-pro/sky_blue/pkg/peach"
)
type jsonData struct {
A string `json:"a"`
B int `json:"b"`
}
func TestString(t *testing.T) {
// peach.Init(peach.PeachDriverApollo, "zdao_backend.sky_blue")
a, _ := peach.Get("db_ms_wallet.yaml").String()
fmt.Println(a)
}
... |
package valueobject
// ValueObject interface must be implemented by any aggregate value object to verify structural equality between two value objects
type ValueObject interface {
Equals(other ValueObject) bool
}
|
package subscriber
import (
"context"
"fmt"
"github.com/Whisker17/goMicroDemo/proto/model"
)
func Handler(ctx context.Context, msg *model.SayParam) error {
fmt.Printf("Received message: %s \n", msg.Msg)
return nil
} |
package requests
type BaseRequest struct {
Action string `json:"action" mapstructure:"action"`
}
|
package 一维数组
import "fmt"
// --------------------------------------------------- 1. 动态规划(开始) ---------------------------------------------------
// trap 接雨水。
// 动态规划解法: 计算所有水柱高度的总和。 (垂直)
// 水柱高度: 向左最大高度、向右最大高度的最小值 - 当前位置的高度。
func trap(heights []int) int {
// 1. 构建当前点向左的最大值映射。
maxHeightToLeft := make([]int, len(hei... |
package db
import (
_ "github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
)
func ConnectGORM() *gorm.DB {
DBMS := "mysql"
USER := "root"
PASS := "password"
PROTOCOL := "tcp([mysql]:3306)"
DBNAME := "video"
CONNECT := USER + ":" + PASS + "@" + PROTOCOL + "/" + DBNAME + "?parseTime=true&loc=Asia%2FTokyo"... |
/*
Copyright 2015 The Kubernetes 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, ... |
package library
import (
"fmt"
devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
"io/ioutil"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"os"
"sigs.k8s.io/controller-runtime"
"strings"
"sigs.k8s.io/... |
package goxtremio
import xms "github.com/emccode/goxtremio/api/v3"
type InitiatorGroupFolder *xms.IGFolder
// GetIGFolder returns a specific initiator by name or ID
func (c *Client) GetIGFolder(id string, name string) (InitiatorGroupFolder, error) {
igf, err := c.api.GetIGFolder(id, name)
if err != nil {
return ... |
package shardkv
// Field names must start with capital letters,
// otherwise RPC will break.
//
// additional state to include in arguments to PutAppend RPC.
//
type PutAppendArgsImpl struct {
RequestID int64
}
//
// additional state to include in arguments to Get RPC.
//
type GetArgsImpl struct {
}
//
// for new ... |
package actions
import (
"path/filepath"
"testing"
"github.com/gobuffalo/suite"
"github.com/gomods/athens/pkg/config"
)
var (
testConfigFile = filepath.Join("..", "..", "..", "config.dev.toml")
)
type ActionSuite struct {
*suite.Action
}
func Test_ActionSuite(t *testing.T) {
conf, err := config.GetConf(test... |
package stack
type Stack struct {
arr []interface{}
}
func NewStack() *Stack {
return &Stack{
arr: make([]interface{}, 0),
}
}
func (stack *Stack) Push(data interface{}) {
stack.arr = append(stack.arr, data)
}
func (stack *Stack) Pop() interface{} {
if len(stack.arr) == 0 {
return ""
}
data := stack.arr[... |
// Kubeaware is built in order to bring order
// for those applications who don't have cloud native support out of the box.
// This becomes important once companies start porting their legacy systems
// onto platforms like Kubernetes
package main
|
package utils
import (
"golang.org/x/crypto/bcrypt"
)
// HashPassword hashes the provided password.
// The hashing uses bcrypt with a default cost of 10.
func HashPassword(password string) string {
// Hashing the password with the default cost of 10
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(passwor... |
package planets
import "errors"
var (
ErrPlanetNotAdded = errors.New("could not save the planet")
ErrPlanetsNotFound = errors.New("planets not found")
ErrPlanetNotFound = errors.New("planet not found")
ErrPlanetNotRemoved = errors.New("could not delete the planet")
ErrPlanetAlrea... |
package bmmongo
import (
"github.com/alfredyang1986/blackmirror/bmmodel/request"
)
type BMMongo interface {
InsertBMObject() error
UpdateBMObject(request.Request) error
FindOne(request.Request) error
}
type BMMongoMulti interface {
FindMulti(req request.Request) error
}
type BmMongoCover interface {
CoverBMOb... |
/*
Copyright IBM Corp. 2016 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 law or agreed to in wri... |
/*
Create a function that takes a sentence and turns every "i" into "wi" and "e" into "we", and add "owo" at the end.
Notes
Don't forget to return the value!
There's a space in front of owo!
uwu
*/
package main
import (
"bytes"
"fmt"
)
func main() {
fmt.Println(owofied("I'm gonna ride 'til I can't no mo... |
package solver
import "github.com/truggeri/go-sudoku/cmd/go-sudoku/puzzle"
type solveTechnique struct {
set func(int, int) puzzle.Set
index func(int, int) int
}
type solution struct {
x, y int
square puzzle.Square
}
// Solve Returns the given puzzle with all elements solved
func Solve(puz puzzle.Puzzle) puz... |
/*
GoLang code created by Jirawat Harnsiriwatanakit https://github.com/kazekim
*/
package kbank
import (
"fmt"
"github.com/kazekim/thaibankclient-go/thcerror"
)
type testSSLError struct {
StatusCode string
ErrorMsg *string
}
func NewTestSSLError(code, errorMsg *string) thcerror.Error {
return &testSSLError{
... |
package format
import (
"github.com/plandem/xlsx/internal/ml/primitives"
)
//List of all possible values for FontFamilyType
const (
_ primitives.FontFamilyType = iota
FontFamilyRoman
FontFamilySwiss
FontFamilyModern
FontFamilyScript
FontFamilyDecorative
)
|
package main
import "fmt"
func test(f func()) {
if f != nil {
f()
}
}
func main() {
test(func() { fmt.Println("hoge") })
test(nil)
}
|
// 고루틴(GoRoutine)
/*
//고루틴(Goroutine)은 함수를 동시에 실행시키는 기능입니다.
//다른 언어의 스레드 생성 방법보다 문법이 간단하고,
//스레드보다 운영체제의 리소스를 적게 사용하므로 많은 수의 고루틴을 쉽게 생성할 수 있습니다.
//'go 함수명'
package main
import (
"fmt"
"math/rand"
"time"
)
//(TIP)
//시간표현
const (
Nanosecond Duration = 1
Microsecond = 1000 * Nanosecond
Millisecond ... |
package planets
import (
"log"
"net/http"
"github.com/flaviogf/star_wars_backend/internal/planets"
"github.com/gorilla/mux"
)
func RemovePlanetHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
handler := planets.NewRemovePlanetHandler(MongoRepository{})
err := handler.Execute(r.Context()... |
package client
import (
"io/ioutil"
"net/http"
"sync"
"time"
)
type HttpClient interface {
GET(url string) ([]byte, error)
}
var once sync.Once
var defaultHttp defaultHttpClient
type defaultHttpClient struct {
client http.Client
}
func NewDefaultHttpClient() HttpClient {
once.Do(func() {
defaultHttp = def... |
// Command json2csv converts JSON to CSV.
//
// For example, the following JSON input:
//
// [
// {"key1": a, "key2": b},
// {"key1": x, "key2": y}
// ]
//
// is converted to the following CSV:
//
// key1 key2
// a b
// x y
//
// The input must be a JSON list of objects, with each object having the
// same set (or ... |
package spacesaving
type StreamManager interface {
Offer(item string, increment int)
Top() []Result
Name() string
}
|
/*
Copyright 2021. 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... |
package main
import (
"os"
"fmt"
"flag"
"os/signal"
"sync"
"github.com/infrawatch/lokean/pkg/logs"
"github.com/infrawatch/apputils/connector"
"github.com/infrawatch/apputils/logging"
"github.com/infrawatch/apputils/config"
)
func printUsage() {
fmt.Fprintln(os.Stderr, `Required command line argument missi... |
//-----------------------------------------------Paquetes E Imports-----------------------------------------------------
package AnalisisYComandos
import (
"../Metodos"
"../Variables"
"bytes"
"fmt"
"github.com/gookit/color"
"path/filepath"
"strconv"
"strings"
)
//---------------------------------... |
package appdynamics
import (
"errors"
"fmt"
"github.com/HarryEMartland/terraform-provider-appdynamics/appdynamics/client"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/stret... |
package timestamp
import "encoding/asn1"
// Status contains the PKI status code.
type PKIStatus int
const (
PKIStatusGranted PKIStatus = iota
PKIStatusGrantedWithMods
PKIStatusRejection
PKIStatusWaiting
PKIStatusRevocationWarning
PKIStatusRevocationNotification
)
// PKIFailureInfo contains err... |
package service
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/mux"
"time"
)
func MiddleHandler(inner http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
a := vars["username"]
fmt.Println("username:", a)
log.Println("middleware 1",... |
package main
import (
"io"
"io/ioutil"
"os"
"strings"
"testing"
)
func TestStartWithNoConfigs(t *testing.T) {
code := Start("test")
if code == 0 {
t.Fatalf("expected program to exit with non-zero, but got %d", code)
}
}
func TestStartWithWrongPath(t *testing.T) {
code := Start("test", "this-is-definitely-... |
package tumblr
import (
"github.com/mrjones/oauth"
"net/http"
)
const (
requestTokenURL = "http://www.tumblr.com/oauth/request_token"
authorizeTokenURL = "http://www.tumblr.com/oauth/authorize"
accessTokenURL = "http://www.tumblr.com/oauth/access_token"
)
// Client is tumblr api client
type Client struct {... |
package service
import (
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/go-xorm/xorm"
)
var MysqlService = new(MysqlPool)
type MysqlPool struct {
DBMysql *xorm.Engine
}
func (M *MysqlPool) InitMysqlPool(config map[string]map[string]string) (err error) {
host := "tcp(" + config["mysql"]["host"] + ":" + co... |
package assembler
import (
"bufio"
"github.com/bonjourmalware/melody/internal/engine"
"github.com/bonjourmalware/melody/internal/events"
"github.com/google/gopacket"
"github.com/google/gopacket/tcpassembly"
"github.com/google/gopacket/tcpassembly/tcpreader"
"io"
"net/http"
)
// HTTPStreamFactory implements tc... |
package main
/**
* Definition for a Node.
* type Node struct {
* Val int
* Children []*Node
* }
*/
type Node struct {
Val int
Children []*Node
}
// 栈-前序遍历
func preorder(root *Node) []int {
var res []int
if root == nil {
return res
}
stack := []*Node{root}
var popNode *Node
for len(stack)... |
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
)
// FetchAWSData represents the set of methods used to interact with AWS ... |
// Copyright 2017 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... |
package middleware
import (
"bytes"
"net/http"
"testing"
"github.com/root-gg/utils"
"github.com/stretchr/testify/require"
"github.com/root-gg/plik/server/common"
"github.com/root-gg/plik/server/context"
)
func TestPaginateDefault(t *testing.T) {
ctx := newTestingContext(common.NewConfiguration())
req, err... |
package main
import "fmt"
// it has a fixed size
// all elm must be of same type
func main() {
var num [5]int
num[0] = 10
num[4] = 20
fmt.Printf("%#v", num)
}
|
/*
* @lc app=leetcode.cn id=1 lang=golang
*
* [1] 两数之和
*/
package solution
// @lc code=start
func twoSum(nums []int, target int) []int {
m := make(map[int]int)
for i := 0; i < len(nums); i++ {
rest := target - nums[i]
if _, ok := m[rest]; ok {
return []int{m[rest], i}
}
m[nums[i]] = i
}
return nil
... |
package main
import (
"fmt"
"github.com/liuzl/unidecode"
)
func main() {
fmt.Println("vim-go")
fmt.Println(unidecode.Unidecode(`乾隆爷的乾儿子是谁?`))
fmt.Println(unidecode.Unidecode("multiply by?"))
}
|
package cosmos
import "testing"
func getDummyClient() *Client {
client, _ := New("AccountEndpoint=https://cosmos-url;AccountKey=abc")
return client
}
func TestEmptyConnString(t *testing.T) {
_, err := New("")
if err == nil {
t.Fatal("error should not be nil")
}
}
|
// Copyright 2023 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... |
package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kms"
)
//encryptFile takes in a file path and returns the KMS encrypted data
func encryptFile(targetFile *string, kmsID *strin... |
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
func main() {
file, err := os.Open("Day2/in2.txt")
if err != nil {
log.Fatal(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
scanner.Scan()
s := strings.Split(scanner.Text... |
////////////////////////////////////////////////////////////////////////////////
// //
// Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or //
// its subsidiaries. ... |
package vac
import (
"bytes"
"errors"
"fmt"
"io"
"sort"
"strings"
"time"
venti "sigint.ca/venti2"
)
const (
// TODO: use the fossil magic (+1)? and reverse botch logic
MetaMagic = 0x5656fc79
MetaHeaderSize = 12
MetaIndexSize = 4
IndexEntrySize = 8
)
const (
BytesPerEntry = 100 // estimate of b... |
// Copyright 2015 Google Inc. 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... |
package main
import (
"fmt"
"math"
)
func main() {
a := 0
b := 1
fmt.Println(divide(a, b))
a = -2147483648
b = 2
fmt.Println(divide(a, b))
fmt.Print(2 >> 1)
fmt.Print(2 << 0)
fmt.Print(2 << 1)
}
func divide(dividend int, divisor int) int {
sign := 1
if dividend < 0 {
dividend = -dividend
sign = -sig... |
// Package lifecycle contains life cycle utilities for autonomous components.
//
// The definitions in this package complement the tomb package.
package lifecycle
import (
"context"
"errors"
)
// Error variables related to AutonmousComponent.
var (
ErrStopSignalled = errors.New("stop signalled")
)
type Autonomous... |
package errors_test
import (
"fmt"
"io"
"syscall"
"testing"
"github.com/kazhuravlev/options-gen/pkg/errors"
"github.com/stretchr/testify/assert"
)
func TestValidationErrors(t *testing.T) {
t.Parallel()
errs := new(errors.ValidationErrors)
assert.NoError(t, errs.AsError())
assert.Equal(t, "", errs.Error()... |
package model
import (
"errors"
"fmt"
"io"
"math/big"
"strconv"
"time"
"github.com/99designs/gqlgen/graphql"
)
type Statistics struct {
ID string `json:"id"`
CoinID uint64 `json:"coinId"`
UserID uint64 `json:"userId"`
WorkerID string `json:"workerId"`
DateTim... |
package main
import (
"log"
"net/http"
_ "github.com/GiG/go-swagger-ui/statik"
"github.com/rakyll/statik/fs"
)
func main() {
statikFS, err := fs.New()
if err != nil {
panic(err)
}
http.Handle("/swagger/", http.StripPrefix("/swagger/", http.FileServer(statikFS)))
log.Println("Listening on localhost:8000"... |
package gorm
import (
"fmt"
"testing"
"time"
"github.com/Jetereting/gorm"
_ "github.com/go-sql-driver/mysql"
)
var (
db *gorm.DB
err error
)
func init() {
db, err = gorm.Open("mysql", "user:password@tcp(ip:port)/dbName?charset=utf8")
if err != nil {
fmt.Println(err)
return
}
db.DB().SetMaxOpenConns(... |
package controller
import (
"fmt"
"io/ioutil"
"net/url"
"os"
"path/filepath"
"strings"
"github.com/Sirupsen/logrus"
"github.com/andygrunwald/perseus/config"
"github.com/andygrunwald/perseus/dependency"
"github.com/andygrunwald/perseus/dependency/repository"
"github.com/andygrunwald/perseus/downloader"
)
/... |
// Magic 8 ball
package main
import (
"bufio"
"fmt"
"math/rand"
"os"
"time"
)
var RESPONSES = []string{
"No",
"Yes",
"Maybe",
"Ask again later",
}
func randomInt(low, high int) int {
rand.Seed(time.Now().UnixNano())
return rand.Intn(high-low) + low
}
func main() {
fmt.Print("What is your question? "... |
package glman
// Model interface for 3D model object
type Model interface {
Render()
}
|
package tameshigiri
import "fmt"
import "runtime"
import "testing"
// Static reference number of the processed assertions
var NumberOfProcessedAssertion uint = 0
// Assertion class
//
// When the assertion fails, assuming that the given result is unexpected, the
// most recent call stacks (up to the size of 2KB) wil... |
package main
import "fmt"
func main() {
var s []int
for i := 1; i <= 3; i++ {
s = append(s, i)
}
fmt.Println(cap(s))
reverse5(s)
fmt.Println(s)
}
func reverse2(s []int) {
s = append(s, 999, 1000, 1001)
for i, j := 0, len(s)-1; i < j; i++ {
j = len(s) - (i + 1)
s[i], s[j] = s[j], s[i]
}
}
func reverse5... |
package namecheap
import (
"encoding/xml"
"fmt"
)
type DomainsResponse struct {
XMLName xml.Name `xml:"ApiResponse"`
Errors []struct {
Message string `xml:",chardata"`
Number string `xml:"Number,attr"`
} `xml:"Errors>Error"`
CommandResponse struct {
Domains []Domain `xml:"DomainGetListResult>Domain"`
}... |
package targets
import (
"fmt"
"os"
"../effects"
"../utils"
)
import . "../defs"
func (cg *CodeGeneratorWla) OutputCallbacks(outFile *os.File) int {
callbacksSize := 0
outFile.WriteString("xpmp_callback_tbl:\n")
for _, cb := range cg.itarget.GetCompilerItf().GetCallbacks... |
package main
import (
"context"
"fmt"
_ "github.com/denisenkom/go-mssqldb"
)
//GetState get a state by it's StateId
func GetState(stateId int) (*State, error) {
ctx := context.Background()
// Check if database is alive.
err := db.PingContext(ctx)
if err != nil {
return nil, err
}
tsql := fmt.Sprintf(`S... |
package caaa
import (
"encoding/xml"
"github.com/thought-machine/finance-messaging/iso20022"
)
type Document01100104 struct {
XMLName xml.Name `xml:"urn:iso:std:iso:20022:tech:xsd:caaa.011.001.04 Document"`
Message *AcceptorBatchTransferV04 `xml:"AccptrBtchTrf"`
}
func (d *Document01100104) Add... |
package inmemory
import (
"errors"
"sync"
"time"
"github.com/Tinee/go-graphql-chat/domain"
)
var (
ErrProfileNotFound = errors.New("profile not found in memory")
)
type profileInMemory struct {
mtx *sync.Mutex
profiles []domain.Profile
}
func (m *profileInMemory) Create(p domain.Profile) (domain.Profil... |
package main
import (
"newfeed/flatform/newfeed"
"newfeed/httpd/handler"
"github.com/gin-gonic/gin"
)
func main() {
feed := newfeed.New()
r := gin.Default()
r.GET("/ping", handler.PingGet())
r.GET("/get_feeds", handler.NewFeedGet(feed))
r.POST("/new_feeds", handler.NewFeedPost(feed))
r.Run(":3000")
}
|
package main
func arithmeticSum(n int, a1 int, increment int) int {
return (2*a1 + (n-1)*increment) * n / 2
}
func getDivisors(n int) []int {
divisors := make(map[int]int)
divisors[1] = n
factors := make([]int, 0)
if n > 1 {
factors = append(factors, 1)
factors = append(factors, n)
for i := 2; i < n/2; i... |
//
// Copyright (c) Telefonica I+D. All rights reserved.
//
package svc
import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/http/httputil"
"os"
"strings"
"sync"
"time"
)
type level int
const (
debugLevel level = iota
infoLevel
warnLevel
errorLevel
fatalLevel
)
var levelNames = []strin... |
/*
* 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 rest
import (
"fmt"
"time"
"github.com/jinmukeji/jiujiantang-services/pkg/rest"
analysispb "github.com/jinmukeji/proto/v3/gen/micro/idl/partner/xima/analysis/v1"
"github.com/kataras/iris/v12"
)
// GetWeeklyReportBody 请求周报的body
type GetWeeklyReportBody struct {
Language Language `json:"language"`
}
// ... |
package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
"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/guregu/dynamo"
)
const workers = 80
func main() {
db := dynamo.New(session.New(), &aws.Config{
Region: ... |
package db
import (
"database/sql"
"errors"
_ "github.com/mattn/go-sqlite3"
)
// DB wraps a sqlite DB with specific calls for wish list.
type DB struct {
db *sql.DB
}
// WishListRow is a json annotated representation of the db schema.
type WishListRow struct {
UserId int `json:"userId"`
BookTitle string ... |
package _1
import (
"bufio"
"os"
"strconv"
)
func PartOne(numbers []int, setNumbers []int) int {
for n := range numbers {
for sn := range setNumbers {
if n == setNumbers[sn] {
return n * (2020 - n)
}
}
}
return 0
}
func PartTwo(numbers []int, setNumbers []int) int {
for n := range numbers {
fo... |
// Copyright 2021 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... |
package problem0623
type TreeNode struct {
Val int
Left *TreeNode
Right *TreeNode
}
func addOneRow(root *TreeNode, val int, depth int) *TreeNode {
if depth == 1 {
newRoot := &TreeNode{Val: val}
newRoot.Left = root
return newRoot
}
h := 1
queue := []*TreeNode{root}
for len(queue) > 0 {
levelLen := l... |
package main
import "fmt"
func Add(a int , b int ) int {
return a +b
}
func main() {
a := 111
b := 111
c := Add( a, b)
fmt.Println( c )
// fmt.Println("Hello MT.Qomolangma!")
}
|
package email
type Button struct {
Color string
TextColor string
Text string
Link string
}
|
package common
/*
Generated using mavgen - https://github.com/ArduPilot/pymavlink/
Copyright 2020 queue-b <https://github.com/queue-b>
Permission is hereby granted, free of charge, to any person obtaining a copy
of the generated software (the "Generated Software"), to deal
in the Generated Software without restricti... |
package auth_test
import (
"context"
"fmt"
"testing"
auth "github.com/gofor-little/aws-auth"
"github.com/stretchr/testify/require"
)
func TestSignUp(t *testing.T) {
setup(t)
defer teardown(t)
testCases := []struct {
emailAddress string
password string
}{
{"john@example.com", "test-Password1234!!"... |
package router
import (
"testing"
"github.com/stretchr/testify/assert"
)
type inputAndOutput struct {
input string
output Params
}
var testData map[string][]inputAndOutput = map[string][]inputAndOutput{
"*": []inputAndOutput{
0: inputAndOutput{
input: "/",
output: Params{},
},
1: inputAndOutput{
... |
package main
import "fmt"
/*
func main() {
var var0, var1, var2, var4 int
var0 = 1
var1 = 983
if var0 == 1 {
var1 += 10550400
var0 = 0
}
var2 = 1
for {
var4 = 1
for {
if (var2 * var4) == var1 {
var0 += var2
}
var4++
if var4 > var1 {
break
}
}
var2++
if var2 > var1 {
... |
package observe
import (
"fmt"
"github.com/nokamoto/grpc-proxy/yaml"
"github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc/codes"
"sort"
"time"
)
// Prom represents a collection of collectors which observes request count, latency, and request/response size.
type Prom interface {
Observe(stri... |
package main
import (
"code.google.com/p/portaudio-go/portaudio"
"fmt"
"github.com/rynlbrwn/oregon/knob"
"github.com/rynlbrwn/oregon/polysynth"
"math"
"os"
"time"
)
const (
rate = 44100
channels = 1
framesPerBuffer = 2048
int16Max = 1<<15 - 1
)
var ps = polysynth.NewPolySynth()
f... |
package gin
import (
"strconv"
)
//ServiceCheckHandle ..
func ServiceCheckHandle() HandlerFunc {
return func(c *Context) {
if true == c.IsInternalURL() {
u := c.Query("user_id")
if "" != u {
if i, err := strconv.ParseUint(u, 10, 64); nil == err {
c.UserID = i
} else {
return
}
}
}... |
package router
import (
"bytes"
"io"
"io/ioutil"
"net/http"
"testing"
"github.com/dennor/go-paddle/events/alerts"
"github.com/dennor/go-paddle/events/subscription"
"github.com/dennor/go-paddle/mime"
"github.com/stretchr/testify/mock"
)
type mockAlertHighRiskTransactionCreated struct {
mock.Mock
}
func (m ... |
package chapter5
import "testing"
func TestPowerSet(t *testing.T) {
t.Skip("Skipping PowerSet tests...")
var powerSetTests = [][]int{{}, {1}, {1, 2, 3}}
for _, tt := range powerSetTests {
PowerSet(tt)
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.