commit stringlengths 40 40 | old_file stringlengths 4 264 | new_file stringlengths 4 264 | old_contents stringlengths 0 4.24k | new_contents stringlengths 1 5.44k | subject stringlengths 14 778 | message stringlengths 15 9.92k | lang stringclasses 277
values | license stringclasses 13
values | repos stringlengths 5 127k |
|---|---|---|---|---|---|---|---|---|---|
6e4546b6820738580d8a30bb1d1719abd12dd41c | main.go | main.go | package main
import (
"fmt"
"log"
"github.com/ghthor/engine/rpg2d"
"github.com/ghthor/engine/rpg2d/quad"
)
type inputPhase struct{}
type narrowPhase struct{}
func (inputPhase) ApplyInputsIn(c quad.Chunk) quad.Chunk {
for _, e := range c.Entities {
switch a := e.(type) {
case actor:
input := a.ReadInput(... | package main
import (
"fmt"
"log"
"github.com/ghthor/engine/rpg2d"
"github.com/ghthor/engine/rpg2d/quad"
"github.com/ghthor/engine/sim/stime"
)
type inputPhase struct{}
type narrowPhase struct{}
func (inputPhase) ApplyInputsIn(c quad.Chunk, now stime.Time) quad.Chunk {
for _, e := range c.Entities {
switch ... | Fix impl of the phase handler interfaces | Fix impl of the phase handler interfaces
| Go | mit | ghthor/aodd,ghthor/aodd |
c8b97052dfbb80daf49ffd43ec10993c33aaba11 | stat_times_darwin.go | stat_times_darwin.go | // +build amd64,darwin
package copy
import (
"os"
"syscall"
"time"
)
func getTimeSpec(info os.FileInfo) timespec {
stat := info.Sys().(*syscall.Stat_t)
times := timespec{
Mtime: info.ModTime(),
Atime: time.Unix(stat.Atimespec.Sec, stat.Atimespec.Nsec),
Ctime: time.Unix(stat.Ctimespec.Sec, stat.Ctimespec.N... | // +build darwin
package copy
import (
"os"
"syscall"
"time"
)
func getTimeSpec(info os.FileInfo) timespec {
stat := info.Sys().(*syscall.Stat_t)
times := timespec{
Mtime: info.ModTime(),
Atime: time.Unix(stat.Atimespec.Sec, stat.Atimespec.Nsec),
Ctime: time.Unix(stat.Ctimespec.Sec, stat.Ctimespec.Nsec),
... | Fix build on Apple Silicon | Fix build on Apple Silicon
Don't assume that Darwin is amd64-only. | Go | mit | otiai10/copy,otiai10/copy |
00ed1a162ef149064fd4f409a3e8441578731fab | subvert_test.go | subvert_test.go | package main
import (
"reflect"
"regexp"
"testing"
)
var genMatcherTests = []struct {
src string
dst *regexp.Regexp
}{
{"abc", regexp.MustCompile(`(abc)`)},
{"abcdef", regexp.MustCompile(`(abcdef)`)},
{"a,b", regexp.MustCompile(`(a|b)`)},
{"a,bc,def", regexp.MustCompile(`(a|bc|def)`)},
{"a\\,b", regexp.Mu... | package main
import (
"reflect"
"regexp"
"testing"
)
var genMatcherTests = []struct {
src string
dst *regexp.Regexp
}{
{`abc`, regexp.MustCompile(`(abc)`)},
{`abcdef`, regexp.MustCompile(`(abcdef)`)},
{`a,b`, regexp.MustCompile(`(a|b)`)},
{`a,bc,def`, regexp.MustCompile(`(a|bc|def)`)},
{`a\,b`, regexp.Mus... | Use backquote in tests in newMatcherTests | Use backquote in tests in newMatcherTests
| Go | mit | kusabashira/msub |
a719d3f1e2734708f6b57d645d9fdc53187e88d9 | util/oauth/encode.go | util/oauth/encode.go | package oauth
import (
"bytes"
"fmt"
)
var hex = "0123456789ABCDEF"
// encode percent-encodes a string as defined in RFC 3986.
func encode(s string) string {
var buf bytes.Buffer
for _, c := range []byte(s) {
if isEncodable(c) {
buf.WriteByte('%')
buf.WriteByte(hex[c>>4])
buf.WriteByte(hex[c&15])
} ... | package oauth
import (
"bytes"
"fmt"
)
var hex = "0123456789ABCDEF"
// encode percent-encodes a string as defined in RFC 3986.
func encode(s string) string {
var buf bytes.Buffer
for _, c := range []byte(s) {
if isEncodable(c) {
if c == '+' {
// replace plus-encoding with percent-encoding
buf.WriteS... | Use percent encoding for calculating the signature | Use percent encoding for calculating the signature
| Go | mpl-2.0 | rainycape/gondola,rainycape/gondola,rainycape/gondola,rainycape/gondola |
6c0ffe24d72250e77872d6af94306c349ca613da | src/github.com/opsee/gozer/registration/registration.go | src/github.com/opsee/gozer/registration/registration.go | package registration
import (
"github.com/opsee/portmapper"
)
const (
ipFilePathDefault = "/gozer/state/ip"
nsqdTopic = "connected"
)
var (
// The location of the file produced by OpenVPN containing the instance IP.
IPFilePath string
)
func init() {
IPFilePath = ipFilePathDefault
}
// /opsee.co/route... | package registration
import (
"github.com/opsee/portmapper"
)
const (
ipFilePathDefault = "/gozer/state/ip"
nsqdTopic = "_.connected"
)
var (
// The location of the file produced by OpenVPN containing the instance IP.
IPFilePath string
)
func init() {
IPFilePath = ipFilePathDefault
}
// /opsee.co/rou... | Send messages to broadcast connected topic. | Send messages to broadcast connected topic.
| Go | mit | opsee/zuul,opsee/zuul |
7444dd213029bc8e3a1d9c0debdecc21199d13e3 | knsq/convenience.go | knsq/convenience.go | package knsq
import (
"io"
"log"
"net/http"
)
// FIXME: Use socket API instead of HTTP
// CreateTopic makes sure a topic exists on the given nsqd.
func CreateTopic(nsqd string, topic string) error {
resp, err := http.Get("http://" + nsqd + "/create_topic?topic=" + topic)
if resp != nil && resp.Body != nil {
r... | package knsq
import (
"io"
"log"
"net/http"
"net/url"
)
// TODO: Add socket implementation
type Client interface {
// CreateTopic makes sure a topic exists on the given nsqd.
CreateTopic(topic string) error
// Send sends a message on a topic to the specified nsqd.
Send(topic string, body io.Reader)
}
// Htt... | Refactor knsq to an interface | Refactor knsq to an interface
| Go | bsd-3-clause | voxelbrain/k |
cb1f88ae032e8f8010d1fe997ff2e0366b27f2af | lib/srpc/load.go | lib/srpc/load.go | package srpc
import (
"crypto/tls"
"fmt"
"os"
"path"
"strings"
)
func loadCertificates(directory string) ([]tls.Certificate, error) {
dir, err := os.Open(directory)
if err != nil {
return nil, err
}
names, err := dir.Readdirnames(0)
defer dir.Close()
if err != nil {
return nil, err
}
certs := make([]... | package srpc
import (
"crypto/tls"
"fmt"
"os"
"path"
"strings"
)
func loadCertificates(directory string) ([]tls.Certificate, error) {
dir, err := os.Open(directory)
if err != nil {
return nil, err
}
names, err := dir.Readdirnames(0)
defer dir.Close()
if err != nil {
return nil, err
}
certs := make([]... | Return nil for empty cert slice in lib/srpc.LoadCertificates(). | Return nil for empty cert slice in lib/srpc.LoadCertificates().
| Go | apache-2.0 | rgooch/Dominator,Symantec/Dominator,rgooch/Dominator,Symantec/Dominator,Symantec/Dominator,keep94/Dominator,keep94/Dominator,rgooch/Dominator,keep94/Dominator |
5a641e1d69181f017f7b9bc350a6a52298fe1eba | krpc/fuzz_test.go | krpc/fuzz_test.go | //go:build go1.18
package krpc
import (
"testing"
"github.com/anacrolix/torrent/bencode"
qt "github.com/frankban/quicktest"
)
func Fuzz(f *testing.F) {
f.Add([]byte("d1:rd2:id20:\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01e1:t1:t1:y1:re"))
f.Fuzz(func(t *testing.T, b []byte)... | //go:build go1.18
// +build go1.18
package krpc
import (
"testing"
"github.com/anacrolix/torrent/bencode"
qt "github.com/frankban/quicktest"
)
func Fuzz(f *testing.F) {
f.Add([]byte("d1:rd2:id20:\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01e1:t1:t1:y1:re"))
f.Fuzz(func(t *tes... | Add old-style build constraint for go1.16 compat | Add old-style build constraint for go1.16 compat
| Go | mpl-2.0 | anacrolix/dht |
6cab290e2c4e9da87a5c115e845cd4afc1dd18a5 | examples/scraper/scraper_test.go | examples/scraper/scraper_test.go | package scraper
import (
"fmt"
"os"
"os/exec"
"testing"
"time"
"github.com/pachyderm/pachyderm/src/client/pkg/require"
)
func TestScraper(t *testing.T) {
wd, err := os.Getwd()
require.NoError(t, err)
fmt.Printf("wd: %s", wd)
require.NoError(t, exec.Command("pachctl", "create-repo", "urls").Run())
require.... | package scraper
import (
"os"
"os/exec"
"testing"
"time"
"github.com/pachyderm/pachyderm/src/client/pkg/require"
)
func TestScraper(t *testing.T) {
require.NoError(t, exec.Command("pachctl", "create-repo", "urls").Run())
require.NoError(t, exec.Command("pachctl", "start-commit", "urls", "master").Run())
putF... | Remove debug print in test. | Remove debug print in test.
| Go | apache-2.0 | pachyderm/pfs,pachyderm/pfs,pachyderm/pfs |
19a0ec601e30cebc35e172e7e061540e05d68d3b | Demo1.go | Demo1.go | /*
Demonstrate how to use channels and goroutines to keep the program alive.
Iterate over a slice of numbers, passing each each i to a function
that calculates the base10 log of i.
We don't actually care what the return value is.
Instead, the function just signals a channel that its work is done.
Based on ... | /*
Demonstrate how to use channels and goroutines to keep the program alive.
Iterate over a slice of numbers, passing each each i to a function
that calculates the base10 log of i.
We don't actually care what the return value is.
Instead, the function just signals a channel that its work is done.
Based on ... | Clarify demo code comment on channels | Clarify demo code comment on channels
In Go, channels always behave as "first in, first out." Setting the
channel's size to 1 makes it behave like a semaphore.
| Go | bsd-3-clause | ewk/nclug-go,ewk/nclug-go |
8de6bfe333c1f26124245d2d0aeffd18720f3110 | entrevista_test.go | entrevista_test.go | package entrevista_test
import (
"fmt"
"github.com/hoop33/entrevista"
)
func Example() {
interview := entrevista.NewInterview()
interview.ReadAnswer = func(question *entrevista.Question) (string, error) {
return question.Key, nil
}
interview.Questions = []entrevista.Question{
{
Key: "name",
Text... | package entrevista_test
import (
"fmt"
"github.com/hoop33/entrevista"
)
func Example() {
interview := entrevista.NewInterview()
interview.ReadAnswer = func(question *entrevista.Question) (string, error) {
return question.Key, nil
}
interview.Questions = []entrevista.Question{
{
Key: "name",
Text... | Fix example test--map iteration not ordered | Fix example test--map iteration not ordered
| Go | mit | hoop33/entrevista |
0e788a4a2c8a859ac638143a2d95c5a5961b87f3 | battery_windows.go | battery_windows.go | package battery
import (
"syscall"
"unsafe"
)
var (
modkernel32 = syscall.NewLazyDLL("kernel32")
procGetSystemPowerStatus = modkernel32.NewProc("GetSystemPowerStatus")
)
type SYSTEM_POWER_STATUS struct {
ACLineStatus byte
BatteryFlag byte
BatteryLifePercent byte
Reserved1 ... | package battery
import (
"math"
"syscall"
"unsafe"
)
var (
modkernel32 = syscall.NewLazyDLL("kernel32")
procGetSystemPowerStatus = modkernel32.NewProc("GetSystemPowerStatus")
)
type SYSTEM_POWER_STATUS struct {
ACLineStatus byte
BatteryFlag byte
BatteryLifePercent byte
Reserved1... | Add logic to show elapsed time in windows | Add logic to show elapsed time in windows
| Go | mit | Code-Hex/battery |
2cbd819b353e8a6cde818ffb4e98dc5239eae44d | lru1/lru1.go | lru1/lru1.go | package lru1
import "container/list"
type Item struct {
key string
value string
}
type Cache struct {
capacity int
data map[string]*list.Element
lst *list.List
}
func NewCache(capacity int) *Cache {
cache := new(Cache)
cache.capacity = capacity
cache.data = make(map[string]*list.Element)
return ... | // Package lru1 implement Least Recently Used based on doubly linked list.
package lru1
import "container/list"
// Item is an element in cache.
type Item struct {
key string
value string
}
// Cache is a sized LRU cache.
type Cache struct {
capacity int
data map[string]*list.Element
lst *list.List
}
... | Fix adding Item to cache. | Fix adding Item to cache.
| Go | mit | krasoffski/gomill,krasoffski/gomill |
d39bb230fd0b01fb94a948e58f1800f9dc51f715 | channels/Demand.go | channels/Demand.go | package channels
type DemandState struct {
Rated *float64 `json:"rated,omitempty"` // rated maximum power, in Watts
ObservedMax *float64 `json:"observedMax,omitempty"` // the observed max current power for this device
Current *float64 `json:"current,omitempty"` // average power for current... | package channels
type DemandState struct {
Rated *float64 `json:"rated,omitempty"` // rated maximum power, in Watts
ObservedMax *float64 `json:"observedMax,omitempty"` // the observed max current power for this device
Current *float64 `json:"current,omitempty"` // average power for current... | Add onticks and offticks to model. | Add onticks and offticks to model.
Signed-off-by: Jon Seymour <44f878afe53efc66b76772bd845eb65944ed8232@ninjablocks.com>
| Go | mit | ninjasphere/go-ninja,ninjasphere/go-ninja |
bbfa21a7c27c68d30e6d34a45f8a681ead3b9c6d | provider/vsphere/init_gccgo.go | provider/vsphere/init_gccgo.go | // Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
// +build gccgo
package vsphere
const (
providerType = "vsphere"
)
| // Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
// +build gccgo
// This file exists so that this package will remain importable under
// GCCGo. In particular, see provider/all/all.go. All other files in
// this package do not build under GCCGo (see lp:1440940).
package vs... | Add a comment explaining the reason for the build constraints. | Add a comment explaining the reason for the build constraints.
| Go | agpl-3.0 | dooferlad/juju,tych0/juju,dooferlad/juju,wwitzel3/juju,davecheney/juju,frankban/juju,tasdomas/juju,cloud-green/juju,Altoros/juju-cloudsigma,frankban/juju,thomnico/juju,howbazaar/juju,frankban/juju-tmp,cloud-green/juju,perrito666/juju,dimitern/juju,bogdanteleaga/juju,sinzui/juju,reedobrien/juju,mjs/juju,axw/juju,howbaza... |
41f48b4306e50a2f3d42169b5a7f97a8b91fec01 | projects/sboms.go | projects/sboms.go | package projects
import "time"
const (
// GetSbomEndpoint is the current endpoint for retrieving an organization's SBOMs
GetSbomEndpoint = "v1/project/getSBOM"
// GetSbomsEndpoint is the current endpoint for retrieving an organization's SBOMs
GetSbomsEndpoint = "v1/project/getSBOMs"
)
// SBOM represents a softwa... | package projects
import "time"
const (
// GetSbomEndpoint is the current endpoint for retrieving an organization's SBOMs
GetSbomEndpoint = "v1/project/getSBOM"
// GetSbomsEndpoint is the current endpoint for retrieving an organization's SBOMs
GetSbomsEndpoint = "v1/project/getSBOMs"
)
// SBOMMetadata contains va... | Add various counts to SBOMs | [ION-1259] Add various counts to SBOMs
| Go | apache-2.0 | ion-channel/ionic,ion-channel/ionic |
9ec6e9d02d7074e96fe3f0db5a94ce38c3f0d501 | src/qpm.io/qpm/core/context.go | src/qpm.io/qpm/core/context.go | package core
import (
"google.golang.org/grpc"
"log"
"os"
msg "qpm.io/common/messages"
"google.golang.org/grpc/credentials"
)
const (
Version = "0.0.1"
PackageFile = "qpm.json"
SignatureFile = "qpm.asc"
Vendor = "vendor"
Address = "pkg.qpm.io:7000"
LicenseFile = "LICENSE"
)
type Con... | package core
import (
"google.golang.org/grpc"
"log"
"os"
msg "qpm.io/common/messages"
"google.golang.org/grpc/credentials"
"fmt"
"runtime"
)
const (
Version = "0.0.1"
PackageFile = "qpm.json"
SignatureFile = "qpm.asc"
Vendor = "vendor"
Address = "pkg.qpm.io:7000"
LicenseFile = "LI... | Send a user agent to the server. | Send a user agent to the server.
This is to get a rough idea of what version of the binary people are
using and also their platform and architecture.
| Go | artistic-2.0 | benlau/qpm,benlau/qpm |
4a348d466b954cf028e8a23735e702668c7cc5ff | base/id_inferable.go | base/id_inferable.go | package base
// IDInferable represents models that have IDs that can be infered by names.
type IDInferable interface {
InferID(cn Connection) error
GetNames(cn Connection, name string) ([]string, error)
}
| package base
// IDInferable represents models that have IDs that can be infered from names
// through communicating the server.
type IDInferable interface {
// After InferID has been completed, all the IDs possible have to have
// been infered from names.
InferID(cn Connection) error
// GetNames exists for the pur... | Document the IDInferable interface and its methods | Document the IDInferable interface and its methods
| Go | apache-2.0 | CenturyLinkCloud/clc-go-cli,CenturyLinkCloud/clc-go-cli |
d080a32aa618961a48042dfaa48c1e5277a64e8a | hackedu/schools.go | hackedu/schools.go | package hackedu
import (
"encoding/json"
"fmt"
"net/http"
"appengine"
)
type School struct {
Name string `json:"latitude,omitempty"`
Location Location
}
type Location struct {
Latitude float32 `json:"latitude,omitempty"`
Longitude float32 `json:"longitude,omitempty"`
}
func Schools(w http.ResponseWrit... | package hackedu
import (
"encoding/json"
"fmt"
"net/http"
"appengine"
)
type School struct {
Name string `json:"name,omitempty"`
Location Location `json:"location,omitempty"`
}
type Location struct {
Latitude float32 `json:"latitude,omitempty"`
Longitude float32 `json:"longitude,omitempty"`
}
func S... | Use the correct JSON keys for School structs. | Use the correct JSON keys for School structs.
| Go | mit | hackedu/website,zachlatta/website,hackedu/website,zachlatta/website,hackedu/website,zachlatta/website |
330114d17efbaa3acf11c6bec6a114c14d660bb6 | irrverbs/config.go | irrverbs/config.go | package main
import "code.google.com/p/gcfg"
// Config is config
type Config struct {
Telegram struct {
Token string
Username string
}
}
func getConfig() (Config, error) {
var cfg Config
err := gcfg.ReadFileInto(&cfg, "./config.cfg")
return cfg, err
}
| package main
import "gopkg.in/gcfg.v1"
// Config is config
type Config struct {
Telegram struct {
Token string
Username string
}
}
func getConfig() (Config, error) {
var cfg Config
err := gcfg.ReadFileInto(&cfg, "/tmp/config.cfg")
return cfg, err
}
| Change imprort name of gcfg to make project compile | Change imprort name of gcfg to make project compile
| Go | mit | sanchopanca/irrverbs |
2ba2dcc5b14ced82e789c36b269ecf8047acd149 | cmd/i-sudoku/main.go | cmd/i-sudoku/main.go | /*
i-sudoku is an interactive command-line sudoku tool
*/
package main
import (
"github.com/jkomoros/sudoku"
"github.com/nsf/termbox-go"
"log"
"strings"
)
type mainModel struct {
grid *sudoku.Grid
}
func main() {
if err := termbox.Init(); err != nil {
log.Fatal("Termbox initialization failed:", err)
}
def... | /*
i-sudoku is an interactive command-line sudoku tool
*/
package main
import (
"github.com/jkomoros/sudoku"
"github.com/nsf/termbox-go"
"log"
"strings"
)
type mainModel struct {
grid *sudoku.Grid
}
func main() {
if err := termbox.Init(); err != nil {
log.Fatal("Termbox initialization failed:", err)
}
def... | Fix rendering of the sudoku puzzle. | Fix rendering of the sudoku puzzle.
| Go | apache-2.0 | jkomoros/sudoku,jkomoros/sudoku,jkomoros/sudoku |
3580009dd80cc93c2c1e85f4e1c79353bdc08a8c | leetcode/199_binary_tree_right_side_view.go | leetcode/199_binary_tree_right_side_view.go | package leetcode
// 199. Binary Tree Right Side View
func rightSideView(root *TreeNode) []int {
if root == nil {
return []int{}
}
res := []int{}
list := []*TreeNode{root}
for len(list) > 0 {
res = append(res, list[len(list)-1].Val)
nextList := make([]*TreeNode, 0)
for _, node := range list {
if node.Le... | package leetcode
import "container/list"
// 199. Binary Tree Right Side View
func rightSideView(root *TreeNode) []int {
if root == nil {
return []int{}
}
res := []int{}
list := []*TreeNode{root}
for len(list) > 0 {
res = append(res, list[len(list)-1].Val)
nextList := make([]*TreeNode, 0)
for _, node := r... | Add 199. Binary Tree Right Side View with list | Add 199. Binary Tree Right Side View with list
| Go | mit | motomux/go-algo |
4cd80fc744507cc9c2eba328da5777e6f184447f | smsender/model/route.go | smsender/model/route.go | package model
import "regexp"
type Route struct {
Id int64 `json:"-"`
Name string `json:"name"`
Pattern string `json:"pattern"`
Broker string `json:"broker"`
From string `json:"from" db:"fromName"`
IsActive bool `json:"is_active"`
broker Broker
regex *regexp.Regexp
}
func NewRoute(na... | package model
import "regexp"
type Route struct {
Id int64 `json:"-"`
Name string `json:"name"`
Pattern string `json:"pattern"`
Broker string `json:"broker"`
From string `json:"from" db:"fromName"`
IsActive bool `json:"is_active" db:"isActive"`
broker Broker
regex *regexp.Regexp
}
fu... | Fix the db tag of model.Route | Fix the db tag of model.Route
| Go | mit | minchao/smsender,minchao/smsender,minchao/smsender,minchao/smsender |
f740ab9b8c6801e16ec3f290a62a09df51045c8f | wakeup.go | wakeup.go | package medtronic
import (
"log"
"time"
)
const (
Wakeup CommandCode = 0x5D
)
func (pump *Pump) Wakeup() {
pump.Model()
if pump.Error() == nil {
return
}
log.Printf("waking pump")
const (
// Older pumps should have RF enabled to increase the
// frequency with which they listen for wakeups.
numWakeups... | package medtronic
import (
"log"
"time"
)
const (
Wakeup CommandCode = 0x5D
)
func (pump *Pump) Wakeup() {
pump.Model()
if pump.Error() == nil {
return
}
pump.SetError(nil)
log.Printf("waking pump")
const (
// Older pumps should have RF enabled to increase the
// frequency with which they listen for w... | Clear error after no response | Clear error after no response
| Go | mit | ecc1/medtronic,ecc1/medtronic |
07f1d94bdb9b961ae76432a23de8919ab96a6d72 | maker/maker_test.go | maker/maker_test.go | package maker
import (
"strings"
"testing"
)
func check(value, pattern string, t *testing.T) {
if value != pattern {
t.Fatalf("Value %s did not match expected pattern %s", value, pattern)
}
}
func TestLines(t *testing.T) {
docs := []string{`// TestMethod is great`}
code := `func TestMethod() string {return "... | package maker
import (
"strings"
"testing"
)
func check(value, pattern string, t *testing.T) {
if value != pattern {
t.Fatalf("Value %s did not match expected pattern %s", value, pattern)
}
}
func TestLines(t *testing.T) {
docs := []string{`// TestMethod is great`}
code := `func TestMethod() string {return "... | Delete a trailing beginning of another test case | Delete a trailing beginning of another test case
| Go | apache-2.0 | vburenin/ifacemaker |
1cb3c147fa9e8916b885c95d743b455db6c83908 | marshalers/dummy.go | marshalers/dummy.go | package transports
import (
"log"
)
type DummyMarshaler struct {
}
func (marshaler DummyMarshaler) Marshal(i *interface{}) (error, interface{}) {
log.Println("** DummyMarshaler, input", *i)
var err error
return err, []byte("aa")
}
func (marshaler DummyMarshaler) Unmarshal() {
return
}
| package transports
import (
// "log"
)
type DummyMarshaler struct {
}
func (marshaler DummyMarshaler) Marshal(i *interface{}) (error, interface{}) {
var err error
return err, *i
}
func (marshaler DummyMarshaler) Unmarshal() {
return
}
| Return the original value from DummyMarshaler | Return the original value from DummyMarshaler
| Go | mit | matiasinsaurralde/transports |
a7be1467bfd712922e9f58e0c4ea61e3de12f4d0 | arch.go | arch.go | // +build !windows
package gottyclient
import (
"encoding/json"
"fmt"
"golang.org/x/sys/unix"
"os"
"os/signal"
"syscall"
)
func notifySignalSIGWINCH(c chan<- os.Signal) {
signal.Notify(c, syscall.SIGWINCH)
}
func resetSignalSIGWINCH() {
signal.Reset(syscall.SIGWINCH)
}
func syscallTIOCGWINSZ() ([]byte, err... | // +build !windows
package gottyclient
import (
"encoding/json"
"fmt"
"golang.org/x/sys/unix"
"os"
"os/signal"
"syscall"
)
func notifySignalSIGWINCH(c chan<- os.Signal) {
signal.Notify(c, syscall.SIGWINCH)
}
func resetSignalSIGWINCH() {
signal.Reset(syscall.SIGWINCH)
}
func syscallTIOCGWINSZ() ([]byte, err... | Fix bug when resizing terminal | Fix bug when resizing terminal
| Go | mit | moul/gotty-client,moul/gotty-client,moul/gotty-client,moul/gotty-client |
b3dbcfb2989b29d211b58d2e87c7de4a9d434207 | go/gorm/model/models.go | go/gorm/model/models.go | package model
// Customer is a model in the "customers" table.
type Customer struct {
ID int `json:"id"`
Name *string `json:"name" gorm:"not null"`
}
// Order is a model in the "orders" table.
type Order struct {
ID int `json:"id"`
Subtotal float64 `json:"subtotal" gorm:"type:decimal(18,2)"`
Cus... | package model
// Customer is a model in the "customers" table.
type Customer struct {
ID int `json:"id,omitempty"`
Name *string `json:"name" gorm:"not null"`
}
// Order is a model in the "orders" table.
type Order struct {
ID int `json:"id,omitempty"`
Subtotal float64 `json:"subtotal" gorm:"type:d... | Add omitempty to id fields | testing: Add omitempty to id fields
Otherwise adding a new customer (or any model) with a POST would include
a zeroed ID field.
| Go | apache-2.0 | cockroachdb/examples-orms,cockroachdb/examples-orms,cockroachdb/examples-orms,cockroachdb/examples-orms,cockroachdb/examples-orms,cockroachdb/examples-orms,cockroachdb/examples-orms |
12670a6e86015965a34a76451f88f2cf9eb0bf4d | worker/diskmanager/diskmanager_unsupported.go | worker/diskmanager/diskmanager_unsupported.go | // Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
// +build !linux
package diskmanager
import (
"github.com/juju/juju/storage"
"github.com/juju/juju/version"
)
var blockDeviceInUse = func(storage.BlockDevice) (bool, error) {
panic("not supported")
}
func listBlockDevic... | // Copyright 2014 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
// +build !linux
package diskmanager
import (
"runtime"
"github.com/juju/juju/storage"
"github.com/juju/juju/version"
)
var blockDeviceInUse = func(storage.BlockDevice) (bool, error) {
panic("not supported")
}
func li... | Fix compile failure for windows. | Fix compile failure for windows.
| Go | agpl-3.0 | AdamIsrael/juju,perrito666/juju,wwitzel3/juju,wwitzel3/juju,howbazaar/juju,bz2/juju,macgreagoir/juju,howbazaar/juju,dimitern/juju,mjs/juju,dooferlad/juju,mikemccracken/juju,AdamIsrael/juju,perrito666/juju,frankban/juju,bac/juju,ericsnowcurrently/juju,mjs/juju,fwereade/juju,alesstimec/juju,AdamIsrael/juju,macgreagoir/ju... |
ee078c3a146c99bb33aee5b58b352d69538b06fb | session.go | session.go | package buffalo
import (
"net/http"
"github.com/gorilla/sessions"
)
// Session wraps the "github.com/gorilla/sessions" API
// in something a little cleaner and a bit more useable.
type Session struct {
Session *sessions.Session
req *http.Request
res http.ResponseWriter
}
// Save the current session
fun... | package buffalo
import (
"net/http"
"github.com/gorilla/sessions"
)
// Session wraps the "github.com/gorilla/sessions" API
// in something a little cleaner and a bit more useable.
type Session struct {
Session *sessions.Session
req *http.Request
res http.ResponseWriter
}
// Save the current session.
fu... | Add punctuation to be consistent | Add punctuation to be consistent | Go | mit | gobuffalo/buffalo,gobuffalo/buffalo,markbates/buffalo |
f307d74d3ace796a60b80d98ae6dd71e1fd94951 | cmd/voyager/app/options/options.go | cmd/voyager/app/options/options.go | package options
import (
"github.com/spf13/pflag"
)
type Config struct {
Master string
KubeConfig string
ProviderName string
ClusterName string
LoadbalancerImageName string
}
func NewConfig() *Config {
return &Config{
Master: "",
KubeConfig: ... | package options
import (
"github.com/spf13/pflag"
)
type Config struct {
Master string
KubeConfig string
ProviderName string
ClusterName string
LoadbalancerImageName string
}
func NewConfig() *Config {
return &Config{
Master: "",
KubeConfig: ... | Set default HAproxy to 1.7.2-k8s | Set default HAproxy to 1.7.2-k8s
| Go | apache-2.0 | appscode/voyager,appscode/voyager,appscode/voyager |
05444a94e25a234b8db2722a6f75da89ff29717e | generator_tcsh.go | generator_tcsh.go | package acgen
import (
"io"
"strings"
"text/template"
)
func init() {
RegisterGenerator("tcsh", generateTcshCompletion)
}
type tcsh struct {
Name string
Opt string
}
func newTcsh(c *Command) (t *tcsh, err error) {
opts := make([]string, 0)
for _, flag := range c.Flags {
for _, opt := range flag.Long {
... | package acgen
import (
"io"
"strings"
"text/template"
)
func init() {
RegisterGenerator("tcsh", generateTcshCompletion)
}
type tcsh struct {
Name string
Opt string
}
func newTcsh(c *Command) (t *tcsh, err error) {
var opts []string
for _, flag := range c.Flags {
for _, opt := range flag.Long {
opts = ... | Use var instead of make | Use var instead of make
| Go | mit | kusabashira/acgen |
67c25cc1f55683bf49354f17369c1646641526b0 | net/httpclient/example_test.go | net/httpclient/example_test.go | package httpclient_test
import (
"fmt"
"net/http"
"gnd.la/net/httpclient"
)
func ExampleIter() {
// Passing nil only works on non-App Engine and while
// running tests. Usually you should pass a *app.Context
// to httpclient.New.
c := httpclient.New(nil)
req, err := http.NewRequest("GET", "http://httpbin.org... | package httpclient_test
import (
"fmt"
"net/http"
"gnd.la/net/httpclient"
)
func ExampleIter() {
// Passing nil only works on non-App Engine and while
// running tests. Usually you should pass a *app.Context
// to httpclient.New.
c := httpclient.New(nil)
req, err := http.NewRequest("GET", "http://httpbin.org... | Update URLs in ExampleIter to match the changes in httpbin's API | Update URLs in ExampleIter to match the changes in httpbin's API
/redirect was changed to /relative-redirect
| Go | mpl-2.0 | rainycape/gondola,rainycape/gondola,rainycape/gondola,rainycape/gondola |
946342bf0d34850bec4be1cd5ac94977112edc8e | models/settings.go | models/settings.go | package models
import (
"gopkg.in/yaml.v2"
"io/ioutil"
)
type Setting struct {
Database struct {
Host string
DbName string
TokenTable string
UserTable string
}
}
var Set Setting
func LoadSettings() error {
text, err := ioutil.ReadFile("./settings.yml")
if err != nil {
return err
}
if e... | package models
import (
"gopkg.in/yaml.v2"
"io/ioutil"
)
type Setting struct {
Database struct {
Host string
DbName string
TokenTable string
UserTable string
}
Ssl struct {
Key string
Sertificate string
}
Router struct {
Register string
Login string
Validate string
}
}
... | Add Ssl config. Add Router config. | Add Ssl config.
Add Router config.
| Go | mit | herald-it/goncord |
3645d26defb048fbbcf0760bae4562a76d8bb107 | lib/html/header.go | lib/html/header.go | package html
import (
"fmt"
"io"
"syscall"
"time"
)
var startTime time.Time = time.Now()
func writeHeader(writer io.Writer) {
fmt.Fprintf(writer, "Start time: %s<br>\n", startTime)
uptime := time.Since(startTime)
fmt.Fprintf(writer, "Uptime: %s<br>\n", uptime)
var rusage syscall.Rusage
syscall.Getrusage(sys... | package html
import (
"fmt"
"github.com/Symantec/Dominator/lib/format"
"io"
"runtime"
"syscall"
"time"
)
var startTime time.Time = time.Now()
func writeHeader(writer io.Writer) {
fmt.Fprintf(writer, "Start time: %s<br>\n", startTime)
uptime := time.Since(startTime)
fmt.Fprintf(writer, "Uptime: %s<br>\n", up... | Add allocated memory to HTML status pages. | Add allocated memory to HTML status pages.
| Go | apache-2.0 | keep94/Dominator,rgooch/Dominator,keep94/Dominator,rgooch/Dominator,keep94/Dominator,Symantec/Dominator,Symantec/Dominator,rgooch/Dominator,Symantec/Dominator |
d8a674e6fe5b37086b0d9978b0d513d9a55b6291 | runtime/fetcher/filereseter.go | runtime/fetcher/filereseter.go | package fetcher
import "os"
// FileReseter implements WriteReseter for an *os.File instance
type FileReseter struct {
*os.File
}
// Reset will truncate the file and seek to the beginning.
func (f *FileReseter) Reset() error {
err := f.Truncate(0)
if err != nil {
return err
}
_, err = f.Seek(0, 0)
return err
... | package fetcher
import "io"
// File interface as implemented by *os.File
type File interface {
Truncate(size int64) error
io.Seeker
io.Writer
}
// FileReseter implements WriteReseter for an *os.File instance
type FileReseter struct {
File
}
// Reset will truncate the file and seek to the beginning.
func (f *Fil... | Define interface wrapping io.File for FileReseter | Define interface wrapping io.File for FileReseter
| Go | mpl-2.0 | walac/taskcluster-worker,walac/taskcluster-worker |
d6c02f5aeba170f9c036695c4aeca82c11dad8fe | builder/digitalocean/artifact_test.go | builder/digitalocean/artifact_test.go | package digitalocean
import (
"testing"
"github.com/mitchellh/packer/packer"
)
func TestArtifact_Impl(t *testing.T) {
var raw interface{}
raw = &Artifact{}
if _, ok := raw.(packer.Artifact); !ok {
t.Fatalf("Artifact should be artifact")
}
}
func TestArtifactId(t *testing.T) {
a := &Artifact{"packer-foobar"... | package digitalocean
import (
"testing"
"github.com/mitchellh/packer/packer"
)
func TestArtifact_Impl(t *testing.T) {
var raw interface{}
raw = &Artifact{}
if _, ok := raw.(packer.Artifact); !ok {
t.Fatalf("Artifact should be artifact")
}
}
func TestArtifactId(t *testing.T) {
a := &Artifact{"packer-foobar"... | Change test to use something that looks like a real region code | Change test to use something that looks like a real region code
| Go | mpl-2.0 | esemplare/packer,tb3088/packer,tb3088/packer,tas50/packer,vtolstov/packer,arizvisa/packer,mayflower/packer,p1-nico/packer,jimmythedog/packer,grange74/packer,pecigonzalo/packer,markpeek/packer,mohae/packer,bhcleek/packer,mitchellh/packer,yoctocloud/packer,taliesins/packer,Akasurde/packer,taliesins/packer,grange74/packer... |
8a8d0404ce817ec490cf7995468ce5ffba8fc3ea | client.go | client.go | package livestatus
import (
"net"
)
const bufferSize = 1024
// Client represents a Livestatus client instance.
type Client struct {
network string
address string
dialer *net.Dialer
conn net.Conn
}
// NewClient creates a new Livestatus client instance.
func NewClient(network, address string) *Client {
retu... | package livestatus
import (
"net"
)
const bufferSize = 1024
// Client represents a Livestatus client instance.
type Client struct {
network string
address string
dialer *net.Dialer
conn net.Conn
}
// NewClient creates a new Livestatus client instance.
func NewClient(network, address string) *Client {
retu... | Add missing keepalive on TCP connection | Add missing keepalive on TCP connection
| Go | bsd-3-clause | vbatoufflet/go-livestatus |
2b58b1f68d60aaf8fb524551f4ce2e0d36c5656c | pkg/buildlog/db-migration.go | pkg/buildlog/db-migration.go | package buildlog
import (
"fmt"
"log"
"github.com/mattes/migrate"
"github.com/mattes/migrate/database/postgres"
_ "github.com/mattes/migrate/source/file"
)
type migrationLogger struct {
}
func (m migrationLogger) Verbose() bool {
return false
}
func (m migrationLogger) Printf(format string, v ...interface{})... | package buildlog
import (
"fmt"
"log"
"os"
"github.com/mattes/migrate"
"github.com/mattes/migrate/database/postgres"
_ "github.com/mattes/migrate/source/file"
)
type migrationLogger struct {
}
func (m migrationLogger) Verbose() bool {
return false
}
func (m migrationLogger) Printf(format string, v ...interf... | Allow DB migrations source path customization | Allow DB migrations source path customization
| Go | mit | fajran/buildlog |
6d8e70fb65d890ddd15fc09a8f89d40f2e71e005 | client.go | client.go | package ssh
import "os"
type C struct {
User string
Host string
HostKeyFun func([]byte)os.Error
PasswordFun func()string
}
func New(C C) (*Client,os.Error) {
c,e := connect(C.Host)
if e != nil { return nil,e }
writeKexInit(c)
b,e := readPacket(c)
c.skex = make([]byte, len(b))
copy(c.skex, b)
if e!=nil { ... | package ssh
import "os"
type C struct {
User string
Host string
HostKeyFun func([]byte)os.Error
PasswordFun func()(string,os.Error)
}
func New(C C) (*Client,os.Error) {
c,e := connect(C.Host)
if e != nil { return nil,e }
writeKexInit(c)
b,e := readPacket(c)
c.skex = make([]byte, len(b))
copy(c.skex, b)
i... | Allow PasswordFun to return an error | Allow PasswordFun to return an error
| Go | mit | albertjin/ssh |
9399611c4095a8c797c60f0ffae532d6baf7df18 | config.go | config.go | package config
import (
"encoding/json"
"github.com/snormore/gologger"
"io/ioutil"
)
type Config interface{}
func Register(name string, c Config) error {
return nil
}
type Configurable struct {
Config interface{}
}
func Read(filePath string, conf *Config) error {
logger.Info("Loading configuration from %s...... | package config
import (
"encoding/json"
"github.com/snormore/gologger"
"io/ioutil"
)
type Config interface{}
func Register(name string, c Config) error {
return nil
}
type Configurable struct {
Config interface{}
}
func Init(filePath string) (*Config, error) {
return Read(filePath)
}
func Read(filePath stri... | Refactor to return Config, error pair. | Refactor to return Config, error pair.
| Go | mit | snormore/goconfig |
8d453096f9be0c37094074e60365e96316c5d044 | cli/main.go | cli/main.go | package main
import (
"bufio"
"fmt"
"os"
"strings"
"github.com/katnegermis/pocketmine-rcon"
)
func main() {
if len(os.Args) < 2 {
fmt.Printf("Usage: ./rcon address password")
return
}
addr := os.Args[1]
pass := os.Args[2]
conn, err := rcon.NewConnection(addr, pass)
if err != nil {
fmt.Println(err)
... | package main
import (
"bufio"
"fmt"
"os"
"strings"
"github.com/katnegermis/pocketmine-rcon"
)
func main() {
if len(os.Args) < 2 {
fmt.Printf("Usage: ./rcon address password")
return
}
addr := os.Args[1]
pass := os.Args[2]
conn, err := rcon.NewConnection(addr, pass)
if err != nil {
fmt.Println(err)
... | Add trimsuffix to remove windows line endings | Add trimsuffix to remove windows line endings | Go | mit | katnegermis/pocketmine-rcon |
6de7d84e1bff2c16af9846929ab777e338e5fe54 | go/tracing/tracing.go | go/tracing/tracing.go | // Package tracing consolidates the setup logic for using opencensus tracing and exporting the
// metrics.
package tracing
import (
"time"
"contrib.go.opencensus.io/exporter/stackdriver"
"go.opencensus.io/trace"
"go.skia.org/infra/go/skerr"
)
// Initialize sets up trace options and exporting for this application... | // Package tracing consolidates the setup logic for using opencensus tracing and exporting the
// metrics to https://cloud.google.com/trace. In order to authenticate to the correct API, any
// service account that uses this package must have the Cloud Trace Agent Role in gcp.
package tracing
import (
"time"
"contri... | Add required service account permission to docs | [infra] Add required service account permission to docs
Change-Id: If0f6782d35bb50bafa55d0279e8506e0e06ab63f
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/480214
Auto-Submit: Kevin Lubick <7cdab2cfab351f23814786ba39716e90eed69047@google.com>
Reviewed-by: Joe Gregorio <b9cf2471ff6d33504cafe8e6f356b732b... | Go | bsd-3-clause | google/skia-buildbot,google/skia-buildbot,google/skia-buildbot,google/skia-buildbot,google/skia-buildbot,google/skia-buildbot,google/skia-buildbot,google/skia-buildbot |
d8cf7ed293a62e21229b7234eae227ebe2e6de39 | agent/config/parse_windows_test.go | agent/config/parse_windows_test.go | // +build windows,unit
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in... | // +build windows,unit
// Copyright Amazon.com Inc. or its affiliates. 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. A copy of the
// License is located at
//
// http://aws.amazon.com/apache2.0/
//
// or in... | Add a test for upper-to-lower conversion on parsing Windows env vars | Add a test for upper-to-lower conversion on parsing Windows env vars
| Go | apache-2.0 | kiranmeduri/amazon-ecs-agent,swipely/amazon-ecs-agent,swipely/amazon-ecs-agent,swipely/amazon-ecs-agent,aws/amazon-ecs-agent,aws/amazon-ecs-agent,kiranmeduri/amazon-ecs-agent,swipely/amazon-ecs-agent,kiranmeduri/amazon-ecs-agent,aws/amazon-ecs-agent,kiranmeduri/amazon-ecs-agent,aws/amazon-ecs-agent |
99e70cb75f5fa8e1911325373aeea57206fe8a71 | goslow.go | goslow.go | // goslow is a slow HTTP server that responds with errors.
// Visit https://github.com/alexandershov/goslow for more details.
package main
import (
"log"
)
// main starts a slow HTTP server that responds with errors.
func main() {
config := NewConfigFromArgs()
server := NewServer(config)
log.Fatal(server.ListenA... | // goslow is a slow HTTP server that responds with errors.
// Visit https://github.com/alexandershov/goslow for more details.
package main
import (
"log"
"runtime"
)
// main starts a slow HTTP server that responds with errors.
func main() {
// GOMAXPROCS call is ignored if NumCPU returns 1 (GOMAXPROCS(0) doesn't c... | Use half of available CPUs | Use half of available CPUs
Or 1 CPU if there is only one CPU in the system
| Go | mit | alexandershov/goslow,alexandershov/goslow |
c3023b6ea764579035f6953ae18c39f0abdd9e6d | system/version_dump_windows.go | system/version_dump_windows.go | package system
import (
"fmt"
"syscall"
"github.com/buildkite/agent/v3/logger"
)
func VersionDump(_ logger.Logger) (string, error) {
dll := syscall.MustLoadDLL("kernel32.dll")
p := dll.MustFindProc("GetVersion")
v, _, _ := p.Call()
return fmt.Sprintf("Windows version %d.%d (Build %d)\n", byte(v), uint8(v>>8)... | package system
import (
"fmt"
"github.com/buildkite/agent/v3/logger"
"golang.org/x/sys/windows"
)
func VersionDump(_ logger.Logger) (string, error) {
info := windows.RtlGetVersion()
return fmt.Sprintf("Windows version %d.%d (Build %d)\n", info.MajorVersion, info.MinorVersion, info.BuildNumber), nil
}
| Update the way we detect windows versions | Update the way we detect windows versions
While running the agent on Windows 10 I noticed we were submitting the
version as "Windows version 6.2", which maps to windows 8 [1].
According to MSDN, the GetVersion call we're using always reports
windows 8 for compatibility reasons[2]:
> GetVersion may be altered or unav... | Go | mit | buildkite/agent,buildkite/agent,buildkite/agent |
d9a0681b867c057686aab7540a575cb30e044b40 | comments/pending_feedback_label.go | comments/pending_feedback_label.go | package comments
import (
"log"
"os"
"github.com/google/go-github/github"
)
var (
pendingFeedbackLabel = "pending-feedback"
HandlerPendingFeedbackLabel = func(client *github.Client, event github.IssueCommentEvent) error {
// if the comment is from the issue author & issue has the "pending-feedback", remove t... | package comments
import (
"log"
"os"
"github.com/google/go-github/github"
)
var (
pendingFeedbackLabel = "pending-feedback"
HandlerPendingFeedbackLabel = func(client *github.Client, event github.IssueCommentEvent) error {
// if the comment is from the issue author & issue has the "pending-feedback", remove t... | Add label so we know where it came from | Add label so we know where it came from
| Go | bsd-3-clause | parkr/auto-reply |
7569c6b2ef7fbf64605494e8acafb95b66d07f50 | applier.go | applier.go | package raftor
import (
"github.com/coreos/etcd/raft/raftpb"
"golang.org/x/net/context"
)
// Applier applies either a snapshot or entries in a Commit object
type Applier interface {
// Apply processes commit messages after being processed by Raft
Apply() chan Commit
}
// Commit is used to send to the cluster to... | package raftor
import (
"time"
"github.com/coreos/etcd/raft"
"github.com/coreos/etcd/raft/raftpb"
"golang.org/x/net/context"
)
// Commit is used to send to the cluster to save either a snapshot or log entries.
type Commit struct {
State RaftState
Entries []raftpb.Entry
Snapshot raftpb.Snapshot
Messages [... | Add RaftState and []raftpb.Message to Commit struct | Add RaftState and []raftpb.Message to Commit struct
| Go | apache-2.0 | eliquious/raftor,blacklabeldata/raftor |
3a0124491f96b1b7155fced4355ef01f6acd88d3 | main.go | main.go | package main
import (
"flag"
"fmt"
"net/http"
"os"
)
const VERSION = "0.1.0"
var clientDir string
func init() {
clientEnv := os.Getenv("CLIENT")
flag.StringVar(&clientDir, "client", clientEnv, "the directory where the client data is stored")
}
func main() {
flag.Parse()
fmt.Printf("resolutionizerd %s start... | package main
import (
"flag"
"fmt"
"net/http"
"os"
"github.com/gorilla/handlers"
)
const VERSION = "0.1.0"
var clientDir string
func init() {
clientEnv := os.Getenv("CLIENT")
flag.StringVar(&clientDir, "client", clientEnv, "the directory where the client data is stored")
}
func main() {
flag.Parse()
fmt.P... | Add a logging wrapper around the file server. | Add a logging wrapper around the file server.
| Go | mpl-2.0 | smkell/resolutionizerd |
904296f68512d2055ae9fe79d2c1f2cddec645b7 | trie.go | trie.go | package kace
type node struct {
val rune
end bool
links []*node
}
func newNode() *node {
return &node{links: make([]*node, 0)}
}
func (n *node) add(rs []rune) {
cur := n
for _, v := range rs {
link := cur.linkByVal(v)
if link == nil {
link = newNode()
cur.links = append(cur.links, link)
}
cur... | package kace
type node struct {
val rune
end bool
links []*node
}
func newNode(val rune, isEnd bool) *node {
return &node{
val: val,
end: isEnd,
links: make([]*node, 0),
}
}
func (n *node) add(rs []rune) {
cur := n
for k, v := range rs {
isEnd := k == len(rs)-1
link := cur.linkByVal(v)
if... | Fix newNode assignments and find logic. | Fix newNode assignments and find logic.
| Go | mit | codemodus/kace |
9f28957fa9cc4b10ba294802b951d9842eab8e2c | zero.go | zero.go | package zero
import (
"fmt"
"github.com/tj/go-debug"
)
type Key string
type Args struct {
Key Key
Type string
Value interface{}
}
const (
String = "string"
Number = "number"
Array = "array"
)
const (
RowSplitter = "|"
ColumnSplitter = ","
)
var d = debug.Debug("zero")
var index = make(map[Key]s... | package zero
import (
"fmt"
"github.com/tj/go-debug"
)
type Key string
type Args struct {
Key Key
Type string
Value interface{}
}
const (
String = "string"
Number = "number"
Array = "array"
)
const (
RowSplitter = "|"
ColumnSplitter = ","
)
var d = debug.Debug("zero")
var index = make(map[Key]s... | Make error message a bit verbose | Make error message a bit verbose
| Go | mit | umayr/zero |
2157666ee3acb470292ac1c5fdaefbb907b5aea5 | list.go | list.go | package async
import (
"container/list"
"sync"
)
/*
Used to contain the Routine functions to be processed
This list inherits http://golang.org/pkg/container/list/ and contains all
of the functionality that it contains, with a minor tweak to Remove. Instead
of Remove returning the element, it returns our... | package async
import (
"container/list"
"sync"
)
/*
Used to contain the Routine functions to be processed
This list inherits https://godoc.org/container/list and contains all
of the functionality that it contains, with a minor tweak to Remove. Instead
of Remove returning the element, it returns our rout... | Replace golang.org link with godoc.org link | Replace golang.org link with godoc.org link
[skip ci]
| Go | mit | Southern/async |
242f6f7bdba47fa1c6f4bde2436c013ced8f2c8a | tidy.go | tidy.go | package main
import (
"io"
"io/ioutil"
"log"
"os"
"os/exec"
)
// Errors & warnings are deliberately suppressed as tidy throws warnings very easily
func Tidy(r io.Reader, xmlIn bool) ([]byte, error) {
f, err := ioutil.TempFile("/tmp", "sajari-convert-")
if err != nil {
log.Println("TempFile:", err)
return n... | package main
import (
"io"
"io/ioutil"
"os"
"os/exec"
)
// Errors & warnings are deliberately suppressed as tidy throws warnings very easily
func Tidy(r io.Reader, xmlIn bool) ([]byte, error) {
f, err := ioutil.TempFile("/tmp", "sajari-convert-")
if err != nil {
return nil, err
}
defer os.Remove(f.Name())
... | Remove unnecessary log from Tidy. | Remove unnecessary log from Tidy. | Go | mit | sajari/docconv,sajari/docconv,nuveo/docconv,poorny/docconv |
5a603ff6d0f49fff48fbcde6cee982e05a80b9ed | models.go | models.go | package campbx
// Ticker
//
// Sample response
//
// {"Last Trade":"244.99","Best Bid":"236.38","Best Ask":"244.99"}
type Ticker struct {
LastTrade float32 `json:"Last Trade,string"`
Bid float32 `json:"Best Bid,string"`
Ask float32 `json:"Best Ask,string"`
}
// OrderBook represents the full order b... | package campbx
// Ticker
//
// Sample response
//
// {"Last Trade":"244.99","Best Bid":"236.38","Best Ask":"244.99"}
type Ticker struct {
LastTrade float32 `json:"Last Trade,string"`
Bid float32 `json:"Best Bid,string"`
Ask float32 `json:"Best Ask,string"`
}
// OrderBook represents the full order b... | Add JSON struct tags to Order. | Add JSON struct tags to Order. | Go | mit | scottjbarr/campbx |
fdc24bdec520bdf017881e1144d9a933c2792981 | cf/user_test.go | cf/user_test.go | package cf_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/pivotal-cf-experimental/cf-test-helpers/cf"
)
var _ = Describe("NewUserContext", func() {
var createUser = func() cf.UserContext {
return cf.NewUserContext("http://FAKE_API.example.com", "FAKE_USERNAME", "FAKE_PASSWORD"... | package cf_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/pivotal-cf-experimental/cf-test-helpers/cf"
)
var _ = Describe("NewUserContext", func() {
var createUser = func() cf.UserContext {
return cf.NewUserContext("http://FAKE_API.example.com", "FAKE_USERNAME", "FAKE_PASSWORD"... | Fix spec descriptions Fix spec descriptions to match property names | Fix spec descriptions
Fix spec descriptions to match property names
| Go | apache-2.0 | cloudfoundry-incubator/cf-test-helpers,nttlabs/cf-test-helpers,cloudfoundry-incubator/cf-test-helpers,nttlabs/cf-test-helpers |
a11816a3bebe99ca4cc82e68739ed3640c9242ae | sample.go | sample.go | package waldo
import "math"
// Sample represents data drawn from some distribution. To compute
// the Wald statistics we need to have a point estimator function
// (e.g., the maximum likelihood estimator (MLE))
// as well as the sampling distribution's variance. Recall
// that the sampling distribution is defined a... | package waldo
import "math"
// Sample represents data drawn from some distribution. To compute
// the Wald statistics we need to have a point estimator function
// (e.g., the maximum likelihood estimator (MLE))
// as well as the sampling distribution's variance. Recall
// that the sampling distribution is defined a... | Add comments about asymptotic normality. | Add comments about asymptotic normality.
| Go | mit | shawnohare/waldo |
8ac5d53b83dce1e21f76c5604247cd76faeeb3a1 | context.go | context.go | package instana
// SpanContext holds the basic Span metadata.
type SpanContext struct {
// A probabilistically unique identifier for a [multi-span] trace.
TraceID uint64
// A probabilistically unique identifier for a span.
SpanID uint64
// Whether the trace is sampled.
Sampled bool
// The span's associated b... | package instana
// SpanContext holds the basic Span metadata.
type SpanContext struct {
// A probabilistically unique identifier for a [multi-span] trace.
TraceID int64
// A probabilistically unique identifier for a span.
SpanID int64
// Whether the trace is sampled.
Sampled bool
// The span's associated bag... | Store IDs as signed integers | Store IDs as signed integers
| Go | mit | instana/golang-sensor,instana/golang-sensor |
88624c01ec7a80b1b34a9b6334a5087fc5a18022 | db.go | db.go | package sqlstmt
import (
"database/sql"
)
// DB is the interface that wraps the database access methods
// used by this package.
//
// The *DB and *Tx types in the standard library package "database/sql"
// both implement this interface.
type DB interface {
// Exec executes a query without returning any rows.
// T... | package sqlstmt
import (
"database/sql"
)
// DB is the interface that wraps the database access methods
// used by this package.
//
// The *DB and *Tx types in the standard library package "database/sql"
// both implement this interface.
type DB interface {
// Exec executes a query without returning any rows.
// T... | Reformat SQLLogger comments to fit in godoc HTML page. | Reformat SQLLogger comments to fit in godoc HTML page.
| Go | mit | jjeffery/sqlr,jjeffery/sqlrow,jjeffery/sqlr |
92e39cdb0505fd8edffd2491a0c913f16a64fb63 | go/010_test.go | go/010_test.go | package main
import (
"testing"
)
func sumOfPrimesBelow(x int) int {
sieve := make([]bool, x)
for i:=0; i<x; i++ {
sieve[i] = true
}
sieve[0] = false
sieve[1] = false
for i:=2; i<x; i++ {
if sieve[i] == false {
continue
}
for j:=2*i; j<x; j+=i {
sieve[j] = false
}
}
sum := 0
for i:=2; i... | package main
import (
"testing"
)
func sumOfPrimesBelow(x int) int {
sieve := make([]bool, x)
for i:=0; i<x; i++ {
sieve[i] = true
}
sieve[0] = false
sieve[1] = false
for i:=2; i<x; i++ {
if sieve[i] == false {
continue
}
for j:=2*i; j<x; j+=i {
sieve[j] = false
}
}
sum := 0
for i:=2; i... | Add benchmarking code to Prob 10 | Add benchmarking code to Prob 10
| Go | bsd-2-clause | jmalonzo/project-euler-solutions,jmalonzo/project-euler-solutions |
c93ce07adc6c14cb169a02ca1a0fa03fa2949b72 | dom/rpcd/api.go | dom/rpcd/api.go | package rpcd
import (
"github.com/Symantec/Dominator/dom/herd"
"github.com/Symantec/Dominator/lib/srpc"
"log"
)
type rpcType struct {
herd *herd.Herd
logger *log.Logger
}
func Setup(herd *herd.Herd, logger *log.Logger) {
rpcObj := &rpcType{
herd: herd,
logger: logger}
srpc.RegisterName("Dominator", rp... | package rpcd
import (
"github.com/Symantec/Dominator/dom/herd"
"github.com/Symantec/Dominator/lib/log"
"github.com/Symantec/Dominator/lib/srpc"
)
type rpcType struct {
herd *herd.Herd
logger log.Logger
}
func Setup(herd *herd.Herd, logger log.Logger) {
rpcObj := &rpcType{
herd: herd,
logger: logger}
s... | Change dom/rpcd.Setup() to use log.Logger interface type. | Change dom/rpcd.Setup() to use log.Logger interface type.
| Go | apache-2.0 | rgooch/Dominator,rgooch/Dominator,rgooch/Dominator,Symantec/Dominator,keep94/Dominator,Symantec/Dominator,keep94/Dominator,Symantec/Dominator,keep94/Dominator |
f0005d4d30923ce6c583c6af2dd990134fb3d826 | unsafe.go | unsafe.go | package bbolt
import "unsafe"
func unsafeAdd(base unsafe.Pointer, offset uintptr) unsafe.Pointer {
return unsafe.Pointer(uintptr(base) + offset)
}
func unsafeIndex(base unsafe.Pointer, offset uintptr, elemsz uintptr, n int) unsafe.Pointer {
return unsafe.Pointer(uintptr(base) + offset + uintptr(n)*elemsz)
}
func ... | package bbolt
import "unsafe"
func unsafeAdd(base unsafe.Pointer, offset uintptr) unsafe.Pointer {
return unsafe.Pointer(uintptr(base) + offset)
}
func unsafeIndex(base unsafe.Pointer, offset uintptr, elemsz uintptr, n int) unsafe.Pointer {
return unsafe.Pointer(uintptr(base) + offset + uintptr(n)*elemsz)
}
func ... | Comment the byte slice conversion | Comment the byte slice conversion
| Go | mit | etcd-io/bbolt |
5bc6df835b7965590773feafa66145e319b0ec00 | integration_tests/connection_test.go | integration_tests/connection_test.go | package integration_tests
import (
"testing"
)
func TestConnection(t *testing.T) {
listen := NewNodeBinary(BinaryOptions{Listen: "[::1]:9999", Fake_money: true})
listen.Start()
defer listen.KillAndPrint(t)
listen_id, err := WaitForID(listen)
if err != nil {
t.Fatal(err)
}
connect := NewNodeBinary(BinaryOpt... | package integration_tests
import (
"testing"
)
func TestConnection(t *testing.T) {
listen := NewNodeBinary(BinaryOptions{Listen: "[::1]:9999", Fake_money: true})
listen.Start()
defer listen.KillAndPrint(t)
listen_id, err := WaitForID(listen)
if err != nil {
t.Fatal(err)
}
connect := NewNodeBinary(BinaryOpt... | Check an error that was being ignored. | Check an error that was being ignored.
| Go | mit | AutoRoute/node,AutoRoute/node |
2acac8e55d79e767c3df488810e18277f57cc485 | fluxctl/main.go | fluxctl/main.go | package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/squaremo/flux/common/store"
"github.com/squaremo/flux/common/store/etcdstore"
)
func main() {
store := etcdstore.NewFromEnv()
var topCmd = &cobra.Command{
Use: "fluxctl",
Short: "control flux",
Long: `Define services and enrol ins... | package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/squaremo/flux/common/store"
"github.com/squaremo/flux/common/store/etcdstore"
)
func main() {
store := etcdstore.NewFromEnv()
var topCmd = &cobra.Command{
Use: "fluxctl",
Short: "control flux",
Long: `Define services and enrol ins... | Print a newline after an error message | Print a newline after an error message
| Go | apache-2.0 | squaremo/ambergreen,squaremo/ambergreen,squaremo/ambergreen,squaremo/ambergreen,squaremo/ambergreen |
29d8ca3ebf8d44abb635c036444928563ee523da | routes.go | routes.go | package main
import (
"net/http"
)
type ResponseWriter interface {
Header() http.Header
Write([]byte) (int, error)
WriteHeader(int)
}
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
}
type Routes []Route
var routes = Routes{
Route{
"Index",
"GE... | package main
import (
"net/http"
)
type ResponseWriter interface {
Header() http.Header
Write([]byte) (int, error)
WriteHeader(int)
}
type Route struct {
Name string
Method string
Pattern string
HandlerFunc http.HandlerFunc
}
type Routes []Route
var routes = Routes{
Route{
"Index",
"GE... | Add route for updating a post | Add route for updating a post
| Go | mit | nicholasrucci/blog,nicholasrucci/blog,nicholasrucci/blog |
afda42f09dd7f2a65c1cfb0d55efd8e207c7030f | lib/delayed_unlock/delayed_unlock.go | lib/delayed_unlock/delayed_unlock.go | package delayed_unlock
import "sync"
type Unlockable interface {
Unlock()
}
// Delay unlocking some interface for a number of steps.
type DelayedUnlockable struct {
sync.Mutex
toUnlock Unlockable
steps int
}
func New(u Unlockable) *DelayedUnlockable {
return &DelayedUnlockable{
toUnlock: u,
steps: 1,... | package delayed_unlock
import "sync"
type Unlockable interface {
Unlock()
}
type DelayedUnlockable interface {
Unlockable
IncSteps()
Go(f func())
}
// Delay unlocking some interface for a number of steps.
type delayedUnlockable struct {
inner sync.Mutex
toUnlock Unlockable
steps int
}
func New(u Unlo... | Remove concurrency bug from DelayedLock | Remove concurrency bug from DelayedLock
| Go | bsd-3-clause | weaviate/weaviate,weaviate/weaviate |
b4d2cd469a8cfa945d9fdfd5e882af4164010209 | web/forms/login_form.go | web/forms/login_form.go | package forms
import (
"bones/entities"
"bones/repositories"
"bones/validation"
"code.google.com/p/go.crypto/bcrypt"
"errors"
"net/http"
)
var LoginFailedError = errors.New("Login failed")
type LoginForm struct {
Request *http.Request `schema:"-"`
User *entities.User `schema:"-"`
Email string ... | package forms
import (
"bones/entities"
"bones/repositories"
"bones/validation"
"code.google.com/p/go.crypto/bcrypt"
"errors"
"net/http"
)
var LoginFailedError = errors.New("Login failed")
type LoginForm struct {
Request *http.Request `schema:"-"`
User *entities.User `schema:"-"`
Email string ... | Use LoginFailedError if password != hash | Use LoginFailedError if password != hash | Go | mit | peterskeide/bones |
e2b7dc6c6d85c3478d95814a4c712657c32d8f5b | leetcode/409_longest_palindrome.go | leetcode/409_longest_palindrome.go | package leetcode
// 409. Longest Palindrome
func longestPalindrome(s string) int {
bytes := make(map[byte]int, 0)
for i := 0; i < len(s); i++ {
b := s[i]
count := bytes[b]
bytes[b] = count + 1
}
res := 0
hasPrime := false
for _, count := range bytes {
x, y := count/2, count%2
res += x * 2
if y == 1 ... | package leetcode
// 409. Longest Palindrome
func longestPalindrome(s string) int {
bytes := make(map[byte]int, 0)
count := 0
for i := 0; i < len(s); i++ {
b := s[i]
_, ok := bytes[b]
if ok {
count++
delete(bytes, b)
} else {
bytes[b] = 1
}
}
if len(bytes) > 0 {
return count*2 + 1
}
return c... | Fix 409. Longest Palindrome to use single loop | Fix 409. Longest Palindrome to use single loop
| Go | mit | motomux/go-algo |
974e6e0bc9a1e5b6b8209febf3c9965c4f1f9ddd | jobsupervisor/monitor/stats_collector_test.go | jobsupervisor/monitor/stats_collector_test.go | package monitor
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Stats collector", func() {
FContext("when calculating CPU usage", func() {
It("should correctly format it for usage by stats.CPUStats", func() {
m := &Monitor{
user: CPUTime{load: 0.25},
kernel: CPUTim... | package monitor
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Stats collector", func() {
Context("when calculating CPU usage", func() {
It("should correctly format it for usage by stats.CPUStats", func() {
m := &Monitor{
user: CPUTime{load: 0.25},
kernel: CPUTime... | Remove programmatic focus from monitor tests | Remove programmatic focus from monitor tests
Signed-off-by: Charlie Vieth <ea3f0b85bda195c42ceb97da0f596f9d6d014e12@pivotal.io>
| Go | apache-2.0 | cloudfoundry/bosh-agent,gu-bin/bosh-agent,mattcui/bosh-agent,mattcui/bosh-agent,mattcui/bosh-agent,gu-bin/bosh-agent,gu-bin/bosh-agent,cloudfoundry/bosh-agent |
58759737673c35a11a89730e80a711ee87bf19e6 | lib/log/api.go | lib/log/api.go | package log
type Logger interface {
Fatal(v ...interface{})
Fatalf(format string, v ...interface{})
Fatalln(v ...interface{})
Panic(v ...interface{})
Panicf(format string, v ...interface{})
Panicln(v ...interface{})
Print(v ...interface{})
Printf(format string, v ...interface{})
Println(v ...interface{})
}
t... | package log
type Logger interface {
Fatal(v ...interface{})
Fatalf(format string, v ...interface{})
Fatalln(v ...interface{})
Panic(v ...interface{})
Panicf(format string, v ...interface{})
Panicln(v ...interface{})
Print(v ...interface{})
Printf(format string, v ...interface{})
Println(v ...interface{})
}
t... | Split out SetLevel method from lib/log.DebugLogger interface. | Split out SetLevel method from lib/log.DebugLogger interface.
| Go | apache-2.0 | rgooch/Dominator,rgooch/Dominator,Symantec/Dominator,Symantec/Dominator,rgooch/Dominator,keep94/Dominator,Symantec/Dominator,keep94/Dominator,keep94/Dominator |
2a09bb753794125e929014cf08c431faefeeec32 | p2p/net/reuseport/reuseport_plan9.go | p2p/net/reuseport/reuseport_plan9.go | package tcpreuse
import (
"net"
"os"
)
// reuseErrShouldRetry diagnoses whether to retry after a reuse error.
// if we failed to bind, we should retry. if bind worked and this is a
// real dial error (remote end didnt answer) then we should not retry.
func reuseErrShouldRetry(err error) bool {
if err == nil {
re... | package tcpreuse
import (
"net"
"os"
)
const (
EADDRINUSE = "address in use"
ECONNREFUSED = "connection refused"
)
// reuseErrShouldRetry diagnoses whether to retry after a reuse error.
// if we failed to bind, we should retry. if bind worked and this is a
// real dial error (remote end didnt answer) then we s... | Update go-netroute and go-reuseport for Plan 9 support | Update go-netroute and go-reuseport for Plan 9 support
| Go | mit | libp2p/go-libp2p,libp2p/go-libp2p,ipfs/go-libp2p |
0d60b633c02961e039aea18b2358960fefeee77b | gnotifier_darwin.go | gnotifier_darwin.go | package gnotifier
import (
"github.com/deckarep/gosx-notifier"
)
func (n *notifier) Push() error {
err := n.IsValid()
if err != nil {
return err
}
notification := gosxnotifier.NewNotification(n.Config.Message)
notification.Title = n.Config.Title
err := note.Push()
return err
}
| package gnotifier
import (
"github.com/deckarep/gosx-notifier"
)
func (n *notifier) Push() error {
err := n.IsValid()
if err != nil {
return err
}
notification := gosxnotifier.NewNotification(n.Config.Message)
notification.Title = n.Config.Title
err = notification.Push()
return err
}
| Fix syntax on Darwin build | Fix syntax on Darwin build
| Go | mit | haklop/gnotifier |
21ffbc825cf7944a91de77d0ffc4c3967130c6f3 | pluto.go | pluto.go | package main
import (
"fmt"
"os"
"github.com/Zac-Garby/pluto/bytecode"
"github.com/Zac-Garby/pluto/compiler"
"github.com/Zac-Garby/pluto/parser"
"github.com/Zac-Garby/pluto/vm"
)
func main() {
compiler := compiler.New()
p := parser.New("a = 5; a")
program := p.Parse()
if len(p.Errors) > 0 {
p.PrintErro... | package main
import (
"fmt"
"os"
"github.com/Zac-Garby/pluto/bytecode"
"github.com/Zac-Garby/pluto/compiler"
"github.com/Zac-Garby/pluto/parser"
"github.com/Zac-Garby/pluto/vm"
)
func main() {
compiler := compiler.New()
p := parser.New(`
a = 5
a
`)
program := p.Parse()
if len(p.Errors) > 0 {
p.PrintE... | Make input string a multiline string | Make input string a multiline string
| Go | mit | pluto-language/pluto |
47a8312fc27481fac011087ba7f66c92521a17aa | str/case.go | str/case.go | package str
import "unicode"
// ToSnake converts a string (camel or spinal) to snake case
func ToSnake(str string) string {
// Skip processing for an empty string
if len(str) == 0 {
return ""
}
// Build the results in this buffer
buf := ""
// Trick: if the first character is uppercase, do not prepend an und... | package str
import (
"unicode"
"unicode/utf8"
)
// ToSnake converts a string (camel or spinal) to snake case
func ToSnake(str string) string {
// Skip processing for an empty string
if len(str) == 0 {
return ""
}
// Build the results in this buffer
buf := ""
// Trick: if the first character is uppercase, ... | Use utf8 rune decoding instead | Use utf8 rune decoding instead
| Go | mit | sagikazarmark/utilz,goph/stdlib |
42c99dbd26bedab9ce355d5cbd82fa333eb8ac88 | serve.go | serve.go | package serve
import (
"net"
"net/http"
"log"
"os"
"os/signal"
)
func Serve(port, socket string, handler http.Handler) {
if socket == "" {
Port(port, handler)
} else {
Socket(socket, handler)
}
}
func Socket(socket string, handler http.Handler) {
l, err := net.Listen("unix", socket)
if err != nil {
l... | package serve
import (
"log"
"net"
"net/http"
"os"
"os/signal"
)
func Serve(port, socket string, handler http.Handler) {
if socket == "" {
Port(port, handler)
} else {
Socket(socket, handler)
}
}
func Socket(socket string, handler http.Handler) {
l, err := net.Listen("unix", socket)
if err != nil {
l... | Replace log.Fatal usages with Println then return | Replace log.Fatal usages with Println then return
| Go | mit | hawx/serve |
6ac30ee2cd5a90deb758414fbecd983dca6d827f | models/Specifics.go | models/Specifics.go | package models
type Specifics struct {
PhotoUrl string `json:"photoUrl"`
ImageId string `json:"imageId"`
ImageLevel string `json:"imageLevel"`
Email string `json:"email"`
EmailLevel string `json:"emailLevel"`
Phone string `json:"phone"`
PhoneLevel string `json:"phoneLevel"`
}
func (s Specifics) ... | package models
type Specifics struct {
PhotoUrl string `json:"photoUrl"`
ImageId string `json:"imageId"`
ImageLevel string `json:"imageLevel"`
Email string `json:"email"`
EmailLevel string `json:"emailLevel"`
Phone string `json:"phone"`
PhoneLevel string `json:"phoneLevel"`
Id int `js... | Fix problem with missing email addresses. | Fix problem with missing email addresses.
| Go | mit | boushley/lds-picture-directory-stats |
efc6ca4c47791eb239bb813718fa3470d99606fe | version/version.go | version/version.go | /*
Copyright The containerd 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... | /*
Copyright The containerd 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... | Prepare release notes for v1.6.0-rc.3 | Prepare release notes for v1.6.0-rc.3
Signed-off-by: Derek McGowan <e1c79a582b6629e6b39e9679f4bb964d25db4aa8@mcg.dev>
| Go | apache-2.0 | containerd/containerd,estesp/containerd,dmcgowan/containerd,mikebrow/containerd,mikebrow/containerd,containerd/containerd,thaJeztah/containerd,thaJeztah/containerd,estesp/containerd,dmcgowan/containerd |
17a8b0428f68b5d38bb6539ab5f4d2f95ed5e77a | pokemon.go | pokemon.go | package main
import (
"time"
"fmt"
)
type Pokemon struct {
ID int
ExpiresAt time.Time
PokedexID int
Latitude float64
Longitude float64
}
func (p *Pokemon) UID() string {
return fmt.Sprintf("%v-%v-%v-%v", p.ExpiresAt, p.PokedexID, p.Latitude, p.Longitude)
}
func (p *Pokemon) IsVisible() bool {
retur... | package main
import (
"time"
"fmt"
)
type Pokemon struct {
ID int
ExpiresAt time.Time
PokedexID int
Latitude float64
Longitude float64
}
func (p *Pokemon) UID() string {
return fmt.Sprintf("%v-%v-%v", p.PokedexID, p.Latitude, p.Longitude)
}
func (p *Pokemon) IsVisible() bool {
return p.ExpiresAt.Af... | Fix another duplicate Pokémon issue | Fix another duplicate Pokémon issue
Sometimes the API will return multiple of the exact same Pokémon but with slightly varying expiration times. Sometimes one second incrementing differences.
If there are two Pokémon located at the exact same coordinate, it’s best you only get notified once anyway.
| Go | mit | jacobmarshall/pokevision-cli,jacobmarshall/pokevision-cli |
2075e1135d26353bbf09c2f9e2244bf7b4288e42 | qpx/qpx.go | qpx/qpx.go | package qpx
import (
"bytes"
"encoding/json"
"io"
"net/http"
)
func Cheapest(origin, destination, date string) (to tripOption, err error) {
var (
res *http.Response
f io.WriteCloser
resp response
buf = bytes.NewBuffer(nil)
)
payload := newRequest(origin, destination, date)
if f, err = logfile()... | package qpx
import (
"bytes"
"encoding/json"
"io"
"net/http"
"os"
)
func Cheapest(origin, destination, date string) (to tripOption, err error) {
var (
res *http.Response
f io.WriteCloser
resp response
buf = bytes.NewBuffer(nil)
)
payload := newRequest(origin, destination, date)
if f, err = log... | Fix bug that closes stdout | Fix bug that closes stdout
| Go | mit | programminh/wright,programminh/wright,programminh/wright |
f6a645f1d721d90915089897e41320d9befbf0a7 | pkg/datapath/endpoint.go | pkg/datapath/endpoint.go | // Copyright 2019 Authors of Cilium
//
// 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 ... | // Copyright 2019 Authors of Cilium
//
// 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 ... | Remove duplicated IsHost from Endpoint | datapath: Remove duplicated IsHost from Endpoint
IsHost is also defined in CompileTimeConfiguration which is embeded in
Endpoint. Remove it to reduce confusion.
Signed-off-by: Yongkun Gui <796c5d06a15acadd68e059e4eec1375f94c5cfd7@google.com>
| Go | apache-2.0 | michi-covalent/cilium,tklauser/cilium,tgraf/cilium,tklauser/cilium,cilium/cilium,michi-covalent/cilium,cilium-team/cilium,cilium/cilium,michi-covalent/cilium,cilium-team/cilium,cilium/cilium,tgraf/cilium,tgraf/cilium,tgraf/cilium,cilium/cilium,tgraf/cilium,michi-covalent/cilium,cilium/cilium,michi-covalent/cilium,tklau... |
402bdefab3da4b3396ed7f97c8b097cbad0da957 | commands/command_base.go | commands/command_base.go | package commands
import (
"github.com/centurylinkcloud/clc-go-cli/base"
)
type CommandBase struct {
Input interface{}
Output interface{}
ExcInfo CommandExcInfo
}
type CommandExcInfo struct {
Verb string
Url string
Resource string
Command string
}
func (c *CommandBase) Execute(cn base.Connection... | package commands
import (
"github.com/centurylinkcloud/clc-go-cli/base"
)
type CommandBase struct {
Input interface{}
Output interface{}
ExcInfo CommandExcInfo
}
type CommandExcInfo struct {
Verb string
Url string
Resource string
Command string
Help string
}
func (c *CommandBase) Execute(c... | Store the command help information in the ExcInfo field | Store the command help information in the ExcInfo field
| Go | apache-2.0 | CenturyLinkCloud/clc-go-cli,CenturyLinkCloud/clc-go-cli |
fed5729677ac8fcee1213c4c0f680f935364de43 | doc.go | doc.go | /*
Copyright 2014 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, ... | /*
Copyright 2014 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, ... | Use Go canonical import paths | Use Go canonical import paths
Add canonical imports only in existing doc.go files.
https://golang.org/doc/go1.4#canonicalimports
Fixes #29014
| Go | apache-2.0 | mengqiy/utils,kubernetes/utils,kubernetes/utils |
5592f35b18607a379c98e5dbf2678716131da87f | doc.go | doc.go | /*
This module is experimental and incomplete. Please be careful.
The archive module provides a few `paul.tag/go/debian` compatable bindings
to read and write Debian apt archives.
*/
package archive
| /*
This module is experimental and incomplete. Please be careful.
The archive module provides a few `pault.ag/go/debian` compatable bindings
to read and write Debian apt archives.
*/
package archive
| Fix "paul.tag" typo (should be "pault.ag") | Fix "paul.tag" typo (should be "pault.ag") | Go | mit | paultag/go-archive |
b2b32d23a07a1037bc766e704a5135346eb454eb | twitter_user.go | twitter_user.go | package anaconda
type TwitterUser struct {
Statuses_count *float64
Contributors_enabled *bool
Friends_count *float64
Geo_enabled *bool
Description *string
Profile_sidebar_border_color *string
Screen_name ... | package anaconda
type TwitterUser struct {
Statuses_count *int64
Contributors_enabled *bool
Friends_count *int64
Geo_enabled *bool
Description *string
Profile_sidebar_border_color *string
Screen_name ... | Convert float64s to int64s (this is a breaking change) | Convert float64s to int64s (this is a breaking change)
* They should never have been floating point numbers to begin with
| Go | mit | Fe4nn0r/anaconda,logashoff/anaconda,ifross89/anaconda,cgag/anaconda,jeffk/anaconda,jmptrader/anaconda,azr/anaconda,aatishnn/anaconda,josephyzhou/anaconda,rfsbraz/anaconda,amit-lulla/twitterapi,intfrr/anaconda,140proof/anaconda,rendon/anaconda |
61f9a44dfce254d35442b81786818c01fbecbe53 | main.go | main.go | package main
import (
"fmt"
. "github.com/nerdzeu/nerdz-api/orm"
)
func main() {
// http handler functions
}
| package main
import (
"fmt"
"github.com/nerdzeu/nerdz-api/nerdz"
)
func main() {
// http handler functions
}
| Update old namespace to the new one | Update old namespace to the new one
| Go | agpl-3.0 | nerdzeu/nerdz-api,nerdzeu/nerdz-api |
f0adb6d869f489b229e3e26c3a78ea146cf80dad | server_test.go | server_test.go | package main
import (
"github.com/labstack/echo"
"github.com/stretchr/testify/assert"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path"
"testing"
)
func TestGet(t *testing.T) {
// Setup
conf := Configuration{
Server: struct {
Port int
}{
1234,
},
Storage: struct {
Directory string
}{... | package main
import (
"github.com/labstack/echo"
"github.com/stretchr/testify/assert"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"path"
"testing"
)
var conf = Configuration{
Server: struct {
Port int
}{
1234,
},
Storage: struct {
Directory string
}{
"testdata",
},
}
func TestGet(t *testing... | Set test configuration to global variable | Set test configuration to global variable
| Go | mit | photoshelf/photoshelf-storage |
c6bcbc5be92ee26356dc5f2f0b2747c3899b7fef | subvert.go | subvert.go | package main
import (
"regexp"
)
func newMatcher(pat string) (*regexp.Regexp, error) {
return regexp.Compile(pat)
}
| package main
import (
"regexp"
"strings"
)
func newMatcher(pat string) (*regexp.Regexp, error) {
sp := strings.Split(pat, ",")
pat2 := "(" + strings.Join(sp, "|") + ")"
return regexp.Compile(pat2)
}
| Implement branch matcher as fake | Implement branch matcher as fake
| Go | mit | kusabashira/msub |
50c9ea44bcb8267a49b68e53cfe2184a1f2b5462 | src/go/main.go | src/go/main.go | package main
import "os"
import "fmt"
func main(){
args := os.Args[1:]
fmt.Println(args[0])
} | package main
import "os"
import "fmt"
import "bufio"
func main(){
args := os.Args[1:]
if len(args) == 1 {
fmt.Println(args[0])
} else {
fmt.Println("No args")
}
fmt.Println("Input something: ")
reader := bufio.NewReader(os.Stdin)
input, _, _ := reader.ReadLine()
fmt.P... | Test go args and input | Test go args and input
| Go | mit | Bigsby/matrix.sum,Bigsby/matrix.sum,Bigsby/matrix.sum,Bigsby/matrix.sum,Bigsby/matrix.sum,Bigsby/matrix.sum,Bigsby/matrix.sum,Bigsby/matrix.sum,Bigsby/matrix.sum,Bigsby/matrix.sum,Bigsby/matrix.sum |
b49c32531fc865f99f7a6dda6b3e497ae31e1244 | measurements_test.go | measurements_test.go | package atlas
import (
"testing"
)
func TestCheckType(t *testing.T) {
d := Definition{Type: "foo"}
test := checkType(d)
if test != false {
t.Errorf("type is invalid: %s", d.Type)
}
d = Definition{Type: "dns"}
test = checkType(d)
if test != true {
t.Errorf("type is invalid: %s", d.Type)
}
}
func TestDN... | package atlas
import (
"testing"
)
func TestCheckType(t *testing.T) {
d := Definition{Type: "foo"}
test := checkType(d)
if test != false {
t.Errorf("type is invalid: %s", d.Type)
}
d = Definition{Type: "dns"}
test = checkType(d)
if test != true {
t.Errorf("type is invalid: %s", d.Type)
}
}
func TestCh... | Add tests for checkTypeAs() & the main methods. | Add tests for checkTypeAs() & the main methods.
| Go | mit | keltia/ripe-atlas |
54d576b46c1872dbf913373397a70529ca1eef22 | solutions/go/trinary/trinary.go | solutions/go/trinary/trinary.go | // Package trinary implements a function for converting a trinary number to a decimal number.
package trinary
import "fmt"
const testVersion = 1
// ParseTrinary converts a trinary number to a decimal number.
// If the input contains invalid characters or overflows int64 an error is returned.
func ParseTrinary(input ... | // Package trinary implements a function for converting a trinary number to a decimal number.
package trinary
import "fmt"
const testVersion = 1
// ParseTrinary converts a trinary number to a decimal number.
// If the input contains invalid characters or overflows int64 an error is returned.
func ParseTrinary(input ... | Add solutions for go problems | Add solutions for go problems
| Go | mit | DanShu93/exercism |
71090408d2fec35bdd4f35a0c3155262c8fd205b | wats/output_volume_test.go | wats/output_volume_test.go | package wats
import (
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
)
var _ = Describe("An application printing a bunch of output", func() {
Befo... | package wats
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
)
var _ = Describe("An application printing a bunch of output", func() {
BeforeEach(fu... | Change logspew nora back to 2g of memory | Change logspew nora back to 2g of memory
Seems to take longer to respond with only 1g, which sometimes causes a
gateway timeout
Signed-off-by: David Morhovich <1d2e5394c2c3adc275fab845f5e23fc4a9634ec0@pivotal.io>
| Go | apache-2.0 | cloudfoundry-incubator/wats,cloudfoundry/wats,cloudfoundry-incubator/wats,cloudfoundry-incubator/wats,cloudfoundry/wats,cloudfoundry-incubator/wats,cloudfoundry-incubator/wats,cloudfoundry/wats,cloudfoundry/wats,cloudfoundry/wats |
95e5097483c747ae9126d7533fa250ade1310a65 | ncm.go | ncm.go | package gosolar
import "fmt"
// RemoveNCMNodes is now even more awesome.
func (c *Client) RemoveNCMNodes(guids []string) error {
req, endpoint := getRemoveNCMNodesRequest(guids)
_, err := c.post(endpoint, req)
if err != nil {
return fmt.Errorf("failed to remove the NCM nodes %v", err)
}
return nil
}
// Remo... | package gosolar
import "fmt"
// RemoveNCMNodes is now even more awesome.
func (c *Client) RemoveNCMNodes(guids []string) error {
endpoint := "Invoke/Cirrus.Nodes/RemoveNodes"
req := [][]string{guids}
_, err := c.post(endpoint, req)
if err != nil {
return fmt.Errorf("failed to remove the NCM nodes %v", err)
}... | Remove const and function creating request | Remove const and function creating request
| Go | apache-2.0 | mrxinu/gosolar |
67b7e2a95d4a9e239dd97be13a1c9a06a275478b | command.go | command.go | package sirius
import "strings"
const prefix = `!`
type Command struct {
Name string
Args []string
}
func (m *Message) Command(name string) (*Command, bool) {
cmd := prefix + name
if strings.HasPrefix(m.Text, cmd) {
var args []string
inv := strings.Split(m.Text, " ")
if len(inv) >= 2 {
args = append(... | package sirius
import "strings"
const prefix = `!`
type Command struct {
Name string
Args []string
}
// Arg returns argument number a, or nil if there is no argument in that
// position.
func (c *Command) Arg(a int) string {
if len(c.Args) > a {
return c.Args[a]
}
return ""
}
func (m *Message) Command(name... | Return empty string instead of nil pointer | Return empty string instead of nil pointer
| Go | mit | kayex/sirius |
b3102f16304663d3cac02944159da3e85c68b1b7 | internal/gps/_testdata/src/dotgodir/.go/dot.go | internal/gps/_testdata/src/dotgodir/.go/dot.go | package dot
// nothing to see here
| // Copyright 2017 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package dot
// nothing to see here
| Add licence header to test file | Add licence header to test file
| Go | bsd-3-clause | golang/dep,ibrasho-forks/dep,golang/dep,ibrasho-forks/dep,golang/dep |
f0d677bb130b74876926c889fba8cbf37ca66bc1 | lang.go | lang.go | package main
import (
"fmt"
"path/filepath"
"strings"
)
type Language struct {
Image string
Command string
}
// TODO: This should be extracted
var Extensions = map[string]Language{
".rb": Language{"ruby:2.2", "ruby %s"},
".py": Language{"python:2.7", "python %s"},
".js": Language{"node:0.12", "... | package main
import (
"fmt"
"path/filepath"
"strings"
)
type Language struct {
Image string
Command string
}
// TODO: This should be extracted
var Extensions = map[string]Language{
".rb": Language{"ruby:2.2", "ruby %s"},
".py": Language{"python:2.7", "python %s"},
".js": Language{"node:0.12", "... | Fix error message for unsupported extension | Fix error message for unsupported extension
| Go | mit | lanastasov/bitrun-api,sosedoff/bitrun-api,bitrun/api |
49dcb487e78e8b385aa9509aa5047085bb63f578 | main.go | main.go | package main
import (
"flag"
"log"
"github.com/mendersoftware/artifacts/config"
"github.com/spf13/viper"
)
func main() {
var configPath string
flag.StringVar(&configPath, "config", "config.yaml", "Configuration file path. Supports JSON, TOML, YAML and HCL formatted configs.")
flag.Parse()
c := viper.New()... | package main
import (
"flag"
"fmt"
"log"
"os"
"github.com/mendersoftware/artifacts/config"
"github.com/spf13/viper"
)
func main() {
var configPath string
var printVersion bool
flag.StringVar(&configPath, "config", "config.yaml", "Configuration file path. Supports JSON, TOML, YAML and HCL formatted configs.... | Add -version command line flag to print application version. | Add -version command line flag to print application version.
| Go | apache-2.0 | pasinskim/deployments,pasinskim/deployments,pasinskim/deployments,pasinskim/deployments |
974a47affc24963768cc523e397b71c5d0efb3a7 | main.go | main.go | package main
import (
"github.com/octavore/naga/service"
"github.com/octavore/ketchup/admin"
"github.com/octavore/ketchup/db/bolt"
"github.com/octavore/ketchup/plugins/pkg"
"github.com/octavore/ketchup/server/api"
"github.com/octavore/ketchup/server/content"
"github.com/octavore/ketchup/server/tls"
)
type App... | package main
import (
"github.com/octavore/naga/service"
"github.com/octavore/ketchup/admin"
"github.com/octavore/ketchup/db/bolt"
"github.com/octavore/ketchup/plugins/pkg"
"github.com/octavore/ketchup/server/api"
"github.com/octavore/ketchup/server/content"
"github.com/octavore/ketchup/server/tls"
)
type App... | Use KETCHUP_ENV as env name. | ketchup: Use KETCHUP_ENV as env name.
| Go | apache-2.0 | ketchuphq/ketchup,ketchuphq/ketchup,ketchuphq/ketchup,ketchuphq/ketchup,ketchuphq/ketchup |
6657839f8f426d83cb426aca87bc4c7439516242 | util.go | util.go | // Copyright © 2015-2017 Hilko Bengen <bengen@hilluzination.de>
// All rights reserved.
//
// Use of this source code is governed by the license that can be
// found in the LICENSE file.
package yara
import (
"github.com/VirusTotal/go-yara/internal/callbackdata"
)
var callbackData = callbackdata.MakePool(256)
func... | // Copyright © 2015-2017 Hilko Bengen <bengen@hilluzination.de>
// All rights reserved.
//
// Use of this source code is governed by the license that can be
// found in the LICENSE file.
package yara
import (
"github.com/hillu/go-yara/internal/callbackdata"
)
var callbackData = callbackdata.MakePool(256)
func toin... | Revert to the original import path. | Revert to the original import path.
| Go | bsd-2-clause | VirusTotal/go-yara |
8e9a26077470c48f4bed938b8e7f8c5e2cfdf36e | pkg/timeseries/transform_functions.go | pkg/timeseries/transform_functions.go | package timeseries
import "time"
func TransformScale(factor float64) TransformFunc {
return func(point TimePoint) TimePoint {
if point.Value != nil {
newValue := *point.Value * factor
point.Value = &newValue
}
return point
}
}
func TransformOffset(offset float64) TransformFunc {
return func(point Time... | package timeseries
import "time"
func TransformScale(factor float64) TransformFunc {
return func(point TimePoint) TimePoint {
if point.Value != nil {
newValue := *point.Value * factor
point.Value = &newValue
}
return point
}
}
func TransformOffset(offset float64) TransformFunc {
return func(point Time... | Fix null handling in removeAbove/BelowValue | Fix null handling in removeAbove/BelowValue
| Go | apache-2.0 | alexanderzobnin/grafana-zabbix,alexanderzobnin/grafana-zabbix,alexanderzobnin/grafana-zabbix,alexanderzobnin/grafana-zabbix,alexanderzobnin/grafana-zabbix,alexanderzobnin/grafana-zabbix |
a61285e4587cef9a01def33ad8926b87612f6e41 | ability.go | ability.go | package main
type targetType uint8
const (
_ targetType = iota
targetTypeOneself
targetTypeFriend
targetTypeAllFriends
targetTypeEnemy
targetTypeAllEnemies
)
type ability struct {
targetType
manaCost statistic
cooldown gameDuration
disableTypes []disableType
perform func(performer, receiver *... | package main
type targetType uint8
const (
_ targetType = iota
targetTypeOneself
targetTypeFriend
targetTypeAllFriends
targetTypeEnemy
targetTypeAllEnemies
)
type damageType uint8
const (
_ damageType = iota
damageTypePhysical
damageTypeMagic
damageTypeTrue
)
type ability struct {
name str... | Add damageType, activationDuration and healthCost | Add damageType, activationDuration and healthCost
| Go | mit | etheriqa/crescent |
22118dbcb2e775fd70132f8afab293579cde80ed | ipfs/query.go | ipfs/query.go | package ipfs
import (
"context"
routing "gx/ipfs/QmPpYHPRGVpSJTkQDQDwTYZ1cYUR2NM4HS6M3iAXi8aoUa/go-libp2p-kad-dht"
"gx/ipfs/QmTRhk7cgjUf2gfQ3p2M9KPECNZEW9XUrmHcFCgog4cPgB/go-libp2p-peer"
)
func Query(dht *routing.IpfsDHT, peerID string) ([]peer.ID, error) {
id, err := peer.IDB58Decode(peerID)
if err != nil {
r... | package ipfs
import (
"context"
routing "gx/ipfs/QmPpYHPRGVpSJTkQDQDwTYZ1cYUR2NM4HS6M3iAXi8aoUa/go-libp2p-kad-dht"
peer "gx/ipfs/QmTRhk7cgjUf2gfQ3p2M9KPECNZEW9XUrmHcFCgog4cPgB/go-libp2p-peer"
)
// Query returns the closest peers known for peerID
func Query(dht *routing.IpfsDHT, peerID string) ([]peer.ID, error) {... | Fix lint report error; Simplify Query function | Fix lint report error; Simplify Query function
| Go | mit | OpenBazaar/openbazaar-go,OpenBazaar/openbazaar-go,OpenBazaar/openbazaar-go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.