text stringlengths 11 4.05M |
|---|
// Package options provides convenience methods for reading node's options.
package options
import (
"github.com/jhump/protoreflect/desc"
"github.com/jhump/protoreflect/dynamic"
"github.com/richardwilkes/toolbox/errs"
)
// OptionReader embeds an extension registry
type OptionReader struct {
init bool
Registr... |
package main
import "fmt"
//Contact exported
type Contact struct {
greeting string
name string
}
//SwitchOnType exported
func SwitchOnType(x interface{}) {
switch x.(type) { // type assertion(type is a lexical element keyword)
case int:
fmt.Println("Sup Integer")
case string:
fmt.Println("Sup String")
... |
/*
Copyright 2019 The Crossplane 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, s... |
package simple_factory
import (
"testing"
)
func TestCaculatorFactory(t *testing.T) {
opFactory := new(OperationFactory)
operation := opFactory.CreateOperation("+")
operation.SetNumber(1, 2)
t.Logf("this is add operation, 1+2=%v\n", operation.GetResult())
operation = opFactory.CreateOperation("-")
operation.... |
package persistence
import (
"github.com/joshprzybyszewski/cribbage/model"
)
func ValidateLatestActionBelongs(mg model.Game) error {
if mg.NumActions() == 0 {
return nil
}
la := mg.Actions[mg.NumActions()-1]
if la.GameID != mg.ID {
return ErrGameActionWrongGame
}
found := false
for _, p := range mg.Playe... |
// Copyright 2021 Dataptive SAS.
//
// 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 ... |
package odoo
import (
"fmt"
)
// StockPicking represents stock.picking model.
type StockPicking struct {
LastUpdate *Time `xmlrpc:"__last_update,omptempty"`
ActivityDateDeadline *Time `xmlrpc:"activity_date_deadline,omptempty"`
ActivityIds *Relation `xmlrpc:"activity_ids,... |
package packet
import "github.com/bianjieai/tibc-sdk-go/types"
const moduleName = "tibc" + "-" + "packet"
// TIBC packet sentinel errors
var (
ErrSequenceSendNotFound = types.Register(moduleName, 2, "sequence send not found")
ErrSequenceReceiveNotFound = types.Register(moduleName, 3, "sequence receive not fou... |
package boltclient
import (
"encoding/json"
"log"
"github.com/gokapaya/cshelper/errlist"
"github.com/gokapaya/cshelper/match"
)
const PairBucket = "pairs"
// StoreMatches saves Pair data to the database.
// `pl` can be single or multiple Pair(s)
func (c *Client) StoreMatches(pl ...match.Pair) error {
var el er... |
package main
import (
"log"
"shared/protobuf/pb"
)
func (c *Client) YggdrasilGetMain(req *pb.C2SYggdrasilGetMain) (*pb.S2CYggdrasilGetMain, error) {
gameResp, err := c.Request(2801, req)
if err != nil {
return nil, err
}
resp := &pb.S2CYggdrasilGetMain{}
err = c.Handle(gameResp, resp)
if err != nil {
ret... |
package polyclip
import (
//"fmt"
g "github.com/murphy214/geobuf"
"github.com/murphy214/geobuf/geobuf_raw"
m "github.com/murphy214/mercantile"
"github.com/murphy214/pbf"
"math"
//"github.com/paulmach/go.geojson"
)
func RoundPt(pt []float64) []float64 {
return []float64{Round(pt[0], .5, 6), Round(pt[1], .5, 6)... |
// Package tree contains the anchor tree
package tree
import (
"runtime"
"sync"
"github.com/wetware/ww/internal/mem"
memutil "github.com/wetware/ww/pkg/util/mem"
)
// Transaction groups multiple node operations into a single atomic commit.
type Transaction Node
// Load API value
func (t Transaction) Load() mem.... |
package validator
import (
"fmt"
"net/http"
"net/url"
"github.com/mts-test-task/pkg/sitesdataservice/httperror"
)
// Input validate input data
type Input interface {
CheckURLs(urls []string) (err error)
}
type input struct {
maxURLsCount int
errorCreator httperror.ErrorCreator
}
func (i *input) CheckURLs(ur... |
/**
* Copyright (c) 2020 Ameya Lokare
*/
package main
import (
"context"
"crypto"
"crypto/ecdsa"
"crypto/ed25519"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"io"
"math/big"
"net"
"net/http"
"sync"
"time"
"github.com/google/uuid"
)
type Mitmer struct {
di... |
package server
import (
"rkouj/fun-with-go/chatserver/user"
"rkouj/fun-with-go/chatserver/util"
)
type Server interface {
ProcessRequests()
GetMessages(u user.User) []string
}
type server struct {
messages map[int][]string
userReadChans []chan string
userWriteChans []chan string
}
func NewServer(userReadChan... |
package main
import "fmt"
func uniqueLetterString(S string) int {
n := len(S)
dict := make(map[byte][]int)
for i := 0; i < n; i++ {
dict[S[i]] = append(dict[S[i]], i);
}
var ans int64 = 0
for i, _ := range dict {
res := int64(0)
lastApp := -1
for j, app := range dict[i] {
if j == len(dict[i]) - 1 {
... |
package wxapi
import (
"encoding/xml"
)
const (
// 消息类型
MsgTypeText = "text" // 文本消息
MsgTypeImage = "image" // 图片消息
MsgTypeVoice = "voice" // 语音消息
MsgTypeVideo = "video" // 视频消息
MsgTypeShortVideo = "shortvideo" // 小视频消息
MsgTypeLocation = "location" // 地理位置消息
Msg... |
// 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 problem07
import (
"exercises/aoc2020/common"
"regexp"
"strconv"
)
func Solve() (int, int, error) {
return SolveBoth("./problem07/input.txt")
}
func SolveBoth(inputFile string) (int, int, error) {
relations, err := parseFile(inputFile)
if err != nil {
return 0, 0, err
}
contained_by := map[string][... |
package schema
import (
"context"
"go-graphql-starter/db"
"go-graphql-starter/person"
)
type ViewerResolver struct {
viewer person.Person
}
func (resolver *ViewerResolver) User(ctx context.Context, args struct {
ID string
}) (person.PersonResolver, error) {
result, err := person.GetByUsername(args.ID, db.GetCo... |
/*
Copyright 2019 The Skaffold 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, sof... |
// 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 arc
import (
"context"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
"chromiumos/tast/ctxutil"
"chromiumos/tast/errors"
"chromiumos/tast/local/arc"
"c... |
package changelog
import "github.com/Azure/azure-sdk-for-go/tools/apidiff/report"
// Changelog describes a changelog of the package during this generation
type Changelog struct {
PackageName string
NewPackage bool
RemovedPackage bool
Modified *report.Package
}
// HasBreakingChanges returns if this r... |
package main
import (
"net/http"
"github.com/dodosuke/authlete-go/internal/app"
"github.com/dodosuke/authlete-go/pkg/authlete"
"github.com/dodosuke/authlete-go/pkg/util"
)
// introspection is an implementation of introspection endpoint defined by RFC 7662.
//
// RFC 7662, OAuth 2.0 Token Introspection
// http://... |
package value
import (
"testing"
"github.com/stretchr/testify/require"
"go.starlark.net/starlark"
)
func TestStringStringMap(t *testing.T) {
sv := starlark.NewDict(2)
err := sv.SetKey(starlark.String("a"), starlark.String("b"))
require.NoError(t, err)
err = sv.SetKey(starlark.String("c"), starlark.String("d")... |
package controller
import (
"fmt"
"github.com/myonlyzzy/prometheus-operator/pkg/apis/prometheus.io/v1alpha1"
"github.com/myonlyzzy/prometheus-operator/pkg/client/clientset/versioned"
pv1alpha1 "github.com/myonlyzzy/prometheus-operator/pkg/client/informers/externalversions/prometheus.io/v1alpha1"
listers "github.c... |
package constants
import "errors"
const (
// ApplicationStatusKTPSave application status for success update Document Information
ApplicationStatusKTPSave = "KTP_SAVED"
// ApplicationStatusPerSave application status for success update Applicant Information
ApplicationStatusPerSave = "PER_SAVED"
// ApplicationSt... |
package breach
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
)
func Test_Sleep(t *testing.T) {
cases := []struct {
seconds string
expectingErr bool
}{
{"10E99999", true},
{"1", false},
}
for i, c := range cases {
fmt.Printf("Running case %d\n", i+1)
err := Sleep(c.seco... |
// 1.2 命令行参数
package main
//func main() {
//fmt.Println("hello, world")
// 第一种拼接参数的方法
//var s, sep string
//for i := 1; i < len(os.Args); i++ {
// s += sep + os.Args[i]
// sep = "/"
//}
//fmt.Println(s)
// 第二种拼接参数的方法 range 返回值 第一个是索引,第二个是索引对应的参数值
//s, sep := "", "/"
//for _, arg := range os.Args[1:] {
/... |
package main
import (
"fmt"
"strings"
)
func main() {
//最长公共前缀
/**
编写一个函数来查找字符串数组中的最长公共前缀。如果不存在公共前缀,则返回""
示例1:
输入: ["flower","flow","flight"]
输出: "fl"
示例 2:
输入: ["dog","racecar","car"]
输出: ""
*/
arr := []string{"flower", "flow", "flight"}
res := longestPrefix(arr)
fmt.Println(res)
}
//以第一个元素为基础... |
package column
import "github.com/vahid-sohrabloo/chconn/v2/internal/readerwriter"
// Array is a column of Array(Nullable(T)) ClickHouse data type
type ArrayNullable[T comparable] struct {
Array[T]
dataColumn NullableColumn[T]
columnData []*T
}
// NewArrayNullable create a new array column of Array(Nullable(T)) C... |
package solutions
import (
"math/rand"
)
type Pair struct {
value int
index int
}
type RandomizedCollection struct {
mapToIndex map[int][]int
nums []Pair
}
func Constructor() RandomizedCollection {
return RandomizedCollection {
mapToIndex: make(map[int][]int),
nums: ... |
package main
import "fmt"
func main() {
var t1 = "text"
switch t1 {
case "test":
fmt.Println("Test abcd")
// list of possible comma separated val
case "text", "hello":
fmt.Println("Text abcd")
case "outer":
fmt.Println("Outer abcd")
default:
fmt.Println("Bye abcd")
}
}
// Text abcd
|
package core
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/opspec-io/opctl/util/containerprovider"
"github.com/opspec-io/opctl/util/pubsub"
"github.com/opspec-io/opctl/util/uniquestring"
"github.com/opspec-io/sdk-golang/pkg/model"
"time"
)
var _ = Context("core", func() {
Context(... |
package miner
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"math/big"
"sync"
"time"
"github.com/golang/protobuf/proto"
"github.com/xuperchain/xupercore/bcs/ledger/xledger/state"
"github.com/xuperchain/xupercore/bcs/ledger/xledger/tx"
lpb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb"
xctx... |
package built
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"github.com/eager7/elog"
"github.com/parnurzeal/gorequest"
"io"
"io/ioutil"
"net/http"
"os"
"reflect"
"strings"
"time"
)
const URLTokenList = "https://raw.githubusercontent.com/MyEtherWallet/ethereum-lists/master/dist/tokens/eth/tokens-eth.jso... |
package martinier
import (
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"time"
)
type User struct {
ID bson.ObjectId `bson:"_id,omitempty"`
Email string `json:"email"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
CreatedAt time.Time `json:"created_at... |
package main
// Leetcode 605. (easy)
func canPlaceFlowers(flowerbed []int, n int) bool {
can := 0
i := 0
for i < len(flowerbed) {
if flowerbed[i] == 0 && (i == len(flowerbed)-1 || flowerbed[i+1] == 0) {
can++
i += 2
} else if flowerbed[i] == 1 {
i += 2
} else {
i++
}
}
return can >= n
}
|
package unimatrix
func NewActivitiesOperation(realm string) *Operation {
return NewRealmOperation(realm, "activities")
}
|
// 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 api
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"strings"
)
func SaveAthenaData(s3FileName string, queryParams map[string]string, dataSource string) {
s3FilePath := os.Getenv("S3_FILE_PATH")
appHost := os.Getenv("APP_HOST")
s3Key := fmt.Sprint(s3FilePath, "/", dataSource, "/", queryParams["... |
package main
import (
"fmt"
)
type Person struct{
Name string
}
func main() {
c := new(Person)
c.Name = "cc"
fmt.Println(c.Name)
d := c
d.Name = "dd"
fmt.Println(c.Name)
i := *d
i.Name="ii"
fmt.Println(c.Name)
fmt.Println(d.Name)
fmt.Println(i.Name)
fmt.Printf("c type: %T\n", c)
fmt.Printf("c : %#... |
package main
import (
"context"
"fmt"
"github.com/gin-gonic/gin"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
"math"
"net/http"
"time"
)
func main() {
route := gin.Default()
http.Handle("/", route)
disableGinDebugLog()
// ログの出力がリクエストスコープでまとまるか
route.GET("/01", handleLog)
// AE Data... |
/*
Copyright 2019 Baidu, 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, software
dis... |
package main
import (
"github.com/gorilla/http"
)
// custom header
// timeout,connection/read
// connection pool
// follow redirect?
func main() {
http.Client{}
}
|
package main
import (
"net"
"fmt"
)
func process(conn net.Conn){
defer conn.Close()
buf := make([]byte, 1024)
n, err := conn.Read(buf)
if err != nil {
fmt.Println("服务器端获取客户端数据异常", err)
return
}
fmt.Print(string(buf[:n]))
//fmt.Print(buf)
}
func main() {
listen, err := net.Listen("tcp", ":8888")
defer ... |
package hash
import (
"fmt"
"github.com/mitchellh/hashstructure/v2"
"github.com/go-task/task/v3/taskfile"
)
type HashFunc func(*taskfile.Task) (string, error)
func Empty(*taskfile.Task) (string, error) {
return "", nil
}
func Name(t *taskfile.Task) (string, error) {
return t.Task, nil
}
func Hash(t *taskfil... |
package main
import "fmt"
func getAverage(arr []int, n int) float32 {
var sum int = 0
var average float32 = 0.0
for i := 0; i < n; i++ {
sum += arr[i]
}
average = float32(sum) / float32(n)
return average
}
func main() {
var arr = []int{1, 2, 0, 4}
fmt.Println(getAverage(arr, len(arr)))
}
|
package util
import (
"golang.org/x/crypto/bcrypt"
)
func GenerateFromPassword(password string) (string, error) {
hash, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
return string(hash), err
}
func CompareHashAndPassword(hash, password string) error {
return bcrypt.CompareHashAndPasswo... |
// Package documention here
package main
import (
"fmt"
"log"
"net/http"
// _ "net/http/pprof"
"regexp"
"github.com/pkg/profile"
)
func main() {
defer profile.Start().Stop()
http.HandleFunc("/regexp/", handlerRegex)
// http.HandleFunc("/", handlerRoot)
err := http.ListenAndServe(":8080", nil)
if err != n... |
// 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 uiauto enables automating with the ChromeOS UI through the chrome.automation API.
// The chrome.automation API is documented here: https://developer.chrome.com/ext... |
package main
import "fmt"
var runa rune = '쯼' // si no se especifica lo toma como tipo rune (int32)
var byta byte = 'a' // esto lo va a tomar como byte (uint8)
var bytb = 'b' //este al no especificar lo tomara como rune (int32)
var runb int32 = 52220 //esto va a mostrar lo mismo que runa
var runc rune =... |
package compute_test
import (
"errors"
"github.com/genevieve/leftovers/gcp/compute"
"github.com/genevieve/leftovers/gcp/compute/fakes"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
gcpcompute "google.golang.org/api/compute/v1"
)
var _ = Describe("Disks", func() {
var (
client *fakes.DisksClient
lo... |
/*
* Copyright 2021 American Express
*
* 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... |
package main
import (
"fmt"
"time"
"runtime"
)
func chanFlow(left, right chan int, bufferLen int) {
if bufferLen <= 0 {
left <- 1 + <-right
} else {
for i := 0; i < bufferLen; i++ {
left <- 1 + <-right
}
}
}
func main() {
fmt.Println("Num Chan:", runtime.NumGoroutine())
nruntime := 100000
chanBuffe... |
package list
import (
"errors"
"fmt"
"io"
"github.com/operator-framework/operator-registry/alpha/action"
"github.com/operator-framework/operator-registry/alpha/model"
"github.com/spf13/cobra"
kcmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/templates"
"github.com/openshift/oc-mirror/pkg/cli"
... |
package cfstack
import (
"errors"
"fmt"
"github.com/CleverTap/cfstack/internal/pkg/aws/cloudformation"
"github.com/CleverTap/cfstack/internal/pkg/aws/s3"
"github.com/CleverTap/cfstack/internal/pkg/aws/session"
"github.com/CleverTap/cfstack/internal/pkg/stack"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/... |
// 速率限制 是控制服务资源利用和质量的重要机制。
// 基于协程、通道和打点器,Go 优雅的支持速率限制
package main
import (
"fmt"
"time"
)
func main() {
// 首先,我们将看一个基本的速率限制
// 假设我们想限制对收到请求的处理,我们可以通过一个channel处理这些请求
requests := make(chan int, 5)
for i := 1; i <= 5; i++ {
requests <- i
}
close(requests)
// limiter 通道每 200ms 接收一个值。 这是我们任务速率限制的调度器
limiter... |
package main
import "fmt"
func f() {
defer fmt.Println("D")
fmt.Println("F")
}
// 被调用函数里的 defer 语句在返回之前就会被执行,所以输出顺序是 F D M。
func main() {
f()
fmt.Println("M")
}
|
package strongly_connected_components
import (
"reflect"
"testing"
)
var tests = []struct {
graph Graph
components []int
}{
{
Graph{
1,
true,
[]Edge{},
},
[]int{0},
},
{
Graph{
2,
true,
[]Edge{},
},
[]int{1, 0},
},
{
Graph{
2,
true,
[]Edge{
{0, 1},
},
},... |
package main
import "fmt"
/*
Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal.
Example 1:
Input: s1 = "sea", s2 = "eat"
Output: 231
Explanation: Deleting "s" from "sea" adds the ASCII value of "s" (115) to the sum.
Deleting "t" from "eat" adds 116 to the sum.
At the... |
package main
import "fmt"
/**
1.3.29
用环形链表实现 CircleQueue。环形链表也是一条链表,只是没有任何结点的链接为空,且只要链表非
空则 last.next 的值为 first。只能使用一个 node 类型的实例变量(last)。
*/
func main() {
circleQueue := NewQueue()
circleQueue.Enqueue(1)
circleQueue.Enqueue(2)
circleQueue.Enqueue(3)
circleQueue.Enqueue(4)
circleQueue.Dequeue()
fmt.Println(c... |
package compile
import (
"fmt"
"io"
"os"
"strconv"
"subc/compile/arch"
"subc/types"
)
type opcode int
type node struct {
op opcode
left, right *node
lv [2]arch.LV
}
const (
opGlue opcode = iota + 1
opAdd
opAddr
opAssign
opBinAnd
opBinOr
opBinXor
opBool
opBrFalse
opBrTrue
opCal... |
package domain
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
type Patch struct {
MetaData metav1.ObjectMeta `json:"metadata"`
}
|
package faker
import (
"regexp"
"strconv"
"testing"
)
func TestImageURL(t *testing.T) {
expectedURL := "http://lorempixel.com/600/400/food?200"
imgurl := f.Image().ImageURL(600, 400, "food")
regex := `http://lorempixel.com/600/400/food\?`
matched, err := regexp.MatchString(regex+"[1-999]", imgurl)
if err !=... |
package main
import (
"fmt"
"sort"
)
type Student2 struct {
Name string
Age int
}
type StudentSet struct {
Items []Student2
}
func (ss StudentSet) Len() int {
return len(ss.Items)
}
func (ss StudentSet) Swap(i, j int) {
ss.Items[i], ss.Items[j] = ss.Items[j], ss.Items[i]
}
func (ss StudentSet) Less(i, j i... |
package main
func waysToStep(n int) int {
if n < 3 {
return n
}
if n == 3 {
return 4
}
var steps = make([]int, n)
steps[0] = 1
steps[1] = 2
steps[2] = 4
for i := 3; i < n; i++ {
steps[i] = (steps[i-1] + steps[i-2] + steps[i-3]) % 1000000007
}
return steps[n-1]
}
|
package tokens
import (
"time"
"github.com/jrapoport/gothic/models/token"
"github.com/jrapoport/gothic/models/types/provider"
"github.com/jrapoport/gothic/store"
)
// GrantAuthToken gets or creates an auth token for the provider.
func GrantAuthToken(conn *store.Connection, p provider.Name, exp time.Duration) (*t... |
package proto
import (
// "rpc"
)
type AddPlayer struct {
PlayerId string
AuthKey string
// ChannelId rpc.GameLocation
ClanName string
}
type AddPlayerResult struct {
}
type DelPlayer struct {
PlayerId string
}
type DelPlayerResult struct {
}
type PlayerChatToPlayer struct {
FromPlayerId string
FromPla... |
package mapbson
import (
"reflect"
"strconv"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
)
type customInt int
func customIntEncoder(key reflect.Value) (string, error) {
gID := key.Interfa... |
package main
import (
"fmt"
"sort"
"strings"
"time"
"github.com/gorilla/feeds"
"github.com/mmcdole/gofeed"
)
// Merge takes a list of raw feed strings, parses and then merges them
func Merge(rawFeeds []string) feeds.Feed {
fp := gofeed.NewParser()
var items itemList
var feedList []string
for _, feed := ra... |
package main
import (
"encoding/json"
"errors"
"fmt"
"log"
"strconv"
"strings"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
func handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
// OrgStatus from request
var reqBody OrgStatus
log.Pr... |
package mypkg
import "fmt"
type Person struct {
Name string
}
func (p *Person) Introduce() {
fmt.Println("Hi, My name is", p.Name)
}
type Student struct {
Person // promotion
School string
}
func (s *Student) Introduce() {
s.Person.Introduce()
s.StudiesAt()
}
func (s *Student) StudiesAt() {
fmt.Println("I... |
package entity
// Store Склад
type Store struct {
Meta *Meta `json:"meta,omitempty"` // Метаданные Склада
Id string `json:"id,omitempty"` // ID Склада (Только для чтения)
AccountId string `json:"accountId,omitempty"` // ID учетной записи (Только для чтени... |
//go:generate moq -out ../../test/testhelpers/workflowMock.go -pkg testhelpers . Workflow:WorkflowMock
package workflow
import (
"context"
"errors"
"fmt"
"io"
"net/http"
"strings"
argoWorkflowAPIClient "github.com/argoproj/argo-workflows/v3/pkg/apiclient/workflow"
argoWorkflowAPISpec "github.com/argoproj/arg... |
/*
Copyright 2020 The Tilt Dev 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, sof... |
package evnet
//k8s.io/api/core/v1/types.go
type EventSource struct {
Component string
Host string
}
type Event struct {
metav1.TypeMeta
metav1.ObjectMeta
InvolvedObject ObjectReference
Reason string
Message string
Source EventSource
FirstTimestamp metav1... |
package wyre
import (
"bytes"
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"net/http"
"net/url"
)
type Client struct {
http *http.Client
key, secret, baseURL string
}
func NewClient(key, secret string, sandbox bool) *Client {
// get the base URL, based on sandbox fla... |
package h2md
import (
"bufio"
"bytes"
"golang.org/x/net/html"
"io"
"strconv"
"strings"
)
// H2MD H2MD struct
type H2MD struct {
*html.Node
ulN int
blockquoteN int
tdN int
tableSpliced bool
skipNewline bool
replacers map[string]Replacer
}
type Replacer func(val string, n *html.Node... |
/*
* Copyright (c) 2020 InterDigital Communications, 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 appl... |
package lmq_test
import (
"reflect"
"time"
. "github.com/zwb-ict/lmq"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("LmqSingleTopicWithSingleCp", func() {
var (
aproducer AsyncProducer
aperr error
consumer Consumer
cerr error
topicName string
opt *Opti... |
package main
import (
"encoding/json"
"errors"
"fmt"
"net/url"
"strings"
"time"
"github.com/gorilla/schema"
)
// ProjectList struct
type ProjectList []*Project
func (pl *ProjectList) formatJSON() *ProjectList {
for _, p := range *pl {
p.formatJSON()
}
return pl
}
// Project struct
type Project struct {... |
// Copyright The containerd Authors.
// Copyright 2021 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unle... |
package main
import (
"github.com/gin-gonic/gin"
"github.com/micro/go-plugins/registry/consul/v2"
"github.com/micro/go-micro/v2/registry"
"github.com/micro/go-micro/v2/web"
"log"
//"time"
)
func main() {
consulReg := consul.NewRegistry(func(op *registry.Options){
op.Addrs = []strin... |
package main
import (
"encoding/json"
"errors"
"fmt"
"log"
"math/rand"
"net/http"
"os"
"sort"
"strconv"
"time"
uuid "github.com/satori/go.uuid"
"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
_ "github.com/heroku/x/hmetrics/onload"
)
var positions [nColumns * nRows]Pos // convenience for get... |
// SPDX-License-Identifier: ISC
// Copyright (c) 2014-2020 Bitmark Inc.
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package block
import (
"github.com/bitmark-inc/bitmarkd/messagebus"
"github.com/bitmark-inc/logger"
)
type blockstore struct {
log *logger.L
}
... |
// Copyright 2018 The ChromiumOS Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package platform
import (
"context"
"time"
upstartcommon "chromiumos/tast/common/upstart"
"chromiumos/tast/local/chrome"
"chromiumos/tast/local/upstart"
"chromiumos/t... |
// If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
// Find the sum of all the multiples of 3 or 5 below 1000.
package main
import "fmt"
func main() {
fmt.Println("Searching :")
const LIMIT = 1000
var sum uint = 0
var t... |
package main
import "fmt"
func main(){
fmt.Println("Hello, This is Deepika")
fmt.Println("Nice to See")
fmt.println("Have a good day")
}
|
package e4
import "testing"
// WrapFunc wraps an error to form a chain.
//
// Instances must follow these rules:
// if argument is nil, return value must be nil
type WrapFunc func(err error) error
// Wrap forms an error chain by calling wrap functions in order
func Wrap(err error, fns ...WrapFunc) error {
for _, fn... |
package auth
import (
"github.com/baetyl/baetyl-cloud/v2/common"
"github.com/baetyl/baetyl-cloud/v2/plugin"
)
type defaultAuth struct {
cfg CloudConfig
}
func init() {
plugin.RegisterFactory("defaultauth", New)
}
// New New
func New() (plugin.Plugin, error) {
var cfg CloudConfig
if err := common.LoadConfig(&c... |
package rss
import (
"encoding/xml"
"testing"
)
var tests = []struct {
in string
want *Feed
}{
{`<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0" xml:base... |
// 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 backend
import (
"github.com/leachim2k/go-shorten/pkg/dataservice/interfaces"
"math/rand"
"sync"
"time"
)
type backend struct {
mutex sync.RWMutex
entityCache map[string]interfaces.Entity
statCache map[int][]*interfaces.StatEntity
}
func (m *backend) All(owner string) (*[]*interfaces.Entity, e... |
package provider
type combinedProvider struct {
status func() (string, error)
}
func init() {
registry.Add("combined", NewCombinedFromConfig)
registry.Add("openwb", NewCombinedFromConfig)
}
// NewCombinedFromConfig creates combined provider
func NewCombinedFromConfig(other map[string]interface{}) (Provider, error... |
package classfile
import "fmt"
const leftBoundOfMajorVersion = 45
const rightBoundOfMajorVersion = 52
const classFileMagic = 0xCAFEBABE
type ClassFile struct {
magic uint32
minorVersion uint16
majorVersion uint16
constantPool ConstantPool
accessFlags uint16
thisClass uint16
superClass uint16
int... |
package testutils
import (
"testing"
plugin_v1 "github.com/cyberark/secretless-broker/internal/plugin/v1"
"github.com/stretchr/testify/assert"
)
// CanProvideTestCase captures a test case where a provider is expected to return a value
// and no error
type CanProvideTestCase struct {
Description string
ID ... |
// 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 orchestratorexplorer
import (
"testing"
"github.com/go-logr/l... |
package models
type Student struct {
Username string `json:"username" csv:"username"`
Name string `json:"name" csv:"name"`
FacultyID string `json:"tpb" csv:"tpb"`
MajorID string `json:"major" csv:"major"`
Email string `json:"email" csv:"email"`
}
|
package syscalls
import (
"github.com/lunixbochs/struc"
"../models"
)
func trunc(s string, length int) string {
if length+1 < len(s) {
return s[:length-1] + "\x00"
}
return s + "\x00"
}
func Uname(u models.Usercorn, addr uint64, un *models.Uname) uint64 {
struc.Pack(u.Mem().StreamAt(addr), un)
/*
var uts... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.