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 |
|---|---|---|---|---|---|---|---|---|---|
25a041c0b624719e34369d4893ebee32b81c67ba | static_run.go | static_run.go | package static
import (
"errors"
"fmt"
"log"
"os"
)
var (
ErrUnknownCommand = errors.New("Unknown command. Valid commands are: 'server', 'build'.")
)
const (
RunCommandServer = "server"
RunCommandBuild = "build"
)
func (s *Static) Run() error {
command := RunCommandServer
if len(os.Args) >= 2 {
command ... | package static
import (
"errors"
"fmt"
"log"
"os"
)
var (
ErrUnknownCommand = errors.New("Unknown command. Valid commands are: 'server', 'build'.")
)
const (
RunCommandServer = "server"
RunCommandBuild = "build"
)
func (s *Static) Run() error {
command := RunCommandServer
if len(os.Args) >= 2 {
command ... | Rename internal functions for clarity. | Rename internal functions for clarity.
What
===
Rename internal functions.
Why
===
Clarity.
| Go | mit | leighmcculloch/static |
36afb44b25bc375046b089f675d700afbf737bc5 | app/features_test.go | app/features_test.go | // +build acceptance
package app
import (
stdnet "net"
"time"
"github.com/DATA-DOG/godog"
"github.com/goph/stdlib/net"
"google.golang.org/grpc"
)
func FeatureContext(s *godog.Suite) {
addr := net.ResolveVirtualAddr("pipe", "pipe")
listener, dialer := net.PipeListen(addr)
server := grpc.NewServer()
client,... | // +build acceptance
package app
import (
stdnet "net"
"time"
"github.com/DATA-DOG/godog"
"github.com/goph/stdlib/net"
"google.golang.org/grpc"
)
func FeatureContext(s *godog.Suite) {
addr := net.ResolveVirtualAddr("pipe", "pipe")
listener, dialer := net.PipeListen(addr)
server := grpc.NewServer()
client,... | Improve dummy feature test example | Improve dummy feature test example
| Go | mit | deshboard/boilerplate-model-service |
0ae7d3c6bcc7a880be4db7d503e52f8bcf49f847 | random.go | random.go | package faker
import (
"math/rand"
"regexp"
"strconv"
"time"
)
func random(min, max int) int {
rand.Seed(time.Now().Unix() + int64(rand.Int()))
return rand.Intn(max-min) + min
}
// UUID generate random uuid.
func UUID() string {
r := regexp.MustCompile(`[xy]`)
RFC4122Template := "xxxxxxxx-xxxx-4xxx-yxxx-xxxx... | package faker
import (
"math/rand"
"regexp"
"strconv"
"time"
)
var seed int64
func StaticSeed(s int64) {
seed = s
}
func ResetStaticSeed() {
seed = 0
}
func GetStaticSeed() int64 {
return seed
}
func random(min, max int) int {
if seed > 0 {
rand.Seed(seed)
} else {
rand.Seed(time.Now().Unix() + int64... | Add method related to static seed | Add method related to static seed
| Go | mit | raitucarp/faker |
b4b0d38e76022e4b1b8eaa3c0aa58c42e7e20533 | besticon/popular_sites.go | besticon/popular_sites.go | package besticon
// PopularSites we might use for examples and testing.
var PopularSites []string
func init() {
PopularSites = []string{
"apple.com",
"bbc.co.uk",
"bing.com",
"booking.com",
"craigslist.org",
"dropbox.com",
"espn.go.com",
"etsy.com",
"facebook.com",
"flickr.com",
"github.com",
... | package besticon
// PopularSites we might use for examples and testing.
var PopularSites []string
func init() {
PopularSites = []string{
"apple.com",
"bbc.co.uk",
"bing.com",
"booking.com",
"dropbox.com",
"espn.go.com",
"etsy.com",
"facebook.com",
"flickr.com",
"github.com",
"imgur.com",
"ins... | Remove youtube.com and craiglist from showcase | Remove youtube.com and craiglist from showcase
| Go | mit | mat/besticon,mat/besticon,mat/besticon |
c14e4298246c74f064e60d0911b16792acf1caba | godelbrot.go | godelbrot.go | package main
import (
"fmt"
"io"
"os"
"os/exec"
)
func main() {
config := exec.Command("configbrot", os.Args[1:]...)
render := exec.Command("renderbrot")
confoutp, conferrp, conferr := pipes(config)
if conferr != nil {
fatal(conferr)
}
rendoutp, renderrp, renderr := p... | package main
import (
"bytes"
"fmt"
"os"
"os/exec"
"github.com/johnny-morrice/pipeline"
)
func main() {
config := exec.Command("configbrot", os.Args[1:]...)
render := exec.Command("renderbrot")
pl := pipeline.New(&bytes.Buffer{}, os.Stdout, os.Stderr)
pl.Chain(config, render)
... | Use neat process pipeline library | Use neat process pipeline library
| Go | mit | johnny-morrice/godelbrot |
72bf14c26294c79fad3c8bc16e4655a1fda60445 | testutils/testapp.go | testutils/testapp.go | package testutils
import (
"net/http/httptest"
"github.com/gorilla/mux"
"github.com/mailgun/scroll"
)
// TestApp wraps a regular app adding features that can be used in unit tests.
type TestApp struct {
RestHelper
app *scroll.App
testServer *httptest.Server
}
// NewTestApp creates a new app should be u... | package testutils
import (
"net/http/httptest"
"github.com/gorilla/mux"
"github.com/mailgun/scroll"
"github.com/mailgun/scroll/registry"
)
// TestApp wraps a regular app adding features that can be used in unit tests.
type TestApp struct {
RestHelper
app *scroll.App
testServer *httptest.Server
}
// Ne... | Test app should register with NopRegistry | Test app should register with NopRegistry
| Go | apache-2.0 | pquerna/scroll,mailgun/scroll,mailgun/scroll |
8593d9c70df732a62f7abfb4ac1548f095ab8275 | govc/version/command.go | govc/version/command.go | /*
Copyright (c) 2014 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed t... | /*
Copyright (c) 2014 VMware, Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed t... | Add version variable that can be set by the linker | Add version variable that can be set by the linker
| Go | apache-2.0 | jrmycanady/govmomi,l1jiang/govmomi,egorovv/govmomi,vmware/govmomi,egorovv/govmomi,daxgames/govmomi,daxgames/govmomi,abathla/govmomi,anexia-it/govmomi,ilikejam/govmomi,juju/govmomi,ilikejam/govmomi,gonkulator/govmomi,gonkulator/govmomi,casualjim/govmomi,higebu/govmomi,excilsploft/govmomi,chrislovecnm/govmomi,dougm/govmo... |
7ccd0ab8d0ef93947e9a7489359c10fbceadfb11 | pkg/util/validation/validate.go | pkg/util/validation/validate.go | package validation
import "github.com/prometheus/client_golang/prometheus"
const (
discardReasonLabel = "reason"
// RateLimited is one of the values for the reason to discard samples.
// Declared here to avoid duplication in ingester and distributor.
RateLimited = "rate_limited"
)
// DiscardedBytes is a metric ... | package validation
import "github.com/prometheus/client_golang/prometheus"
const (
discardReasonLabel = "reason"
// RateLimited is one of the values for the reason to discard samples.
// Declared here to avoid duplication in ingester and distributor.
RateLimited = "rate_limited"
)
// DiscardedBytes is a metric ... | Use tenant as label name for discarded_samples metrics | Use tenant as label name for discarded_samples metrics
discarded_samples should use the name labels as the other metrics.
Signed-off-by: Julien Pivotto <df1ed88a312a603dfee9f157a90fa8f7f195ab59@inuits.eu>
| Go | agpl-3.0 | grafana/loki,grafana/loki,grafana/loki,grafana/loki,grafana/loki,grafana/loki |
2a2989abe972e1c7a3d88698a3ecb9874328fa8f | cfgfile/cfgfile.go | cfgfile/cfgfile.go | package cfgfile
import (
"flag"
"fmt"
"io/ioutil"
"gopkg.in/yaml.v2"
)
// Command line flags
var configfile *string
var testConfig *bool
func CmdLineFlags(flags *flag.FlagSet, name string) {
configfile = flags.String("c", fmt.Sprintf("/etc/%s/%s.yml", name, name), "Configuration file")
testConfig = flags.Bool... | package cfgfile
import (
"flag"
"fmt"
"io/ioutil"
"gopkg.in/yaml.v2"
)
// Command line flags
var configfile *string
var testConfig *bool
func CmdLineFlags(flags *flag.FlagSet, name string) {
configfile = flags.String("c", fmt.Sprintf("/etc/%s/%s.yml", name, name), "Configuration file")
testConfig = flags.Bool... | Adjust doc to be more google like | Adjust doc to be more google like
| Go | mit | yapdns/yapdnsbeat,yapdns/yapdnsbeat |
447b539334464de8949aad222e85932cd926ec10 | 2019/day05/first/day05a.go | 2019/day05/first/day05a.go | package main
import (
"strings"
"github.com/bewuethr/advent-of-code/go/convert"
"github.com/bewuethr/advent-of-code/go/intcode"
"github.com/bewuethr/advent-of-code/go/ioutil"
"github.com/bewuethr/advent-of-code/go/log"
)
func main() {
scanner, err := ioutil.GetInputScanner()
if err != nil {
log.Die("getting... | package main
import (
"fmt"
"strings"
"github.com/bewuethr/advent-of-code/go/convert"
"github.com/bewuethr/advent-of-code/go/intcode"
"github.com/bewuethr/advent-of-code/go/ioutil"
"github.com/bewuethr/advent-of-code/go/log"
)
func main() {
scanner, err := ioutil.GetInputScanner()
if err != nil {
log.Die("... | Update 2019 day 5, first part, for new intcode computer | Update 2019 day 5, first part, for new intcode computer
| Go | mit | bewuethr/advent_of_code,bewuethr/advent_of_code,bewuethr/advent_of_code |
eff3bfec17b711a2dd5f4efdb3b3bb1c6900e46b | benchmark_test.go | benchmark_test.go | package sample
import (
"testing"
)
func BenchmarkLessThanRand(b *testing.B) {
s, err := NewLessThan(1000)
if err != nil {
b.Fatal("NewLessThan must not error", err)
}
// run sample b.N times
for n := 0; n < b.N; n++ {
s.Sample()
}
b.Log(Stats(s))
}
func BenchmarkLessThan(b *testing.B) {
s, err := New... | package sample
import (
"testing"
)
func BenchmarkLessThanRand(b *testing.B) {
s, err := NewLessThan(1000)
if err != nil {
b.Fatal("NewLessThan must not error", err)
}
// run sample b.N times
for n := 0; n < b.N; n++ {
s.Sample()
}
b.Log(Stats(s))
}
func BenchmarkLessThanFrom(b *testing.B) {
s, err :=... | Rename benchmark to allow for easier selectiv run by pattern matching | Rename benchmark to allow for easier selectiv run by pattern matching
| Go | mit | breml/sample,breml/sample |
84a5fd6f0ac18740844ea22407cd207947e59e5c | pkg/cli/clihelper.go | pkg/cli/clihelper.go | package cli
import (
"os"
"path/filepath"
"strconv"
"github.com/spf13/cobra"
)
func flag(cmd *cobra.Command, f string) string {
s := cmd.Flag(f).DefValue
if cmd.Flag(f).Changed {
s = cmd.Flag(f).Value.String()
}
return s
}
func GetCliStringFlag(cmd *cobra.Command, f string) string {
return flag(cmd, f)
... | package cli
import (
"os"
"path/filepath"
"strconv"
"github.com/spf13/cobra"
)
func flag(cmd *cobra.Command, f string) string {
s := cmd.Flag(f).DefValue
if cmd.Flag(f).Changed {
s = cmd.Flag(f).Value.String()
}
return s
}
func GetCliStringFlag(cmd *cobra.Command, f string) string {
return flag(cmd, f)
... | Fix bin name when using symlink. | Fix bin name when using symlink.
| Go | mpl-2.0 | mobingi/mobingi-cli |
79a3160ccb19db48cf9038daae20133d490d478c | configreader/main.go | configreader/main.go | package main
import (
"os"
"fmt"
"encoding/json"
)
type Config struct {
BooleanOption bool
StringOption string
ArrayOption []string
}
func main() {
file, err := os.Open("config.json")
if err!= nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
decoder := json.NewDecoder(file)
configuration := Config{}
e... | package main
import (
"os"
"fmt"
"encoding/json"
)
type Config struct {
BooleanOption bool
StringOption string
ArrayOption []string
}
func main() {
args := os.Args
if len(args) < 2 {
fmt.Fprintln(os.Stderr, "Usage: main filename")
os.Exit(1)
}
file, err := os.Open(args[1])
if err!= nil {
fmt.Fprint... | Add capablity to read config filename from args | Add capablity to read config filename from args
| Go | mit | daniel-bryant-uk/go-book-exp |
228713acb8c952579be07f23249b0930c4bc49e5 | src/server/pkg/testutil/ports.go | src/server/pkg/testutil/ports.go | package testutil
import "sync/atomic"
var nextPort uint32 = 41300
// UniquePort generates a likely unique port, so that multiple servers can run
// concurrently. Note that it does not actually check that the port is free,
// but uses atomics and a fairly highly port range to maximize the likelihood
// that the port ... | package testutil
import "sync/atomic"
var nextPort uint32 = 40000
// UniquePort generates a likely unique port, so that multiple servers can run
// concurrently. Note that it does not actually check that the port is free,
// but uses atomics and a fairly highly port range to maximize the likelihood
// that the port ... | Revert "Up the test port range" | Revert "Up the test port range"
This reverts commit de370ced97cb6d1a20bbdf745c8926a3e9e5bf4a.
| Go | apache-2.0 | pachyderm/pfs,pachyderm/pfs,pachyderm/pfs |
7baa466a8cad03c01018d4bfb8366205604ce14f | key-check/main.go | key-check/main.go | package main
import (
"log"
"os"
"github.com/flynn/flynn-controller/client"
)
func main() {
key := os.Args[3]
client, err := controller.NewClient("", os.Getenv("CONTROLLER_AUTH_KEY"))
if err != nil {
log.Fatalln("Unable to connect to controller:", err)
}
keys, err := client.KeyList()
if err != nil {
lo... | package main
import (
"log"
"os"
"github.com/flynn/flynn-controller/client"
)
func main() {
key := os.Args[2]
client, err := controller.NewClient("", os.Getenv("CONTROLLER_AUTH_KEY"))
if err != nil {
log.Fatalln("Unable to connect to controller:", err)
}
keys, err := client.KeyList()
if err != nil {
lo... | Update number of arguments sent to key-check | receiver: Update number of arguments sent to key-check
Signed-off-by: Jonathan Rudenberg <3692bfa45759a67d83aedf0045f6cb635a966abf@titanous.com>
| Go | bsd-3-clause | justintung/flynn,whouses/flynn,supermario/flynn,felixrieseberg/flynn,mubassirhayat/flynn,kgrz/flynn,philiplb/flynn,ozum/flynn,clifff/flynn,pkdevbox/flynn,mubassirhayat/flynn,Brandywine2161/flynn,schatt/flynn,clifff/flynn,felixrieseberg/flynn,technosophos/flynn,jzila/flynn,benbjohnson/flynn,TribeMedia/flynn,TribeMedia/f... |
11fb2c6c9f583570ef82650a64e125c36c3114be | knx/proto/hpai.go | knx/proto/hpai.go | package proto
import (
"errors"
"io"
"github.com/vapourismo/knx-go/knx/encoding"
)
// Address is a IPv4 address.
type Address [4]byte
// Port is a port number.
type Port uint16
// HostInfo contains information about a host.
type HostInfo struct {
Address Address
Port Port
}
// ReadFrom initializes the stru... | package proto
import (
"errors"
"fmt"
"io"
"github.com/vapourismo/knx-go/knx/encoding"
)
// Address is a IPv4 address.
type Address [4]byte
// String formats the address.
func (addr Address) String() string {
return fmt.Sprintf("%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3])
}
// Port is a port number.
type... | Add String() method to Address | Add String() method to Address
| Go | mit | vapourismo/knx-go |
f1b72f4fee37bb9b19ef15e207e398baeba4220b | ioutil.go | ioutil.go | package missinggo
import "io"
type StatWriter struct {
Written int64
w io.Writer
}
func (me *StatWriter) Write(b []byte) (n int, err error) {
n, err = me.w.Write(b)
me.Written += int64(n)
return
}
func NewStatWriter(w io.Writer) *StatWriter {
return &StatWriter{w: w}
}
type ZeroReader struct{}
func (m... | package missinggo
import "io"
type StatWriter struct {
Written int64
w io.Writer
}
func (me *StatWriter) Write(b []byte) (n int, err error) {
n, err = me.w.Write(b)
me.Written += int64(n)
return
}
func NewStatWriter(w io.Writer) *StatWriter {
return &StatWriter{w: w}
}
var ZeroReader zeroReader
type z... | Make ZeroReader a var instead of a type | Make ZeroReader a var instead of a type
| Go | mit | anacrolix/missinggo |
b7f2285ba304b0473025902fd6508a175cf51420 | Src/Server/emailManager.go | Src/Server/emailManager.go | package main
import (
"fmt"
"net/smtp"
"strconv"
)
type emailManager struct {
Login string
Password string
Host string
Port int
}
func NewEmailManager() *emailManager {
manager := new(emailManager)
manager.Login = GlobalConfig.Email.Login
manager.Password = GlobalConfig.Email.Password
manager.H... | package main
import (
"fmt"
"net/smtp"
"strconv"
)
type emailManager struct {
Login string
Password string
Host string
Port int
}
func NewEmailManager() *emailManager {
manager := new(emailManager)
manager.Login = GlobalConfig.Email.Login
manager.Password = GlobalConfig.Email.Password
manager.H... | Send should be public method | Send should be public method
| Go | mit | lukasz-pyrzyk/CerberCam,lukasz-pyrzyk/CerberCam,lukasz-pyrzyk/CerberCam,lukasz-pyrzyk/CerberCam,lukasz-pyrzyk/CerberCam |
1b71ee9f41dde3560f816b8ba6e9932211789f0f | examples/intEnums/main.go | examples/intEnums/main.go | package main
import "fmt"
func main() {
for _, ev := range WolfEnumValues() {
fmt.Println("Enum value: ", ev)
}
ev1 := Wolf1{}.New()
ev2 := Wolf2{}.New()
if ev1 != ev2 {
fmt.Println(ev1, " differs from ", ev2)
} else {
fmt.Println(ev1, " is the same as ", ev2)
}
ev1 = Wolf3{}.New()
ev2 = Wolf3{}.New... | package main
import "fmt"
func main() {
for _, wolf := range WolfEnumValues() {
fmt.Println("Enum value: ", wolf)
}
ev1 := Wolf1{}.New()
ev2 := Wolf2{}.New()
if ev1 != ev2 {
fmt.Println(ev1, " differs from ", ev2)
} else {
fmt.Println(ev1, " is the same as ", ev2)
}
ev1 = Wolf3{}.New()
ev2 = Wolf3{}... | Add type switch evaluation example | Add type switch evaluation example
| Go | mit | gdm85/go-genums |
77849ede1a3ccc01b3e8db6a458ba6d15447a476 | fill.go | fill.go | package funk
import (
"reflect"
"errors"
"fmt"
)
func Fill(in interface{}, fillValue interface{}) (interface{}, error) {
inValue := reflect.ValueOf(in)
inKind := inValue.Type().Kind()
if inKind != reflect.Slice && inKind != reflect.Array {
return nil, errors.New("Can only fill slices and arrays")
}
inType ... | package funk
import (
"errors"
"fmt"
"reflect"
)
// Fill fills elements of array with value
func Fill(in interface{}, fillValue interface{}) (interface{}, error) {
inValue := reflect.ValueOf(in)
inKind := inValue.Type().Kind()
if inKind != reflect.Slice && inKind != reflect.Array {
return nil, errors.New("Can... | Add missing documentation for Fill | Add missing documentation for Fill
| Go | mit | thoas/go-funk,thoas/go-fn |
e6e81175964c529897196451c8ff0943fbe78710 | main.go | main.go | package main
import (
"fmt"
"github.com/pagarme/teleport/config"
"github.com/pagarme/teleport/server"
)
func main() {
config := config.New()
// Load config file
err := config.ReadFromFile("source_config.yml")
// Start db
if err = config.Database.Start(); err != nil {
fmt.Printf("ERROR STARTING DATABASE: %... | package main
import (
"fmt"
"github.com/pagarme/teleport/config"
"github.com/pagarme/teleport/server"
"time"
)
func main() {
config := config.New()
// Load config file
err := config.ReadFromFile("source_config.yml")
// Start db
if err = config.Database.Start(); err != nil {
fmt.Printf("ERROR STARTING DAT... | Use time to manipulate seconds. | Use time to manipulate seconds.
| Go | mit | pagarme/teleport,pagarme/teleport,timehop/teleport |
f7fed7aed50067c57296e05c08064b4c6c8ed4f4 | creational/factory_method.go | creational/factory_method.go | package creational
import (
"fmt"
"io"
"os"
)
var outputWriter io.Writer = os.Stdout // modified during testing
// StoogeType is used as a enum for stooge types.
type StoogeType int
const (
Larry StoogeType = iota
Moe
Curly
)
// Stooge provides an interface for interacting with stooges.
type Stooge interface... | package creational
import (
"fmt"
"io"
"os"
)
var outputWriter io.Writer = os.Stdout // modified during testing
// StoogeType is used as a enum for stooge types.
type StoogeType int
const (
Larry StoogeType = iota // Larry stooge
Moe // Moe stooge
Curly // Cutly stooge
)
... | Add documentation for stooge types | Add documentation for stooge types
| Go | mit | bvwells/go-patterns,bvwells/go-patterns |
98521e1639d785d5633eaa225460cd0ce486af7b | formats/structs.go | formats/structs.go | package formats
import (
"fmt"
"github.com/ungerik/go3d/float64/vec3"
)
type lineError struct {
lineNumber int
line string
err error
}
func (e lineError) Error() string {
return fmt.Sprintf("Line #%d: %v ('%s')", e.lineNumber, e.line, e.err)
}
// material represents the name of a material used b... | package formats
import (
"fmt"
"github.com/ungerik/go3d/float64/vec3"
)
type lineError struct {
lineNumber int
line string
err error
}
func (e lineError) Error() string {
return fmt.Sprintf("Line #%d: %v ('%s')", e.lineNumber, e.line, e.err)
}
// faceCorner represents a 'corner' (or vertex) in a... | Remove 'material' struct - just using string (name). | Remove 'material' struct - just using string (name).
| Go | agpl-3.0 | larsmoa/renderdb,larsmoa/renderdb,larsmoa/renderdb,larsmoa/renderdb |
c1f6c7ed0bb6bc544da60c6da8b442f240404f0e | github/repository.go | github/repository.go | package github
import (
"context"
)
type Repo struct {
Name *string `json:"name, omitempty"`
}
func (github *Client) Repos(user string) ([]*Repo, error) {
ctx := context.Background()
repos, _, err := github.client.Repositories.List(ctx, user, nil)
if err != nil {
return nil, err
}
result := make([]*Repo, ... | package github
import (
"context"
)
type Repo struct {
Name *string `json:"name,omitempty"`
}
func (github *Client) Repos(user string) ([]*Repo, error) {
ctx := context.Background()
repos, _, err := github.client.Repositories.List(ctx, user, nil)
if err != nil {
return nil, err
}
result := make([]*Repo, 0... | Update struct field on json tag | Update struct field on json tag
| Go | mit | proshik/githubstatbot,proshik/githubstatbot |
8c066089cfc84e13709054cc54c941afb1cd8caa | api/internal/mocks/service.go | api/internal/mocks/service.go | package mocks
import "time"
type Service struct {
URLCall struct {
ReturnURL string
Err error
}
StartCall struct {
Called bool
Err error
}
StopCall struct {
Called bool
Err error
}
WaitForBootCall struct {
Timeout time.Duration
Err error
}
}
func (s *Service) URL() (string,... | package mocks
import "time"
type Service struct {
URLCall struct {
ReturnURL string
Err error
}
StartCall struct {
Called bool
Err error
}
StopCall struct {
Called bool
Err error
}
WaitForBootCall struct {
Timeout time.Duration
Err error
}
}
func (s *Service) URL() (string,... | Fix the mock Service to implement "Debug" also. | Fix the mock Service to implement "Debug" also.
| Go | mit | Etienne42/agouti,abourget/agouti,sclevine/agouti,sclevine/agouti,abourget/agouti,Etienne42/agouti |
18caa28b669871adb11dff0f6914d3094d2d2c4e | command/container/stats_unit_test.go | command/container/stats_unit_test.go | package container
import (
"testing"
"github.com/docker/docker/api/types"
)
func TestCalculBlockIO(t *testing.T) {
blkio := types.BlkioStats{
IoServiceBytesRecursive: []types.BlkioStatEntry{{8, 0, "read", 1234}, {8, 1, "read", 4567}, {8, 0, "write", 123}, {8, 1, "write", 456}},
}
blkRead, blkWrite := calculat... | package container
import (
"testing"
"github.com/docker/docker/api/types"
)
func TestCalculateBlockIO(t *testing.T) {
blkio := types.BlkioStats{
IoServiceBytesRecursive: []types.BlkioStatEntry{{8, 0, "read", 1234}, {8, 1, "read", 4567}, {8, 0, "write", 123}, {8, 1, "write", 456}},
}
blkRead, blkWrite := calcu... | Update function name for TestCalculBlockIO | Update function name for TestCalculBlockIO
Signed-off-by: yuexiao-wang <cb85382fcdcd61052c05cab964e91e5c6acdef6c@zte.com.cn>
| Go | apache-2.0 | Zebrilee/cli,redpanda/cli,ashfall/cli,riyazdf/cli,e11137/cli,dnephin/cli,Zebrilee/cli,dnephin/cli,ashfall/cli,e11137/cli,allencloud/cli,redpanda/cli,cpuguy83/cli,thaJeztah/cli,riyazdf/cli,cpuguy83/cli,allencloud/cli,gdevillele/cli,docker/cli,thaJeztah/cli,docker/cli |
7f16516d8feaf99e0be1f1d85b81fa595895730a | tokenizer/text_token_test.go | tokenizer/text_token_test.go | package tokenizer
import (
"io/ioutil"
"testing"
)
func TestEnglish001(t *testing.T) {
files := []string{
"testdata/input-org-syn.txt",
"testdata/input-te-wiki.txt",
}
for _, fn := range files {
t.Logf("TEST : %s", fn)
bs, err := ioutil.ReadFile(fn)
if err != nil {
t.Fatalf("FATAL : Input data... | package tokenizer
import (
"io/ioutil"
"testing"
)
func TestEnglish001(t *testing.T) {
files := []string{
"testdata/input-org-syn.txt",
"testdata/input-te-wiki.txt",
}
for _, fn := range files {
t.Logf("%-8s : %s", "TEST", fn)
bs, err := ioutil.ReadFile(fn)
if err != nil {
t.Fatalf("%-8s : Input da... | Make minor formatting change in tests | Make minor formatting change in tests
| Go | mit | js-ojus/RxnMiner,RxnWeaver/RxnMiner |
5ae158f91cef7c6e8889f0a9697ba5b18a858cd3 | pkg/config/client.go | pkg/config/client.go | package config
import (
"time"
)
// Client is the aptomictl config representation
type Client struct {
Debug bool `validate:"-"`
API API `validate:"required"`
Auth Auth `validate:"required"`
HTTP HTTP `validate:"required"`
}
// HTTP is the config for low level HTTP client
type HTTP struct {
Timeout time.D... | package config
import (
"time"
)
// Client is the aptomictl config representation
type Client struct {
Debug bool `validate:"-"`
Output string `validate:"required"`
API API `validate:"required"`
Auth Auth `validate:"required"`
HTTP HTTP `validate:"required"`
}
// HTTP is the config for low lev... | Add output config for CLI to specify type of the output | Add output config for CLI to specify type of the output
| Go | apache-2.0 | Aptomi/aptomi,Aptomi/aptomi,Aptomi/aptomi,Aptomi/aptomi |
78e4fa6f41a1061033be63ca323ae7837b3a5cd1 | pkg/base/config.go | pkg/base/config.go | package base
const (
defaultTimeFormat = "2006-01-02-15-04-05"
)
type Config struct {
// TimeFormat is used for a directory path
TimeFormat string
// RootDir
RootDir string
// TempDir
TempDir string
}
func (cfg *Config) InitDefaults() {
cfg.TimeFormat = defaultTimeFormat
}
| package base
const (
defaultTimeFormat = "2006-01-02-15-04-05"
)
type Config struct {
// TimeFormat is used for a directory path
TimeFormat string
// RootDir
RootDir string
// TempDir
TempDir string
}
func (cfg *Config) InitDefaults() {
if cfg.TimeFormat == "" {
cfg.TimeFormat = defaultTimeFormat
}
}
| Set time format if it is empty | Set time format if it is empty
| Go | apache-2.0 | taku-k/polymerase,taku-k/polymerase,taku-k/polymerase,taku-k/polymerase |
e3aaab175ff40d05eeab963592d862f83a873950 | requests/json_volumes.go | requests/json_volumes.go | //
// Copyright (c) 2014 The heketi 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 agr... | //
// Copyright (c) 2014 The heketi 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 agr... | Fix issue found by go vet | Fix issue found by go vet
| Go | apache-2.0 | lpabon/heketi,humblec/heketi,humblec/heketi,lpabon/heketi,lpabon/heketi,Zandrr/heketi,Zandrr/heketi,Zandrr/heketi,humblec/heketi,humblec/heketi |
caa9a2c71883912ded2b765fc874aa390cc536c0 | xstrings/upcase.go | xstrings/upcase.go | package xstrings
import (
"strings"
)
// Upcase returns a copy of string s
// with all lowercase letters replaced
// with their uppercase counterparts.
func Upcase(s string) string {
return strings.ToUpper(s)
}
| package xstrings
import (
"strings"
)
// Upcase returns a copy of string s
// with all lowercase letters replaced
// with their uppercase counterparts.
func Upcase(s string) string {
return strings.ToUpper(s)
}
| Fix spacing for documentation to work. | Fix spacing for documentation to work.
| Go | bsd-2-clause | wallclockbuilder/gstrings,wallclockbuilder/stringutil |
53d3ce1fc67cce86cd2db02907bd6de2c67065b3 | server/request.go | server/request.go | package server
import (
"github.com/b2aio/typhon/auth"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
)
// Request received by the server
type Request interface {
context.Context
// Id of this message, used to correlate the response
Id() string
// ContentType of the payload
ContentType() strin... | package server
import (
"fmt"
"github.com/b2aio/typhon/auth"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
)
// Request received by the server
type Request interface {
context.Context
// Id of this message, used to correlate the response
Id() string
// ContentType of the payload
ContentType... | Allow server to be recovered from the context | Allow server to be recovered from the context
| Go | mit | monzo/typhon,mondough/typhon |
f8c9a5ec509f1a8140d30dc1dc608af02489107e | pkg/cli/clihelper.go | pkg/cli/clihelper.go | package cli
import (
"os"
"strconv"
"strings"
"github.com/spf13/cobra"
)
func flag(cmd *cobra.Command, f string) string {
s := cmd.Flag(f).DefValue
if cmd.Flag(f).Changed {
s = cmd.Flag(f).Value.String()
}
return s
}
func GetCliStringFlag(cmd *cobra.Command, f string) string {
return flag(cmd, f)
}
fun... | package cli
import (
"os"
"path/filepath"
"strconv"
"github.com/spf13/cobra"
)
func flag(cmd *cobra.Command, f string) string {
s := cmd.Flag(f).DefValue
if cmd.Flag(f).Changed {
s = cmd.Flag(f).Value.String()
}
return s
}
func GetCliStringFlag(cmd *cobra.Command, f string) string {
return flag(cmd, f)
... | Use base name only for bin name. | Use base name only for bin name.
| Go | mpl-2.0 | mobingi/mobingi-cli |
73812af5f144d49e532eba96261e152b565d243a | cmd/gddoexp/gddoexp.go | cmd/gddoexp/gddoexp.go | // gddoexp is a command line tool crated to list eligible packages for
// archiving in GoDoc.org
package main
import (
"fmt"
"github.com/golang/gddo/database"
"github.com/rafaeljusto/gddoexp"
)
func main() {
db, err := database.New()
if err != nil {
fmt.Println("error connecting to database:", err)
return
... | // gddoexp is a command line tool crated to list eligible packages for
// archiving in GoDoc.org
package main
import (
"fmt"
"net/http"
"os"
"path"
"github.com/golang/gddo/database"
"github.com/gregjones/httpcache"
"github.com/gregjones/httpcache/diskcache"
"github.com/rafaeljusto/gddoexp"
)
func main() {
/... | Add HTTP cache in Github request/response | Add HTTP cache in Github request/response
As we are running this command many times, there's no reason to query every
time the Github to retrieve the same information.
| Go | mit | rafaeljusto/gddoexp |
c9547da2ec51bcb1ea904b8e1375c718c4ce0d24 | plugin/plugin_shim.go | plugin/plugin_shim.go | package plugin
import "os"
/**
* This function is called by the plugin to setup their server. This allows us to call Run on the plugin
* os.Args[1] port CF_CLI rpc server is running on
* os.Args[2] **OPTIONAL**
* SendMetadata - used to fetch the plugin metadata
**/
func Start(cmd Plugin) {
cliConnection := NewC... | package plugin
import "os"
/**
* This function is called by the plugin to setup their server. This allows us to call Run on the plugin
* os.Args[1] port CF_CLI rpc server is running on
* os.Args[2] **OPTIONAL**
* SendMetadata - used to fetch the plugin metadata
**/
func Start(cmd Plugin) {
cliConnection := NewC... | Remove move method off of other file's struct | refactor: Remove move method off of other file's struct
Signed-off-by: Tyler Schultz <6b7a73f4f7cffc2a148becd12890940350ddfa95@pivotal.io>
| Go | apache-2.0 | cloudfoundry/cli,cloudfoundry/cli,cloudfoundry/cli |
905ab950c57f4b207c410ca5f5a8349ebf21c663 | src/lib/time/tick_test.go | src/lib/time/tick_test.go | // Copyright 2009 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 time
import (
"testing";
"time";
)
export func TestTick(t *testing.T) {
const (
Delta uint64 = 100*1e6;
Count uint64 = 10;
);
c := Tick(Delta... | // Copyright 2009 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 time
import (
"testing";
"time";
)
export func TestTick(t *testing.T) {
const (
Delta = 100*1e6;
Count = 10;
);
c := Tick(Delta);
t0 := Nano... | Remove types from constants, since they didn't match what Tick() expected. | Remove types from constants, since they didn't match what
Tick() expected.
R=rsc
DELTA=2 (0 added, 0 deleted, 2 changed)
OCL=22979
CL=22986
| Go | bsd-3-clause | glycerine/jeaten-go-arrayof-structof,mhennings/marcohennings-go,npe9/noahevans-go9,npe9/noahevans-go9,npe9/noahevans-go9,sanjosh/sanjos100-tipc,bryanxu/go-zh,glycerine/jeaten-go-arrayof-structof,rflanagan/reginaldflanagan-project1,glycerine/jeaten-go-arrayof-structof,npe9/noahevans-go9,sanjosh/sanjos100-tipc,d0f/go-zh,... |
a7c7f8ba291cf93958b49120f8e16899b21f613d | cmd/genpass-http/main.go | cmd/genpass-http/main.go | package main
import (
"fmt"
"net/http"
"os"
"strconv"
"github.com/scottjbarr/genpass"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
bind := fmt.Sprintf(":%v", port)
http.HandleFunc("/", indexHandler)
if err := http.ListenAndServe(bind, nil); err != nil {
panic(err)
}
}
... | package main
import (
"fmt"
"net/http"
"os"
"strconv"
"github.com/scottjbarr/genpass"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
bind := fmt.Sprintf(":%v", port)
http.HandleFunc("/", indexHandler)
if err := http.ListenAndServe(bind, nil); err != nil {
panic(err)
}
}
... | Fix length parsing from http param | Fix length parsing from http param
| Go | mit | scottjbarr/genpass |
3fab59b1d33459b5ec435f6ad950c24237ed6ffa | commands.go | commands.go | package main
import (
"log"
"os"
"fmt"
"github.com/timakin/ts/loader"
"github.com/codegangsta/cli"
)
var Commands = []cli.Command{
commandAll,
commandBiz,
commandHack,
}
var commandAll = cli.Command{
Name: "all",
Usage: "",
Description: `
`,
Action: doAll,
}
var commandBiz = cli.Command{
Name: "biz",... | package main
import (
"log"
"os"
"fmt"
"github.com/timakin/ts/loader"
"github.com/codegangsta/cli"
)
var Commands = []cli.Command{
commandAll,
commandBiz,
commandHack,
}
var commandAll = cli.Command{
Name: "all",
Usage: "",
Description: `
`,
Action: doAll,
}
var commandBiz = cli.Command{
Name: "biz",... | Change the target set for channel | Change the target set for channel
| Go | mit | timakin/ts,timakin/ts |
f45c7a34e944b6fb12e01dbc8f227a924bdec1ab | pkg/api/unversioned.go | pkg/api/unversioned.go | /*
Copyright 2014 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in ... | /*
Copyright 2014 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in ... | Make label and field selector query strings versionable. | Make label and field selector query strings versionable.
Kubernetes-commit: 266234f3b9ccce6519c2bb500a2b102bf4b7fa16
| Go | apache-2.0 | kubernetes/api |
6c3a7b745cc5bb236df587bf2ad27bd16b0f1b94 | pkg/lang/policy_api.go | pkg/lang/policy_api.go | package lang
type APIPolicy struct {
Namespace map[string]*PolicyNamespace
}
type APIPolicyNamespace struct {
Services map[string]*Service
Contracts map[string]*Contract
Clusters map[string]*Cluster
Rules map[string]*Rule
ACLRules map[string]*Rule
Dependencies map[string]*Dependency
}
fu... | package lang
// APIPolicy is a Policy representation for API filtered for specific user
type APIPolicy struct {
Namespace map[string]*APIPolicyNamespace
}
// APIPolicyNamespace is a PolicyNamespace representation for API filtered for specific user
type APIPolicyNamespace struct {
Services map[string]*Service
C... | Add comments and fix APIPolicy/Namespace type | Add comments and fix APIPolicy/Namespace type
| Go | apache-2.0 | Aptomi/aptomi,Aptomi/aptomi,Aptomi/aptomi,Aptomi/aptomi |
b6dc6b208309f5035b1ca22e565a1dfa982691d9 | internal/keys/kind.go | internal/keys/kind.go | package keys
import "fmt"
// Kind expresses usage of the ambient internal key.
type Kind int
const (
// Delete represents deletion of this key.
Delete = 0
// Value represents value setting of this key.
Value = 1
maxKind = Value
// Seek is maximum(Value, Delete), which is a valid Kind and
// serves as start... | package keys
import "fmt"
// Kind expresses usage of the ambient internal key.
type Kind int
const (
// XXX Don't change those values, together with user keys there are
// persisted to files.
// Delete represents deletion of this key.
Delete = 0
// Value represents value setting of this key.
Value = 1
maxK... | Add CHANGE CAUTION for values of keys.Kind | Add CHANGE CAUTION for values of keys.Kind
| Go | mit | kezhuw/leveldb,kezhuw/leveldb |
0410e3edc651f083577e49ab2248a63f6cc86975 | webbrowser.go | webbrowser.go | package webbrowser
import (
"errors"
"net/url"
"os/exec"
)
var (
ErrCantOpen = errors.New("webbrowser.Open: can't open webpage")
ErrNoCandidates = errors.New("webbrowser.Open: no browser candidate found for your OS.")
)
//
var Candidates []Browser
// Browser
type Browser interface {
Open(string) error
}
... | package webbrowser
import (
"errors"
"net/url"
"os/exec"
)
var (
ErrCantOpen = errors.New("webbrowser.Open: can't open webpage")
ErrNoCandidates = errors.New("webbrowser.Open: no browser candidate found for your OS.")
)
//
var Candidates []Browser
// Browser
type Browser interface {
Open(string) error
}
... | Enforce HTTP Scheme on Open and added docs. | Enforce HTTP Scheme on Open and added docs.
| Go | mit | toqueteos/webbrowser |
a983ff09acefb0d7255abf92573b338cc67de135 | middleware_recover.go | middleware_recover.go | package horizon
import (
"bytes"
"fmt"
gctx "github.com/goji/context"
"github.com/stellar/go-horizon/render/problem"
"github.com/zenazn/goji/web"
. "github.com/zenazn/goji/web/middleware"
"log"
"net/http"
"runtime/debug"
)
func RecoverMiddleware(c *web.C, h http.Handler) http.Handler {
fn := func(w http.Res... | package horizon
import (
"net/http"
"runtime/debug"
gctx "github.com/goji/context"
"github.com/stellar/go-horizon/log"
"github.com/stellar/go-horizon/render/problem"
"github.com/zenazn/goji/web"
)
func RecoverMiddleware(c *web.C, h http.Handler) http.Handler {
fn := func(w http.ResponseWriter, r *http.Request... | Integrate recover middleware with new log | Integrate recover middleware with new log
| Go | apache-2.0 | irisli/horizon,masonforest/go-horizon,masonforest/horizon,FredericHeem/go-horizon,lackac/horizon,stellar/horizon,masonforest/horizon,irisli/horizon,lackac/horizon,FredericHeem/go-horizon,stellar/horizon,masonforest/go-horizon,stellar/horizon,nullstyle/go-horizon,nullstyle/go-horizon,masonforest/go-horizon,nullstyle/go-... |
cee5deef1e50a7ee2107af17809b01598a7a5725 | templates/content.go | templates/content.go | package templates
func ScopeTemplateContent() string {
return `#cloud-config
{{ .Name}}:
{{ range .Services }}{{ .GetName }}:
{{ range $key, $value := .GetParameters }}{{ $key }}: {{ $value }}
{{ end }}
{{ end }}
`
}
| package templates
func ScopeTemplateContent() string {
return `#cloud-config
{{ .Name}}:
{{ range .Services }}{{ .GetName }}:
{{ range $key, $value := .GetParameters }}{{ $key }}: {{ $value }}
{{ end }}
{{ end }}units:
{{ range .Units }}- name: {{ .GetName }}
command: {{ .GetCommand }}
{{ end... | Add units to template file | Add units to template file
| Go | apache-2.0 | bernardolins/clustereasy,bernardolins/clustereasy |
7619917e11bec5c0c743c01b37b8d8eb956bd775 | update_test.go | update_test.go | package dns
import (
"testing"
)
func TestDynamicUpdateParsing(t *testing.T) {
prefix := "example.com. IN "
for _, typ := range TypeToString {
if typ == "CAA" || typ == "OPT" || typ == "AXFR" || typ == "IXFR" || typ == "ANY" || typ == "TKEY" ||
typ == "TSIG" || typ == "ISDN" || typ == "UNSPEC" || typ == "NULL... | package dns
import (
"testing"
)
func TestDynamicUpdateParsing(t *testing.T) {
prefix := "example.com. IN "
for _, typ := range TypeToString {
if typ == "CAA" || typ == "OPT" || typ == "AXFR" || typ == "IXFR" || typ == "ANY" || typ == "TKEY" ||
typ == "TSIG" || typ == "ISDN" || typ == "UNSPEC" || typ == "NULL... | Add Test for dynamic unpack failure | Add Test for dynamic unpack failure
| Go | bsd-3-clause | bboreham/dns,skynet/dns,miekg/dns,josephyzhou/dns,modulexcite/dns,jmhodges/dns,tempbottle/dns,bragr/dns,flebarbe/dns,ym/go-dns,skyportsystems/dns,cloudflare/dns,curtiszimmerman/dns,benbearchen/dns,Git-Host/dns,tsenart/dns,ezoic/dns,janstk/dns,letsencrypt/dns,jdef/dns,Psiphon-Inc/dns,michaelharo/dns,asergeyev/dns,ErikDu... |
097bd9f0b1cd3cae779ed277efce5911359cc49a | utils/slice.go | utils/slice.go | package utils
import "sync"
// ConcurrentSlice type that can be safely shared between goroutines
type ConcurrentSlice struct {
sync.RWMutex
items []interface{}
}
// ConcurrentSliceItem contains the index/value pair of an item in a
// concurrent slice
type ConcurrentSliceItem struct {
Index int
Value interface{}
... | package utils
import "sync"
// ConcurrentSlice type that can be safely shared between goroutines
type ConcurrentSlice struct {
sync.RWMutex
items []interface{}
}
// ConcurrentSliceItem contains the index/value pair of an item in a
// concurrent slice
type ConcurrentSliceItem struct {
Index int
Value interface{}
... | Implement utils.List type with a Contains() method | utils: Implement utils.List type with a Contains() method
| Go | mit | ranjithamca/gru |
97f78a3a5ab9a20ced142328710e8defa40d0678 | go/src/socialapi/workers/notification/models/notificationcontent_bongo.go | go/src/socialapi/workers/notification/models/notificationcontent_bongo.go | package models
import "github.com/koding/bongo"
func (nc *NotificationContent) AfterCreate() {
bongo.B.AfterCreate(nc)
}
func (nc *NotificationContent) AfterUpdate() {
bongo.B.AfterUpdate(nc)
}
func (nc *NotificationContent) AfterDelete() {
bongo.B.AfterDelete(nc)
}
func NewNotificationContent() *NotificationCo... | package models
import "github.com/koding/bongo"
func (nc *NotificationContent) AfterCreate() {
bongo.B.AfterCreate(nc)
}
func (nc *NotificationContent) AfterUpdate() {
bongo.B.AfterUpdate(nc)
}
func (nc *NotificationContent) AfterDelete() {
bongo.B.AfterDelete(nc)
}
func NewNotificationContent() *NotificationCo... | Add some method to notificationcontent | Notification: Add some method to notificationcontent
| Go | agpl-3.0 | drewsetski/koding,mertaytore/koding,sinan/koding,andrewjcasal/koding,sinan/koding,szkl/koding,andrewjcasal/koding,drewsetski/koding,acbodine/koding,szkl/koding,koding/koding,drewsetski/koding,szkl/koding,usirin/koding,usirin/koding,alex-ionochkin/koding,rjeczalik/koding,usirin/koding,kwagdy/koding-1,drewsetski/koding,k... |
a46d7149f8c866d75f0161df3788c1e9331e2dcf | hw.go | hw.go | package main
import (
"fmt"
"net/http"
)
func helloWorld(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World!")
}
func startPage(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello, test server started on 8080 port.\n - /helloworld - show title page\n - /showinfo - show information a... | //Command to run test version:
//goapp serve app.yaml
//Command to deploy/update application:
//goapp deploy -application golangnode0 -version 0
package main
import (
"fmt"
"net/http"
)
func helloWorld(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World!")
}
func startPage(w http.ResponseWriter... | Correct version for deploy to GAE | Correct version for deploy to GAE
| Go | mit | GreyLabsDev/GoTests,GreyLabsDev/GoTests |
93fdb8b568b3f0e9fb822242cb9b3f3ee67d2a60 | drawinginstruction.go | drawinginstruction.go | package svg
// InstructionType tells our path drawing library which function it has
// to call
type InstructionType int
// These are instruction types that we use with our path drawing library
const (
PathInstruction InstructionType = iota
MoveInstruction
CircleInstruction
CurveInstruction
LineInstruction
HLine... | package svg
// InstructionType tells our path drawing library which function it has
// to call
type InstructionType int
// These are instruction types that we use with our path drawing library
const (
PathInstruction InstructionType = iota
MoveInstruction
CircleInstruction
CurveInstruction
LineInstruction
HLine... | Add more fields to the DrawingInstructions | Add more fields to the DrawingInstructions
| Go | mit | rustyoz/svg |
daef6f29bcd8a9212fb44b42431352c4eae276dd | streaming/streaming.go | streaming/streaming.go | package streaming
import (
"net/url"
"github.com/ChimeraCoder/anaconda"
)
func StartUserStream(api *anaconda.TwitterApi) anaconda.Stream {
v := url.Values{}
v.Set("with", "user")
v.Set("replies", "all")
return api.UserStream(v)
}
| package streaming
import (
"net/url"
"github.com/ChimeraCoder/anaconda"
)
func StartUserStream(api *anaconda.TwitterApi) *anaconda.Stream {
v := url.Values{}
v.Set("with", "user")
v.Set("replies", "all")
return api.UserStream(v)
}
| Fix wrong stream return type | Fix wrong stream return type
| Go | mit | mrap/twitterget |
068fc2e05e885734d5d6ab8c66ce5b94867bdd07 | engine/dot.go | engine/dot.go | package engine
import (
"encoding/json"
"fmt"
)
type Dot struct {
X uint8
Y uint8
}
// Equals compares two dots
func (d1 Dot) Equals(d2 Dot) bool {
return d1 == d2 || (d1.X == d2.X && d1.Y == d2.Y)
}
// Implementing json.Marshaler interface
func (d Dot) MarshalJSON() ([]byte, error) {
return json.Marshal([]ui... | package engine
import (
"encoding/json"
"fmt"
)
type Dot struct {
X uint8
Y uint8
}
// Equals compares two dots
func (d1 Dot) Equals(d2 Dot) bool {
return d1 == d2 || (d1.X == d2.X && d1.Y == d2.Y)
}
// Implementing json.Marshaler interface
func (d Dot) MarshalJSON() ([]byte, error) {
return json.Marshal([]ui... | Fix engine.Dot: do not convert x and y to uint16 for json marshaling | Fix engine.Dot: do not convert x and y to uint16 for json marshaling
| Go | bsd-2-clause | ivan1993spb/clever-snake |
ff48cecce2391f044c9ea8451ce493f429e7123b | server/missionary.go | server/missionary.go | package server
import (
"fmt"
"log"
"time"
"warcluster/entities"
"warcluster/server/response"
)
// StartMissionary is used when a call to initiate a new mission is rescived.
// 1. When the delay ends the thread ends the mission calling EndMission
// 2. The end of the mission is bradcasted to all clients and the ... | package server
import (
"fmt"
"log"
"time"
"warcluster/entities"
"warcluster/server/response"
)
// StartMissionary is used when a call to initiate a new mission is rescived.
// 1. When the delay ends the thread ends the mission calling EndMission
// 2. The end of the mission is bradcasted to all clients and the ... | Save the target planet at the end of each mission | Save the target planet at the end of each mission
| Go | mit | WarCluster/warcluster-server,WarCluster/warcluster-server |
599439ae107b1f36aebb7754aaa9c2f27e5eec36 | parse.go | parse.go | package route
import (
"fmt"
"github.com/mailgun/predicate"
)
// IsValid checks whether expression is valid
func IsValid(expr string) bool {
_, err := parse(expr, &match{})
return err == nil
}
func parse(expression string, result *match) (matcher, error) {
p, err := predicate.NewParser(predicate.Def{
Functio... | package route
import (
"fmt"
"github.com/vulcand/predicate"
)
// IsValid checks whether expression is valid
func IsValid(expr string) bool {
_, err := parse(expr, &match{})
return err == nil
}
func parse(expression string, result *match) (matcher, error) {
p, err := predicate.NewParser(predicate.Def{
Functio... | Move from github.com/mailgun/... to github.com/vulcand/... for dependencies. | Move from github.com/mailgun/... to github.com/vulcand/... for dependencies.
| Go | apache-2.0 | vulcand/route,mailgun/route |
297531c672687973facd15b3d0b8a6c839fef6ef | codecs/g722_packet_test.go | codecs/g722_packet_test.go | package codecs
import (
"bytes"
"math"
"math/rand"
"testing"
)
func TestG722Payloader(t *testing.T) {
p := G722Payloader{}
const (
testlen = 10000
testmtu = 1500
)
//generate random 8-bit g722 samples
samples := make([]byte, testlen)
_, err := rand.Read(samples)
if err != nil {
//according to go d... | package codecs
import (
"bytes"
"crypto/rand"
"math"
"testing"
)
func TestG722Payloader(t *testing.T) {
p := G722Payloader{}
const (
testlen = 10000
testmtu = 1500
)
//generate random 8-bit g722 samples
samples := make([]byte, testlen)
_, err := rand.Read(samples)
if err != nil {
t.Fatal("RNG Erro... | Use crypto/rand instead of math/rand | Use crypto/rand instead of math/rand
to satisfy the linter
Relates to #284
| Go | mit | pion/rtp |
147d5555aef0c08495931f9fa2745829abe3b58f | bbcode_test.go | bbcode_test.go | package moeparser
import (
"fmt"
"testing"
)
func TestBbCodeParse(t *testing.T) {
testString := `Something [b][i][img=http://sauyon.com/blah.png][/i][/i] [b]hi[/b=what]
This seems to work very well :D [url][/url] [size=12px]something
[url]http://sauyon.com/wrappedinurl[/url] [url=http://sauyon.com] [img=//sauyon.c... | package moeparser_test
import (
"fmt"
"moeparser"
"testing"
)
func TestBbCodeParse(t *testing.T) {
testString := `Something [b][i][img=http://sauyon.com/blah.png][/i][/i] [b]hi[/b=what]
This seems to work very well :D [url][/url] [size=12px]something
[url]http://sauyon.com/wrappedinurl[/url] [url=http://sauyon.co... | Move test code to package moeparser_test | Move test code to package moeparser_test
| Go | bsd-2-clause | moechat/parser |
c1fc51fddf78f194498fbd0c7175a5c48e17cb8e | sinks/adsb-ws/main.go | sinks/adsb-ws/main.go | package main
import (
"flag"
"log"
"net/http"
)
var bindaddr = flag.String("bind-address", ":8080", "Address to respond to HTTP requests on")
func main() {
log.SetFlags(0)
flag.Parse()
go h.run()
go readInput()
http.HandleFunc("/stream", serveStream)
err := http.ListenAndServe(*bindaddr, nil)
if err != nil... | package main
import (
"flag"
"log"
"net/http"
)
var bindaddr = flag.String("bind-address", ":8080", "Address to respond to HTTP requests on")
var staticdir = flag.String("static-dir", "", "Static directory to serve at /")
func main() {
log.SetFlags(0)
flag.Parse()
go h.run()
go readInput()
http.HandleFunc("... | Support serving a static directory along with the websocket stream | Support serving a static directory along with the websocket stream
| Go | apache-2.0 | flamingcowtv/adsb-tools,flamingcowtv/adsb-tools,flamingcowtv/adsb-tools,flamingcowtv/adsb-tools |
c21945cbc2ed0b993b1db071c02623812094465d | set_bench_test.go | set_bench_test.go | package set
import (
"testing"
)
// BenchmarkAdd checks the performance of the set.Add() method
func BenchmarkAdd(b *testing.B) {
// Create a new set
set := New()
// Run set.Add() b.N times
for i := 0; i < b.N; i++ {
set.Add(i)
}
}
| package set
import (
"testing"
)
// BenchmarkAdd checks the performance of the set.Add() method
func BenchmarkAdd(b *testing.B) {
// Create a new set
set := New()
// Run set.Add() b.N times
for i := 0; i < b.N; i++ {
set.Add(i)
}
}
// benchmarkCartesianProduct checks the performance of the set.CartesianProd... | Add BenchmarkCartesianProduct(), small and large variants | Add BenchmarkCartesianProduct(), small and large variants
| Go | mit | mdlayher/goset |
8dfe751d5529fbc192a281ce20ef8478bf40e741 | tutorial01/main.go | tutorial01/main.go | package main
import (
"fmt"
"hge"
)
var h *hge.HGE
func FrameFunc() int {
if h.Input_GetKeyState(hge.K_ESCAPE) {
return 1
}
return 0
}
func main() {
h = hge.Create(hge.VERSION)
defer h.Release()
h.System_SetState(hge.FRAMEFUNC, FrameFunc)
h.System_SetState(hge.TITLE, "HGE Tutorial 01 - Minimal HGE appl... | package main
import (
"fmt"
"hge"
)
var h *hge.HGE
func FrameFunc() int {
if h.Input_GetKeyState(hge.K_ESCAPE) {
return 1
}
return 0
}
func main() {
h = hge.Create(hge.VERSION)
defer h.Release()
h.System_SetState(hge.LOGFILE, "tutorial01.log")
h.System_SetState(hge.FRAMEFUNC, FrameFunc)
h.System_SetSt... | Add a logfile for tutorial01 | Add a logfile for tutorial01
| Go | bsd-2-clause | losinggeneration/hge,losinggeneration/hge-go,losinggeneration/hge-go,losinggeneration/hge |
0a4ec9f982f1c55e5b41650b2ef865ef956addab | load_balancing_example_test.go | load_balancing_example_test.go | package cloudflare
| package cloudflare_test
import (
"fmt"
"log"
cloudflare "github.com/cloudflare/cloudflare-go"
)
func ExampleAPI_ListLoadBalancers() {
// Construct a new API object.
api, err := cloudflare.New("deadbeef", "test@example.com")
if err != nil {
log.Fatal(err)
}
// Fetch the zone ID.
id, err := api.ZoneIDByNam... | Add an example load balancing test | Add an example load balancing test
| Go | bsd-3-clause | cloudflare/cloudflare-go,cloudflare/cloudflare-go |
e9e513171c5188b616e6b7f49ee33d512833c7af | page_test.go | page_test.go | package main
import (
// "fmt"
"os"
"strings"
"testing"
)
func TestGeneral(t *testing.T) {
defer os.RemoveAll("data")
p := Open("testpage")
err := p.Update("**bold**")
if err != nil {
t.Error(err)
}
if strings.TrimSpace(p.RenderedPage) != "<p><strong>bold</strong></p>" {
t.Errorf("Did n... | package main
import (
// "fmt"
"os"
"strings"
"testing"
)
func TestGeneral(t *testing.T) {
pathToData = "testdata"
os.MkdirAll(pathToData, 0755)
defer os.RemoveAll(pathToData)
p := Open("testpage")
err := p.Update("**bold**")
if err != nil {
t.Error(err)
}
if strings.TrimSpace(p.Render... | Create special folder for tests | Create special folder for tests
Former-commit-id: ae51c6c248baaf996f899e77e760aba1f0c161cf [formerly 7bf4f38602dd6b24f7888d88f18ca6e9cac9b9a3] [formerly 0ef00a42149f4e7724fde45c2a252e9ec7c550f5 [formerly d20e40ca85e6a06d0aba698624e3433e7c5c612a]]
Former-commit-id: 69b97c02f08943de02a1ae58c8291dcae6c56db8 [formerly d2... | Go | mit | schollz/AwwKoala,schollz/cowyo,schollz/AwwKoala,schollz/AwwKoala,schollz/AwwKoala |
71ac956c57977c38325979dbf0de29c282b1c06f | entity.go | entity.go | package engi
type Entity struct {
id string
components []Component
requires []string
}
func NewEntity(requires []string) *Entity {
return &Entity{requires: requires}
}
func (e *Entity) DoesRequire(name string) bool {
for _, requirement := range e.requires {
if requirement == name {
return true
... | package engi
type Entity struct {
id string
components []Component
requires map[string]bool
}
func NewEntity(requires []string) *Entity {
e := &Entity{requires: make(map[string]bool)}
for _, req := range requires {
e.requires[req] = true
}
return e
}
func (e *Entity) DoesRequire(name string) bool ... | Change Entity.requires into a map for faster lookups. | Change Entity.requires into a map for faster lookups.
| Go | mit | Newbrict/engi,EngoEngine/engo,paked/engi,EngoEngine/engo,Newbrict/engi,Newbrict/engo,EtienneBruines/engi,Newbrict/engo |
442aed80fd4a62be7142a5da1a51eae3f53e5a20 | proto_0_0.go | proto_0_0.go | package main
import (
"fmt"
"os"
"os/exec"
)
func proto_0_0(inFlag, outFlag bool, errFlag, workdir string, args []string) error {
proc := exec.Command(args[0], args[1:]...)
proc.Dir = workdir
done := make(chan bool)
done_count := 0
done_count += wrapStdin(proc, os.Stdin, inFlag, done)
if outFlag {
done_co... | package main
import (
"fmt"
"os"
"os/exec"
)
func proto_0_0(inFlag, outFlag bool, errFlag, workdir string, args []string) error {
proc := exec.Command(args[0], args[1:]...)
proc.Dir = workdir
done := make(chan bool)
done_count := 0
done_count += wrapStdin(proc, os.Stdin, inFlag, done)
if outFlag {
done_co... | Fix logic error in error flag handling | Fix logic error in error flag handling | Go | mit | alco/goon,felixbuenemann/goon,felixbuenemann/goon,alco/goon |
564facec9183e6152408543a0bd7d9ad9148da27 | moebot_bot/bot/commands/random.go | moebot_bot/bot/commands/random.go | package commands
import (
"fmt"
"github.com/camd67/moebot/moebot_bot/util/db"
"github.com/camd67/moebot/moebot_bot/util/reddit"
)
type RandomCommand struct {
RedditHandle *reddit.Handle
}
func (ac *RandomCommand) Execute(pack *CommPackage) {
send, err := ac.RedditHandle.GetRandomImage("awwnime")
if err != nil... | package commands
import (
"fmt"
"github.com/camd67/moebot/moebot_bot/util/db"
"github.com/camd67/moebot/moebot_bot/util/reddit"
)
type RandomCommand struct {
RedditHandle *reddit.Handle
}
func (ac *RandomCommand) Execute(pack *CommPackage) {
send, err := ac.RedditHandle.GetRandomImage("awwnime")
if err != nil... | Update help text to only display the andom alias | Update help text to only display the
andom alias
| Go | mit | camd67/moebot,camd67/moebot |
442f64ad9d4812d72bdc6219f3cc158a92d4e54e | sum.go | sum.go | package multihash
import (
"errors"
)
// ErrSumNotSupported is returned when the Sum function code is not implemented
var ErrSumNotSupported = errors.New("Function not implemented. Complain to lib maintainer.")
var ErrLenTooLarge = errors.New("requested length was too large for digest")
// Sum obtains the cryptogr... | package multihash
import (
"errors"
)
// ErrSumNotSupported is returned when the Sum function code is not implemented
var ErrSumNotSupported = errors.New("Function not implemented. Complain to lib maintainer.")
var ErrLenTooLarge = errors.New("requested length was too large for digest")
// Sum obtains the cryptogr... | Remove misplaced optimism about escape analysis. | Remove misplaced optimism about escape analysis.
| Go | mit | jbenet/go-multihash,jbenet/go-multihash |
a06b2733ee93a553a0e7691fa9c476419fb69bf1 | src/aguin/crypto/signed_test.go | src/aguin/crypto/signed_test.go |
package crypto
import (
"testing"
"fmt"
"github.com/stretchr/testify/assert"
)
func TestEncrypt(t *testing.T) {
authKey := []byte("545e0716f2fea0c7a9c46c74fec46c71")
expected := map[string]interface{}{"entity": "something2"}
res, _ := Encrypt(expected, authKey, authKey)
r, _ := Decrypt(res, authKey, authKey)
... |
package crypto
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestEncrypt(t *testing.T) {
authKey := []byte("545e0716f2fea0c7a9c46c74fec46c71")
expected := map[string]interface{}{"entity": "something2"}
res, _ := Encrypt(expected, authKey, authKey)
r, _ := Decrypt(res, authKey, authKey)
assert.... | Remove fmt import since no more use, need to add git hooks :-/ | Remove fmt import since no more use, need to add git hooks :-/
| Go | mit | vanng822/aguin,vanng822/aguin,vanng822/aguin,vanng822/aguin,vanng822/aguin |
9b343d990ef728f08e23c6fee299bcf30e59b039 | unmarshal_test.go | unmarshal_test.go | package main
import (
"testing"
)
func TestParseMaintainer(t *testing.T) {
cases := []struct {
in []byte
want *Maintainer
}{
{[]byte("JohnDoe"), &Maintainer{Name: "JohnDoe"}},
{[]byte("John Doe"), &Maintainer{Name: "John Doe"}},
{[]byte(" John Doe"), &Maintainer{Name: "John Doe"}},
{[]byte("John Doe ... | package main
import (
"testing"
)
func TestParseMaintainer(t *testing.T) {
cases := []struct {
in []byte
want *Maintainer
}{
{[]byte("JohnDoe"), &Maintainer{Name: "JohnDoe"}},
{[]byte("John Doe"), &Maintainer{Name: "John Doe"}},
{[]byte(" John Doe"), &Maintainer{Name: "John Doe"}},
{[]byte("John Doe ... | Fix a test not to compare structs directly | Fix a test not to compare structs directly
| Go | mit | y-taka-23/voicepipe,y-taka-23/voicepipe |
a8875df193de5915ec472414145bd9f952d4cc68 | db/db.go | db/db.go | package db
import (
"database/sql"
"fmt"
"github.com/rafaeljusto/cctldstats/config"
)
// Connection database connection.
var Connection *sql.DB
// Connect performs the database connection. Today the following databases are supported: mysql and postgres
func Connect() (err error) {
var connParams string
switch ... | package db
import (
"database/sql"
"fmt"
"github.com/rafaeljusto/cctldstats/config"
)
// Connection database connection.
var Connection *sql.DB
// Connect performs the database connection. Today the following databases are supported: mysql and postgres
func Connect() (err error) {
var connParams string
switch ... | Disable SSL mode in DB connection for now | Disable SSL mode in DB connection for now
| Go | mit | rafaeljusto/cctldstats |
143de764951ce3a467032c53dead6e7f2a6e0865 | main.go | main.go | package main
import (
"flag"
"runtime"
"gonico"
)
const (
startHelp = "Set start page"
endHelp = "Set end page"
outHelp = "Set download path"
intervalHelp = "Polling interval time (min)"
)
var (
start = flag.Int("start", 1, startHelp)
end = flag.Int("end", 1, endHelp)
out = flag.... | package main
import (
"flag"
"runtime"
"gonico"
)
const (
urlHelp = "The movie url or id from which you want to extract movie infomation."
)
func main() {
movieUrl := flag.String("url", "foo", urlHelp)
flag.Parse()
runtime.GOMAXPROCS(runtime.NumCPU())
gonico.GetVideoInfo(*movieUrl)
}
| Add a command line flag | Add a command line flag
| Go | mit | takuan-osho/gonico |
9e09c7603cb8dc67266e4418043cca91b487b4db | evaluation/errors.go | evaluation/errors.go | package evaluation
import "fmt"
func Err(ctx *Context, msg, tag string, fmts ...interface{}) Object {
msg = fmt.Sprintf(msg, fmts...)
e := &Instance{
Base: ctx.Get("Error"),
}
if e.Base == nil {
panic("Since the prelude isn't loaded, errors cannot be thrown!")
}
e.Data = map[string]Object{
"tag": &Stri... | package evaluation
import "fmt"
// Err returns an error object with the message and tag provided
func Err(ctx *Context, msg, tag string, fmts ...interface{}) Object {
msg = fmt.Sprintf(msg, fmts...)
e := &Instance{
Base: ctx.Get("Error"),
}
if e.Base == nil {
panic("Since the prelude isn't loaded, errors ca... | Add comments to error functions | Add comments to error functions
| Go | mit | pluto-language/pluto |
1be16f01e01f15c4148c7eacf85c9a297e0c038d | tasks/image/push.go | tasks/image/push.go | package image
import (
"io"
"os"
"github.com/dnephin/dobi/tasks/context"
docker "github.com/fsouza/go-dockerclient"
)
// RunPush pushes an image to the registry
func RunPush(ctx *context.ExecuteContext, t *Task, _ bool) (bool, error) {
pushTag := func(tag string) error {
return pushImage(ctx, t, tag)
}
if e... | package image
import (
"io"
"os"
"github.com/dnephin/dobi/tasks/context"
docker "github.com/fsouza/go-dockerclient"
)
// RunPush pushes an image to the registry
func RunPush(ctx *context.ExecuteContext, t *Task, _ bool) (bool, error) {
pushTag := func(tag string) error {
return pushImage(ctx, tag)
}
if err ... | Fix lint error, unused param | Fix lint error, unused param
| Go | apache-2.0 | dnephin/dobi,dnephin/dobi |
d2b79eddb0e79fcf29f697731ef60a5c0837c484 | lxd/state/testing.go | lxd/state/testing.go | //go:build linux && cgo && !agent
// +build linux,cgo,!agent
package state
import (
"context"
"testing"
"github.com/lxc/lxd/lxd/db"
"github.com/lxc/lxd/lxd/firewall"
"github.com/lxc/lxd/lxd/sys"
)
// NewTestState returns a State object initialized with testable instances of
// the node/cluster databases and of... | //go:build linux && cgo && !agent
// +build linux,cgo,!agent
package state
import (
"context"
"testing"
"github.com/lxc/lxd/lxd/db"
"github.com/lxc/lxd/lxd/firewall"
"github.com/lxc/lxd/lxd/sys"
)
// NewTestState returns a State object initialized with testable instances of
// the node/cluster databases and of... | Update tests with NewState usage | lxd/state: Update tests with NewState usage
Signed-off-by: Thomas Parrott <6b778ce645fb0e3dde76d79eccad490955b1ae74@canonical.com>
| Go | apache-2.0 | atxwebs/lxd,atxwebs/lxd,lxc/lxd,lxc/lxd,atxwebs/lxd,atxwebs/lxd,hallyn/lxd,hallyn/lxd,lxc/lxd,lxc/lxd,lxc/lxd,hallyn/lxd,hallyn/lxd,hallyn/lxd,stgraber/lxd,stgraber/lxd,hallyn/lxd,stgraber/lxd,stgraber/lxd,lxc/lxd,lxc/lxd,stgraber/lxd,stgraber/lxd,stgraber/lxd |
0af0796ae57311e1828f135161cc19dcb55d8105 | statemachine/statemachine.go | statemachine/statemachine.go | package statemachine
import (
"log"
"os"
)
type Handler func() string
type Machine struct {
Handlers map[string]Handler
Logger *log.Logger
}
type StateMachineError struct {
State string
}
func (sme StateMachineError) Error() string {
return "statemachine: No handler function registered for state: " + sme.S... | package statemachine
import (
"log"
"os"
)
type Handler func() string
type Machine struct {
Handlers map[string]Handler
Logger *log.Logger
}
type StateMachineError struct {
State string
}
func (sme StateMachineError) Error() string {
return "ERROR: No handler function registered for state: " + sme.State
}
... | Add levels to log output | Add levels to log output
| Go | mit | christianberg/boxrunner |
6051c6372ddad9326d591477ee14dde484772ff6 | netascii/netascii.go | netascii/netascii.go | package netascii
import (
"bufio"
"bytes"
"io"
)
func WriteTo(b []byte, bw *bufio.Writer) (n int, err error) {
b = bytes.Replace(b, []byte{'\r', 0}, []byte{'\r'}, -1)
b = bytes.Replace(b, []byte{'\r', '\n'}, []byte{'\n'}, -1)
n, err = bw.Write(b)
if err != nil {
return 0, err
}
return n, nil
}
func Conver... | package netascii
import (
"bufio"
"bytes"
"io"
)
func WriteTo(b []byte, bw *bufio.Writer) (n int, err error) {
b = bytes.Replace(b, []byte{'\r', 0}, []byte{'\r'}, -1)
b = bytes.Replace(b, []byte{'\r', '\n'}, []byte{'\n'}, -1)
n, err = bw.Write(b)
if err != nil {
return n, err
}
return n, nil
}
func Conver... | Return the actual size written to bw, even when an error occurs. | Return the actual size written to bw, even when an error occurs.
| Go | apache-2.0 | marcelki/tftp |
f2c87d2930e64db4eec51b74db8b7d321a6d480a | crc16.go | crc16.go | package dexcom
//go:generate ../gen_crc_table/gen_crc_table
func crc16(msg []byte) []byte {
res := uint16(0)
for _, b := range msg {
res = res<<8 ^ crc16Table[byte(res>>8)^b]
}
return MarshalUint16(res)
}
| package dexcom
//go:generate ../crcgen/crcgen
func crc16(msg []byte) []byte {
res := uint16(0)
for _, b := range msg {
res = res<<8 ^ crc16Table[byte(res>>8)^b]
}
return MarshalUint16(res)
}
| Change CRC table generator to "crcgen" | Change CRC table generator to "crcgen"
| Go | mit | ecc1/dexcom |
009f8981aabf58e5baf4f1c652bb538ea6d541c5 | 2021/tls/https-server.go | 2021/tls/https-server.go | package main
import (
"crypto/tls"
"flag"
"fmt"
"log"
"net/http"
"time"
)
func main() {
addr := flag.String("addr", ":4000", "HTTP network address")
certFile := flag.String("certfile", "cert.pem", "certificate PEM file")
keyFile := flag.String("keyfile", "key.pem", "key PEM file")
flag.Parse()
tlsConfig :... | package main
import (
"crypto/tls"
"flag"
"fmt"
"log"
"net/http"
)
func main() {
addr := flag.String("addr", ":4000", "HTTP network address")
certFile := flag.String("certfile", "cert.pem", "certificate PEM file")
keyFile := flag.String("keyfile", "key.pem", "key PEM file")
flag.Parse()
mux := http.NewServ... | Tweak server to be shorter | Tweak server to be shorter
| Go | unlicense | eliben/code-for-blog,eliben/code-for-blog,eliben/code-for-blog,eliben/code-for-blog,eliben/code-for-blog,eliben/code-for-blog,eliben/code-for-blog,eliben/code-for-blog,eliben/code-for-blog,eliben/code-for-blog,eliben/code-for-blog |
a4bfead8819da655e78d990680d200fae519cc55 | cmd/kube-dns/dns.go | cmd/kube-dns/dns.go | /*
Copyright 2016 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 2016 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, ... | Split the version metric out to its own package | Split the version metric out to its own package
| Go | apache-2.0 | bowei/dns,bowei/dns,cmluciano/dns,kubernetes/dns,corlettb/dns,kubernetes/dns,cmluciano/dns,corlettb/dns,kubernetes/dns |
77e0cadc1eba7101344af34a73a39654221d8b93 | crypto/rand_test.go | crypto/rand_test.go | package crypto
import (
"testing"
)
// TestRandIntnPanics tests that RandIntn panics if n <= 0.
func TestRandIntnPanics(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Error("expected panic for n <= 0")
}
}()
RandIntn(0)
RandIntn(-1)
}
| package crypto
import (
"testing"
)
// TestRandIntnPanics tests that RandIntn panics if n <= 0.
func TestRandIntnPanics(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Error("expected panic for n <= 0")
}
}()
_, err := RandIntn(0)
if err != nil {
t.Error("expected panic on n <= 0, not er... | Add error checks to TestRandIntnPanics | Add error checks to TestRandIntnPanics
RandIntn should panic, not error on n <= 0
| Go | mit | ericflo/Sia,mnsl/Sia,Mingling94/Sia,NebulousLabs/Sia,mharkus/Sia,MrStrong/Sia,mtlynch/Sia,ChrisSchinnerl/Sia,rivine/rivine,NebulousLabs/Sia,rivine/rivine,MrStrong/Sia,mnsl/Sia,mtlynch/Sia,ChrisSchinnerl/Sia,ericflo/Sia,johnathanhowell/Sia,mharkus/Sia |
d276e040aaf0971105dbde4be159417e7e01162d | cmd/crazyradio-scan/main.go | cmd/crazyradio-scan/main.go | // Utility scans spectrum and shows channels on which Crazyflies found
package main
import (
"log"
"github.com/krasin/crazyradio"
)
func main() {
st, err := crazyradio.Start(nil)
if err != nil {
log.Fatal(err)
}
addr, err := st.Scan()
if err != nil {
log.Fatalf("Scan failed: %v", err)
}
log.Printf("Foun... | // Utility scans spectrum and shows channels on which Crazyflies found
package main
import (
"log"
"github.com/krasin/crazyradio"
"github.com/krasin/crazyradio/usb"
)
func main() {
st, err := crazyradio.Start(usb.Hub)
if err != nil {
log.Fatal(err)
}
addr, err := st.Scan()
if err != nil {
log.Fatalf("Sca... | Fix nil reference panic in crazyradio-scan. Pass usb.Hub to station.Start, instead of nil | Fix nil reference panic in crazyradio-scan. Pass usb.Hub to station.Start, instead of nil
| Go | mit | samofly/cflie |
63603f42b2802fa71d8a0a6ab56f39be2615c7e5 | pty_freebsd_nocgo.go | pty_freebsd_nocgo.go | // +build freebsd,!cgo
/*
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 app... | // +build freebsd,!cgo
/*
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 app... | Add missing import in freebsd nocgo stub | Add missing import in freebsd nocgo stub
Signed-off-by: Shengjing Zhu <2dd997cfa01a89f57dd2ea7f2dd61043cc88e07b@debian.org>
| Go | apache-2.0 | containerd/console |
b43683f05ba1453e302ffed77c04ed124bf330d4 | dice/die_test.go | dice/die_test.go | package dice
import "testing"
func TestRollable(t *testing.T) {
var attackDie AttackDie
var defenseDie DefenseDie
attackDie.Roll()
defenseDie.Roll()
}
| package dice
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestRollable_AttackDie(t *testing.T) {
assert := assert.New(t)
var attackDie AttackDie
var blanks, focuses, hits, crits int
attackDie.Roll()
for i := 0; i < 1000; i++ {
switch attackDie.Result() {
case BLANK:
blanks++
case F... | Add test for die rolling. | Add test for die rolling.
| Go | mit | geordanr/go_xwing,geordanr/go_xwing,geordanr/go_xwing |
2258533f00d6e8383052a06976b86e627bf1cc11 | dom/herd/httpd.go | dom/herd/httpd.go | package herd
import (
"fmt"
"net"
"net/http"
)
var httpdHerd *Herd
func (herd *Herd) startServer(portNum uint, daemon bool) error {
listener, err := net.Listen("tcp", fmt.Sprintf(":%d", portNum))
if err != nil {
return err
}
httpdHerd = herd
http.HandleFunc("/", statusHandler)
http.HandleFunc("/listSubs",... | package herd
import (
"fmt"
"net"
"net/http"
)
var httpdHerd *Herd
func (herd *Herd) startServer(portNum uint, daemon bool) error {
listener, err := net.Listen("tcp", fmt.Sprintf(":%d", portNum))
if err != nil {
return err
}
httpdHerd = herd
http.HandleFunc("/", statusHandler)
http.HandleFunc("/listSubs",... | Fix bug: list of all subs did not work. | Fix bug: list of all subs did not work.
Bug introduced in commit 08c68b5a85bc9ab42391c6b3bb65942d4c9dce6b.
| Go | apache-2.0 | rgooch/Dominator,Symantec/Dominator,Symantec/Dominator,keep94/Dominator,keep94/Dominator,keep94/Dominator,rgooch/Dominator,Symantec/Dominator,rgooch/Dominator |
6e4b9c696f71ab416079ee901a157f24f6ae6bcf | src/lib/time/tick_test.go | src/lib/time/tick_test.go | // Copyright 2009 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 time
import (
"testing";
"time";
)
export func TestTick(t *testing.T) {
const (
Delta uint64 = 100*1e6;
Count uint64 = 10;
);
c := Tick(Delta... | // Copyright 2009 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 time
import (
"testing";
"time";
)
export func TestTick(t *testing.T) {
const (
Delta = 100*1e6;
Count = 10;
);
c := Tick(Delta);
t0 := Nano... | Remove types from constants, since they didn't match what Tick() expected. | Remove types from constants, since they didn't match what
Tick() expected.
R=rsc
DELTA=2 (0 added, 0 deleted, 2 changed)
OCL=22979
CL=22986
| Go | bsd-3-clause | XuYunnan/go,suncycheng/go,malvira/go,deft-code/go,frobware/go,chinanjjohn2012/go,andrewchambers/go,vsekhar/elastic-go,richo/go,dgnorton/go,pgmreddy/go,waterlink/go,Cofyc/go,9618211/go,minux/go-windows,chinanjjohn2012/go,albertjin/golang-go,dafyddcrosby/go,jacobsa/go,shawnl/go,9618211/go,danielsoro/go,mbrukman/go,dafydd... |
f9ee6c4ccec0bfca077b484f4f4867c988384650 | version/version.go | version/version.go | package version
type Version struct {
GitSHA string
Version string
}
var VersionInfo = Version{
GitSHA: gitSha,
Version: version,
}
const gitSha = "unknown"
const version = "0.1"
| package version
type Version struct {
GitCommit string
Version string
}
var VersionInfo = unknownVersion
var unknownVersion = Version{
GitCommit: "unknown git commit",
Version: "unknown version",
}
| Change back to git commit | Change back to git commit
| Go | agpl-3.0 | ericsnowcurrently/juju-charmstore,mhilton/charmstore,urosj/charmstore-1,mhilton/charmstore,makyo/charmstore,mhilton/juju-charmstore,jrwren/charmstore,fabricematrat/charmstore,fabricematrat/charmstore,wallyworld/charmstore,juju/charmstore,makyo/charmstore,urosj/charmstore-1,wallyworld/charmstore,frankban/charmstore,fran... |
94739f50927845013ce01a310fbfc2a23855be15 | collector/metrics.go | collector/metrics.go | package collector
import "github.com/prometheus/client_golang/prometheus"
const namespace = "ipmi"
var (
temperatures = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "temperatures"),
"Contains the collected temperatures from IPMI",
[]string{"sensor"},
nil,
)
fanspeed = prometheus.NewDesc(
p... | package collector
import "github.com/prometheus/client_golang/prometheus"
const namespace = "ipmi"
var (
temperatures = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "", "temperatures"),
"Contains the collected temperatures from IPMI",
[]string{"sensor"},
nil,
)
fanspeed = prometheus.NewDesc(
p... | Fix go format with go fmt | Fix go format with go fmt
| Go | bsd-3-clause | lovoo/ipmi_exporter,lovoo/ipmi_exporter |
1e52da8ed1a84cdb8e36aedec0d90ef637f72099 | src/cmd/dtodo/main.go | src/cmd/dtodo/main.go | package main
func main() {
}
| package main
import (
"log"
"pault.ag/go/debian/control"
"pault.ag/go/debian/dependency"
"pault.ag/go/resolver"
)
func main() {
log.SetFlags(log.Lshortfile)
// TODO configurable path? perhaps allow for an optional *.dsc instead?
con, err := control.ParseControlFile("debian/control")
if err != nil {
log.F... | Throw in some initial basic code so we have something to work with | Throw in some initial basic code so we have something to work with
| Go | mit | tianon/dtodo |
e8c2f51ea4163622526a670c7d6225ddc1c8fe4b | helpers/js.go | helpers/js.go | package helpers
func ConvertTypeForJS(s string) string {
conv := map[string]string{
"array": "array",
"boolean": "boolean",
"integer": "number",
"number": "number",
"object": "object",
"string": "string",
}
return conv[s]
}
| package helpers
func ConvertTypeForJS(s string) string {
v, ok := map[string]string{
"integer": "number",
}[s]
if !ok {
return s
}
return v
}
| Return given type when target is not found | Return given type when target is not found
| Go | mit | go-jstmpl/go-jstmpl,minodisk/go-jstmpl |
fd6982c0c6c53d66e35658aa4beb8cb2c1de74a2 | util/util.go | util/util.go | // Copyright 2016 Albert Nigmatzianov. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package util
import (
"os"
"path/filepath"
"strconv"
"strings"
)
const (
millisecondsInSecond = 1000
secondsInMinute = 60
minutesInHour ... | // Copyright 2016 Albert Nigmatzianov. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package util
import (
"os"
"path/filepath"
"strconv"
"strings"
)
const (
millisecondsInSecond = 1000
secondsInMinute = 60
minutesInHour ... | Rename duration arg to milliseconds in ParseDuration | Rename duration arg to milliseconds in ParseDuration
| Go | mit | bogem/nehm |
8b3b3d98b7388c65581dab06b90ced2f82e8a73f | cli/app/version.go | cli/app/version.go | package app
import (
"fmt"
"os"
"runtime"
"text/template"
"github.com/Sirupsen/logrus"
"github.com/docker/libcompose/version"
"github.com/urfave/cli"
)
var versionTemplate = `Version: {{.Version}} ({{.GitCommit}})
Go version: {{.GoVersion}}
Built: {{.BuildTime}}
OS/Arch: {{.Os}}/{{.Arch}}`
... | package app
import (
"fmt"
"os"
"runtime"
"text/template"
"github.com/Sirupsen/logrus"
"github.com/docker/libcompose/version"
"github.com/urfave/cli"
)
var versionTemplate = `Version: {{.Version}} ({{.GitCommit}})
Go version: {{.GoVersion}}
Built: {{.BuildTime}}
OS/Arch: {{.Os}}/{{.Arch}}`
... | Update Version signature to remove warning | Update Version signature to remove warning
Signed-off-by: Vincent Demeester <87e1f221a672a14a323e57bb65eaea19d3ed3804@sbr.pm>
| Go | apache-2.0 | vdemeester/libcompose,weitenghuang/libcompose,vito-c/libcompose,docker/libcompose,vito-c/libcompose,jainvipin/libcompose,dweomer/docker-libcompose,Azure22/libcompose,jainvipin/libcompose,weitenghuang/libcompose,Azure22/libcompose,dweomer/docker-libcompose,docker/libcompose,vdemeester/libcompose |
181822dd2b2187367f11cbcaf16c261fc16f4849 | table-of-contents/handler/main.go | table-of-contents/handler/main.go | package handler
import (
"go/build"
"log"
"net/http"
"path/filepath"
"github.com/shurcooL/go/gopherjs_http"
"github.com/shurcooL/httpfs/httputil"
"github.com/shurcooL/httpfs/vfsutil"
)
func init() {
// HACK: This code registers routes at root on default mux... That's not very nice.
http.Handle("/table-of-co... | package handler
import (
"go/build"
"log"
"net/http"
"path/filepath"
"github.com/shurcooL/go/gopherjs_http"
"github.com/shurcooL/httpfs/httputil"
"github.com/shurcooL/httpfs/vfsutil"
)
func init() {
// HACK: This code registers routes at root on default mux... That's not very nice.
http.Handle("/table-of-co... | Use keyed fields in composite literal. | table-of-contents/handler: Use keyed fields in composite literal.
Fixes go vet issue.
| Go | mit | shurcooL/frontend,shurcooL/frontend |
0e84598e29d091bc4274409c1df02260e2dcefb0 | git.go | git.go | package main
// gitVersion returns the tag of the HEAD, if one exists,
// or else the commit hash.
func gitVersion() string {
tag := cmd("git", "tag", "--contains", "HEAD").OutputLine()
if tag != "" {
return tag
}
return cmd("git", "rev-parse", "--short", "HEAD").OutputLine()
}
| package main
import "os/exec"
// gitVersion returns one of the following:
// - Git tag of the HEAD if one exists, or
// - Commit hash of the HEAD, or
// - Empty string if Git is not in the PATH.
func gitVersion() string {
cmdName := "git"
if _, err := exec.LookPath(cmdName); err != nil {
return ""
}
tag := cm... | Check that Git is in the PATH | Check that Git is in the PATH
fixes #1
| Go | mit | samherrmann/gowrap |
544e3058008e94569a463d2849034d65739f0a4c | langdet/models.go | langdet/models.go | package langdet
// Token represents a text token and its occurence in an analyzed text
type Token struct {
Occurrence int
Key string
}
// ByOccurrence represents an array of tokens which can be sorted by occurrences of the tokens.
type ByOccurrence []Token
func (a ByOccurrence) Len() int { return len(a... | package langdet
// Token represents a text token and its occurence in an analyzed text
type Token struct {
Occurrence int
Key string
}
// ByOccurrence represents an array of tokens which can be sorted by occurrences of the tokens.
type ByOccurrence []Token
func (a ByOccurrence) Len() int { return len(a... | Fix typo in ngram sorting code. | Fix typo in ngram sorting code. | Go | apache-2.0 | chrisport/go-lang-detector |
d734313a15076bf107024fabb6d8f65f492a1622 | ptypes/closestint.go | ptypes/closestint.go | // Copyright (c) 2015, Peter Mrekaj. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE.txt file.
package ptypes
// IntWeight returns number of bits set to 1 in x.
func IntWeight(x uint64) (w int) {
for x > 0 {
w++
x &= (x - 1)
}
return w
}
/... | // Copyright (c) 2015, Peter Mrekaj. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE.txt file.
package ptypes
// IntWeight returns number of bits set to 1 in x.
func IntWeight(x uint64) (w int) {
for x > 0 {
w++
x &= (x - 1)
}
return w
}
/... | Add time/space compexity analysis for ptypes.ClosestInt function | Add time/space compexity analysis for ptypes.ClosestInt function
| Go | mit | mrekucci/epi,mrekucci/epi |
d819d52e60622806e94fcd99ed82e59dc889f42e | lxc/exec_windows.go | lxc/exec_windows.go | // +build windows
package main
import (
"io"
"os"
"github.com/gorilla/websocket"
"github.com/mattn/go-colorable"
"github.com/lxc/lxd/shared/logger"
)
// Windows doesn't process ANSI sequences natively, so we wrap
// os.Stdout for improved user experience for Windows client
type WrappedWriteCloser struct {
io... | // +build windows
package main
import (
"io"
"os"
"os/signal"
"syscall"
"github.com/gorilla/websocket"
"github.com/mattn/go-colorable"
"github.com/lxc/lxd/shared/logger"
)
// Windows doesn't process ANSI sequences natively, so we wrap
// os.Stdout for improved user experience for Windows client
type Wrapped... | Fix signal handler for Windows | lxc/exec: Fix signal handler for Windows
Closes #3496
Signed-off-by: Stéphane Graber <089afc6d81f66f1168a9849e15660feae286e024@ubuntu.com>
| Go | apache-2.0 | lxc/lxd,stgraber/lxd,Skarlso/lxd,lxc/lxd,Skarlso/lxd,hallyn/lxd,erikmack/lxd,stgraber/lxd,stgraber/lxd,lxc/lxd,Skarlso/lxd,mjeanson/lxd,Skarlso/lxd,lxc/lxd,stgraber/lxd,lxc/lxd,atxwebs/lxd,erikmack/lxd,hallyn/lxd,erikmack/lxd,atxwebs/lxd,hallyn/lxd,mjeanson/lxd,stgraber/lxd,hallyn/lxd,pcdummy/lxd,atxwebs/lxd,lxc/lxd,st... |
6155cdba0bb5a316ffa7105dafa4224c9fec9fc1 | components/cmd_to_param_test.go | components/cmd_to_param_test.go | package components
import (
"testing"
"github.com/scipipe/scipipe"
)
func TestCommandToParams(tt *testing.T) {
// Run test workflow and make sure that the parameter read from the file is
// always "abc"
wf := scipipe.NewWorkflow("wf", 4)
cmdToParams := NewCommandToParams(wf, "cmdtoparams", "echo foo; echo bar... | package components
import (
"testing"
"github.com/scipipe/scipipe"
)
func TestCommandToParams(tt *testing.T) {
// Run test workflow and make sure that the parameter read from the file is
// always "abc"
wf := scipipe.NewWorkflow("wf", 4)
cmdToParams := NewCommandToParams(wf, "cmdtoparams", "{ echo foo; echo b... | Improve shell command in test | Improve shell command in test
| Go | mit | scipipe/scipipe,samuell/scipipe,scipipe/scipipe |
2f58cbdf8834fe79c36f4cb5428151d0c559bbab | entities/init_test.go | entities/init_test.go | package entities
import "time"
var (
timeStamp int64 = time.Date(2012, time.November, 10, 23, 0, 0, 0, time.UTC).UnixNano() / 1e6
mission Mission = Mission{
Color: Color{22, 22, 22},
Source: []int{100, 200},
Target: []int{800, 150},
Type: "Attack",
CurrentTime: timeStamp,
Star... | package entities
import "time"
var (
timeStamp int64 = time.Date(2012, time.November, 10, 23, 0, 0, 0, time.UTC).UnixNano() / 1e6
mission Mission = Mission{
Color: Color{22, 22, 22},
Source: []int{100, 200},
Target: []int{800, 150},
Type: "Attack",
CurrentTime: timeStamp,
Star... | Add player in the test data | Add player in the test data
| Go | mit | WarCluster/warcluster-server,WarCluster/warcluster-server |
d6bd609df37b4b60dcdad123ee607417fa2b38b9 | hello_world/go/hello_world.go | hello_world/go/hello_world.go | package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
| package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
| Update go hello world with tab instead of spaces indentation. | Update go hello world with tab instead of spaces indentation.
| Go | mit | jbranchaud/hello-world,jbranchaud/hello-world,jbranchaud/hello-world,jbranchaud/hello-world,jbranchaud/hello-world,jbranchaud/hello-world |
24c8425a8b65e4e18146bf487f22898873b488f7 | src/lib/core/bool_test.go | src/lib/core/bool_test.go | package core
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBoolEqual(t *testing.T) {
for _, ts := range [][2]*Thunk{
{True, True},
{False, False},
} {
assert.True(t, testEqual(ts[0], ts[1]))
}
for _, ts := range [][2]*Thunk{
{True, False},
{False, True},
} {
assert.True(t, !t... | package core
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBoolEqual(t *testing.T) {
for _, ts := range [][2]*Thunk{
{True, True},
{False, False},
} {
assert.True(t, testEqual(ts[0], ts[1]))
}
for _, ts := range [][2]*Thunk{
{True, False},
{False, True},
} {
assert.True(t, !t... | Increase test coverange of core/bool.go | Increase test coverange of core/bool.go
| Go | mit | raviqqe/tisp,raviqqe/tisp,tisp-lang/tisp,tisp-lang/tisp,raviqqe/tisp |
9d477a0b0ceb63bba152b82a8e0de8dfb94c93f7 | parse_test.go | parse_test.go | package narcissus
import (
"testing"
"honnef.co/go/augeas"
)
type foo struct {
}
func TestParseNotAPtr(t *testing.T) {
n := New(&augeas.Augeas{})
err := n.Parse(foo{}, "/files/some/path")
if err == nil {
t.Error("Expected an error, got nothing")
}
if err.Error() != "not a ptr" {
t.Errorf("Expected erro... | package narcissus
import (
"testing"
"honnef.co/go/augeas"
)
type foo struct {
A string `path:"a"`
}
func TestParseNotAPtr(t *testing.T) {
n := New(&augeas.Augeas{})
err := n.Parse(foo{}, "/files/some/path")
if err == nil {
t.Error("Expected an error, got nothing")
}
if err.Error() != "not a ptr" {
t.... | Add test for field not found (currently failing) | Add test for field not found (currently failing)
| Go | apache-2.0 | raphink/narcissus |
613ada987d2da5d1bcbbd7d4fd40ef0ab69132c2 | internal/common/common_linux.go | internal/common/common_linux.go | // +build linux
package common
import "os"
func NumProcs() (uint64, error) {
f, err := os.Open(HostProc())
if err != nil {
return 0, err
}
list, err := f.Readdir(-1)
defer f.Close()
if err != nil {
return 0, err
}
return uint64(len(list)), err
}
| // +build linux
package common
import (
"os"
"os/exec"
"strings"
)
func DoSysctrl(mib string) ([]string, error) {
err := os.Setenv("LC_ALL", "C")
if err != nil {
return []string{}, err
}
sysctl, err := exec.LookPath("/sbin/sysctl")
if err != nil {
return []string{}, err
}
out, err := exec.Command(sysct... | Add DoSysctrl() to Linux's common utilities. | Add DoSysctrl() to Linux's common utilities.
| Go | bsd-3-clause | influxdb/gopsutil,influxdb/gopsutil |
36cfe2218a5a7f833175c45635834faa9978b93d | compat_go18.go | compat_go18.go | // +build go1.8
package avatica
import (
"database/sql/driver"
"fmt"
)
type namedValue struct {
Name string
Ordinal int
Value driver.Value
}
func driverValueToNamedValue(values []driver.Value) []namedValue {
list := make([]namedValue, len(values))
for i, v := range values {
list[i] = namedValue{
O... | package avatica
import (
"database/sql/driver"
"fmt"
)
type namedValue struct {
Name string
Ordinal int
Value driver.Value
}
func driverValueToNamedValue(values []driver.Value) []namedValue {
list := make([]namedValue, len(values))
for i, v := range values {
list[i] = namedValue{
Ordinal: i + 1,
... | Remove go 1.8 build tag for compatibility structs and constants | Remove go 1.8 build tag for compatibility structs and constants
| Go | apache-2.0 | Boostport/calcite-avatica-go,Boostport/calcite-avatica-go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.