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
485935a9fc776a65e38b67d2d3746f8da4f57993
attachments.go
attachments.go
package slack // https://api.slack.com/docs/attachments // It is possible to create more richly-formatted messages using Attachments. type AttachmentField struct { Title string `json:"title"` Value string `json:"value"` Short bool `json:"short"` } type Attachment struct { Color string `json:"color,omitempty"...
package slack // https://api.slack.com/docs/attachments // It is possible to create more richly-formatted messages using Attachments. type AttachmentField struct { Title string `json:"title"` Value string `json:"value"` Short bool `json:"short"` } type Attachment struct { Color string `json:"color,omitempty"...
Add footer fields to Attachment
Add footer fields to Attachment
Go
mit
bluele/slack
8d74280caf163c26c084d042a31fc301b5913b4f
pkg/identity/identity.go
pkg/identity/identity.go
/* Package identity provides type that allows to authorize request */ package identity import ( "github.com/google/uuid" ) // Identity data to be encode in auth token type Identity struct { ID uuid.UUID `json:"id"` Email string `json:"email"` Roles []string `json:"roles"` } // WithEmail returns a new Iden...
/* Package identity provides type that allows to authorize request */ package identity import ( "github.com/google/uuid" ) // Identity data to be encode in auth token type Identity struct { ID uuid.UUID `json:"id"` Email string `json:"email"` Roles []string `json:"roles"` } // WithEmail returns a new Iden...
Remove some err checks, return it directly
Remove some err checks, return it directly
Go
mit
vardius/go-api-boilerplate,vardius/go-api-boilerplate,vardius/go-api-boilerplate
d9f9fb14a7bb6fec351384a3cce1e7495b17da31
api/oidc.go
api/oidc.go
package api import ( "errors" "fmt" ) var ErrAudienceTooLong = errors.New("the API only supports at most one element in the audience") type OidcToken struct { Token string `json:"token"` } func (c *Client) OidcToken(jobId string, audience ...string) (*OidcToken, *Response, error) { type oidcTokenRequest struct ...
package api import ( "errors" "fmt" ) var ErrAudienceTooLong = errors.New("the API only supports at most one element in the audience") type OidcToken struct { Token string `json:"token"` } func (c *Client) OidcToken(jobId string, audience ...string) (*OidcToken, *Response, error) { type oidcTokenRequest struct ...
Add a comment about audience
Add a comment about audience
Go
mit
buildkite/agent,buildkite/agent,buildkite/agent
eb2c30a26b5e139d5f8f0045d09fc53c264b5a9a
example/main.go
example/main.go
package main import ( "github.com/op/go-logging" "github.com/CaliDog/certstream-go" ) var log = logging.MustGetLogger("example") func main() { stream := certstream.CertStreamEventStream(false) for jq := range stream { message_type, err := jq.String("message_type") if err != nil { log.Fatalf("Error pars...
package main import ( "github.com/CaliDog/certstream-go" logging "github.com/op/go-logging" ) var log = logging.MustGetLogger("example") func main() { stream := certstream.CertStreamEventStream(false) for jq := range stream { message_type, err := jq.String("message_type") if err != nil { log.Fatalf("Er...
Add proper library prefix in example.
Add proper library prefix in example.
Go
mit
CaliDog/certstream-go
a3c6388aa272447266d978ab905fa665746fd527
server/response/main.go
server/response/main.go
package response import ( "encoding/json" "time" ) type Response interface { MakeATimestamp() } type baseResponse struct { Command string Timestamp int64 } func (r *baseResponse) MakeATimestamp() { r.Timestamp = time.Now().UnixNano() / 1e6 } func Send(r Response, sender func([]byte)) error { r.MakeATimest...
package response import ( "encoding/json" "time" ) type Timestamp int64 type baseResponse struct { Command string Timestamp Timestamp } func (t *Timestamp) MarshalJSON() ([]byte, error) { return json.Marshal(time.Now().UnixNano() / 1e6) } func Send(r interface{}, sender func([]byte)) error { serialized, er...
Fix the marshaling of timestamp in response
Fix the marshaling of timestamp in response
Go
mit
WarCluster/warcluster-server,WarCluster/warcluster-server
863c6c5b91a29633c91272ae838f1509b4d2247b
blockfreight/cmd/leveldb-test/leveldb-test.go
blockfreight/cmd/leveldb-test/leveldb-test.go
package main import ( "fmt" "strconv" "github.com/blockfreight/blockfreight-alpha/blockfreight/bft/leveldb" ) func main() { //db_path := "bft-db/db" db_path := "bft-db" db, err := leveldb.OpenDB(db_path) defer leveldb.CloseDB(db) leveldb.HandleError(err, "Create or Open Database") //fmt.Println("Database cr...
package main import ( "fmt" "strconv" "github.com/blockfreight/blockfreight-alpha/blockfreight/bft/leveldb" ) func main() { //db_path := "bft-db/db" db_path := "bft-db" db, err := leveldb.OpenDB(db_path) defer leveldb.CloseDB(db) leveldb.HandleError(err, "Create or Open Database") //fmt.Println("Database cr...
Move code to a db library
Move code to a db library
Go
mit
blockfreight/go-bftx,blockfreight/go-bftx,blockfreight/blockfreight-alpha
f12ee16e5bedc485598ec4e76c3dc6c292f88584
integration/integration_suite_test.go
integration/integration_suite_test.go
package integration_test import ( "io/ioutil" "os" "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" bmtestutils "github.com/cloudfoundry/bosh-micro-cli/testutils" ) func TestIntegration(t *testing.T) { RegisterFailHandler(Fail) BeforeSuite(func() { err := bmtestutils.BuildExecutable() Exp...
package integration_test import ( "io/ioutil" "os" "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" bmtestutils "github.com/cloudfoundry/bosh-micro-cli/testutils" ) func TestIntegration(t *testing.T) { RegisterFailHandler(Fail) BeforeSuite(func() { err := bmtestutils.BuildExecutable() Exp...
Remove bosh-micro-cli from 'Integration Suite'
Remove bosh-micro-cli from 'Integration Suite'
Go
apache-2.0
allomov/bosh-init,forrestsill/bosh-init,cloudfoundry/bosh-init,cloudfoundry/bosh-init,allomov/bosh-init,allomov/bosh-init,cloudfoundry/bosh-init,forrestsill/bosh-init,forrestsill/bosh-init
3e43b363701eb1744e9b628e00569231cf91e582
doc.go
doc.go
// Package vpki provides a layer of abstraction between the golang stdlib // crypto primitives and common crypto uses (e.g. serving HTTPS) and the // functionality provided by Vault. Internally, the library generates private // keys locally and sends CSRs to the vault server, so that private keys are // never transmitt...
// Package vpki provides a layer of abstraction between the golang stdlib // crypto primitives and common crypto uses (e.g. serving HTTPS) and the // functionality provided by Vault. Internally, the library generates private // keys locally and sends CSRs to the vault server, so that private keys are // never transmitt...
Update import statement to only allow single source
Update import statement to only allow single source
Go
mit
andrewstuart/vpki
ef81eac9f1cb1355afc9f079bbaef2a2baf1dfe9
handlers.go
handlers.go
package main import ( "fmt" "log" "net/http" "time" "github.com/labstack/echo" ) func (h *Handler) getGithubRepoHealth(c echo.Context) error { db := h.DB.Clone() defer db.Close() owner := c.Param("owner") repo := c.Param("repo") queryParams := c.QueryParams() health := &Health{ RepositoryName: fmt.Spr...
package main import ( "fmt" "log" "net/http" "time" "github.com/labstack/echo" ) func (h *Handler) getGithubRepoHealth(c echo.Context) error { db := h.DB.Clone() defer db.Close() owner := c.Param("owner") repo := c.Param("repo") queryParams := c.QueryParams() health := &Health{ RepositoryName: fmt.Spr...
Return full URL in health
Return full URL in health
Go
mit
hasit/healthyrepo,hasit/healthyrepo,hasit/healthyrepo
5733d1e8997727dff6a60ff4b2c1503cca92a295
examples/cmdline/main.go
examples/cmdline/main.go
// TODO // * improve JRD output // * do stuff with the JRD package main import ( "flag" "fmt" "github.com/ant0ine/go-webfinger" "io/ioutil" "log" "os" ) func printHelp() { fmt.Println("webfinger [-vh] <resource uri>") flag.PrintDefaults() fmt.Println("example: webfinger -v bob@example.com") // same Bob as in...
// TODO // * improve JRD output // * do stuff with the JRD package main import ( "encoding/json" "flag" "fmt" "github.com/ant0ine/go-webfinger" "io/ioutil" "log" "os" ) func printHelp() { fmt.Println("webfinger [-vh] <resource uri>") flag.PrintDefaults() fmt.Println("example: webfinger -v bob@example.com") ...
Change the output for a nicely indented JSON...
Change the output for a nicely indented JSON... ...until I get more sophisticated ideas about what to do with the data.
Go
mit
ant0ine/go-webfinger
1e0b729163c3ff9c01813fd459bd668ca17db0a9
goat/logger.go
goat/logger.go
package goat import ( "bufio" "fmt" "log" "os" "time" ) // LogManager is responsible for creating the main loggers func LogManager() { // Create log directory and file, and pull current date to add to logfile name now := time.Now() os.Mkdir("logs", os.ModeDir|os.ModePerm) logFile, err := os.Create(fmt.Sprint...
package goat import ( "fmt" "time" ) // LogManager is responsible for creating the main loggers func LogManager() { // Start the system status logger go StatusLogger() // Wait for error to be passed on the logChan channel, or termination signal for { select { case msg := <-Static.LogChan: now := time.No...
Remove file logging for now, as it is broken
Remove file logging for now, as it is broken
Go
mit
mdlayher/goat
cc30bf92c079553cbf9fefea70820d5e4f8aa5ee
ascending_node.go
ascending_node.go
package rel import ( "reflect" ) type AscendingNode OrderingNode func (node AscendingNode) Eq(other AscendingNode) bool { return reflect.DeepEqual(node, other) } func (node AscendingNode) Direction() string { return "ASC" } func (node AscendingNode) Reverse() *DescendingNode { return &DescendingNode{Expr: node...
package rel import ( "reflect" ) type AscendingNode OrderingNode func (node AscendingNode) Eq(other AscendingNode) bool { return reflect.DeepEqual(node, other) } func (node *AscendingNode) Direction() string { return "ASC" } func (node *AscendingNode) Reverse() *DescendingNode { return &DescendingNode{Expr: no...
Use ptrs to ascending nodes
Use ptrs to ascending nodes
Go
mit
aackerman/rel
407568cc983d16b68baec4c91f40e60a38b5b367
integration_tests/pkg/cassandra/connector_test.go
integration_tests/pkg/cassandra/connector_test.go
package cassandra import ( "github.com/Sirupsen/logrus" "github.com/intelsdi-x/swan/pkg/cassandra" . "github.com/smartystreets/goconvey/convey" "testing" ) func TestCassandraConnection(t *testing.T) { logrus.SetLevel(logrus.ErrorLevel) Convey("While creating Cassandra config with proper parameters", t, func() {...
package cassandra import ( "github.com/Sirupsen/logrus" "github.com/intelsdi-x/swan/pkg/cassandra" . "github.com/smartystreets/goconvey/convey" "testing" ) func TestCassandraConnection(t *testing.T) { logrus.SetLevel(logrus.ErrorLevel) Convey("While creating Cassandra config with proper parameters", t, func() {...
Test error before config in connector test.
Test error before config in connector test.
Go
apache-2.0
intelsdi-x/swan,intelsdi-x/swan,intelsdi-x/swan
3cbb9019e62b5ed8d2ec7ce693851f96cb8feade
null_backend.go
null_backend.go
package honeybadger // nullBackend implements the Backend interface but swallows errors and does not // send them to Honeybadger. type nullBackend struct{} // Ensure nullBackend implements Backend. var _ Backend = &nullBackend{} // NewNullBackend creates a backend which swallows all errors and does not send // them ...
package honeybadger // nullBackend implements the Backend interface but swallows errors and does not // send them to Honeybadger. type nullBackend struct{} // Ensure nullBackend implements Backend. var _ Backend = &nullBackend{} // NewNullBackend creates a backend which swallows all errors and does not send // them ...
Make NewNullBackend returns a pointer to nullBackend
Make NewNullBackend returns a pointer to nullBackend Based on a better understanding of Go from when I originally added the null backend. With this change Notify should no longer copy the nullBackend when called.
Go
mit
honeybadger-io/honeybadger-go
f163fb286961e518f0472b4b731d70182b7179ce
internal/vm/fuzz.go
internal/vm/fuzz.go
// Copyright 2011 Google Inc. All Rights Reserved. // This file is available under the Apache license. // +build gofuzz package vm import ( "bytes" "flag" "fmt" ) func Fuzz(data []byte) int { // Enable this when debugging with a fuzz crash artifact. dumpDebug := false // We need to successfully parse flags to...
// Copyright 2011 Google Inc. All Rights Reserved. // This file is available under the Apache license. // +build gofuzz package vm import ( "bytes" "flag" "fmt" "os" ) func Fuzz(data []byte) int { // Enable this when debugging with a fuzz crash artifact. dumpDebug := false // We need to successfully parse fl...
Use os.Args for the command name.
Use os.Args for the command name.
Go
apache-2.0
SuperQ/mtail,google/mtail,google/mtail,SuperQ/mtail
a443e46636c6eb2d84f6b24d05efb32f39895bab
google/appenginevm.go
google/appenginevm.go
// +build appenginevm package google import ( "strings" "github.com/golang/oauth2" "google.golang.org/appengine" ) type AppEngineConfig struct { context appengine.Context scopes []string cache oauth2.Cache } func NewAppEngineConfig(context appengine.Context, scopes []string) *AppEngineConfig { return &Ap...
// +build !appengine package google import ( "strings" "github.com/golang/oauth2" "google.golang.org/appengine" ) type AppEngineConfig struct { context appengine.Context scopes []string cache oauth2.Cache } func NewAppEngineConfig(context appengine.Context, scopes []string) *AppEngineConfig { return &App...
Make app engine main implementation godoced.
Make app engine main implementation godoced.
Go
bsd-3-clause
tpiha/oauth2,djalal/oauth2,flowlo/oauth2,hoysoft/oauth2,pengwynn/oauth2-1,cw2018/oauth2,lancecarlson/oauth2,qtzheng/oauth2,jboeuf/oauth2,hoonmin/oauth2,walmartlabs/oauth2,drewwells/oauth2,heshed/oauth2,Kuzmin/oauth2,paul-at-start/oauth2,wmydz1/oauth2,EagerIO/oauth2,equinux/oauth2,helojo/oauth2,broady/oauth2,cllu/oauth2...
365f4db3d4dee206f262f205e39dd85bf633da1c
sack/display.go
sack/display.go
package sack import ( "fmt" "github.com/wsxiaoys/terminal/color" "io/ioutil" "regexp" "strings" ) func display() { lines := content() dat, err := ioutil.ReadFile(termPath) check(err) // Header fmt.Print(header) for i, line := range lines { li := strings.SplitN(line, " ", 3) s := displayLines(string(...
package sack import ( "fmt" "github.com/wsxiaoys/terminal/color" "io/ioutil" "regexp" "strings" ) func display() { lines := content() dat, err := ioutil.ReadFile(termPath) check(err) // Header fmt.Print(header) for i, line := range lines { li := strings.SplitN(line, " ", 3) s := displayLines(string(...
Fix case issue in highlighted match
Fix case issue in highlighted match
Go
mit
zph/go-sack,zph/go-sack
2ce20bdde18b062b19261a850e7342bb28087eec
time/time.go
time/time.go
// Package time contains functions to help work with date and time package time import ( "time" ) // ZoneName - a convenience function for determining the current timezone's name func ZoneName() string { n, _ := time.Now().Zone() return n } // ZoneOffset - determine the current timezone's offset, in seconds east ...
// Package time contains functions to help work with date and time package time import ( "time" "github.com/hairyhenderson/gomplate/v3/env" ) // ZoneName - a convenience function for determining the current timezone's name func ZoneName() string { n, _ := zone() return n } // ZoneOffset - determine the current ...
Support changing TZ env var in Zone functions
Support changing TZ env var in Zone functions Signed-off-by: Dave Henderson <43109f09330ba64e33d78babb963403790c3ac10@gmail.com>
Go
mit
hairyhenderson/gomplate
825e19bc5f8402662d904c397b38171a7ae20bf3
agent/structs/structs_oss.go
agent/structs/structs_oss.go
// +build !consulent package structs import ( "hash" "github.com/hashicorp/consul/acl" ) // EnterpriseMeta stub type EnterpriseMeta struct{} func (m *EnterpriseMeta) estimateSize() int { return 0 } func (m *EnterpriseMeta) addToHash(hasher hash.Hash) { // do nothing } // ReplicationEnterpriseMeta stub func R...
// +build !consulent package structs import ( "hash" "github.com/hashicorp/consul/acl" ) // EnterpriseMeta stub type EnterpriseMeta struct{} func (m *EnterpriseMeta) estimateSize() int { return 0 } func (m *EnterpriseMeta) addToHash(hasher hash.Hash) { // do nothing } // ReplicationEnterpriseMeta stub func R...
Add DirEntry method to fill enterprise authz context
Add DirEntry method to fill enterprise authz context
Go
mpl-2.0
hashicorp/consul,42wim/consul,42wim/consul,hashicorp/consul,42wim/consul,kingland/consul,kingland/consul,kingland/consul,42wim/consul,kingland/consul,scalp42/consul,scalp42/consul,scalp42/consul,42wim/consul,kingland/consul,scalp42/consul,hashicorp/consul,hashicorp/consul,scalp42/consul
b86751bb49937553fd31cb90b7bbf64f46db193a
logic/track.go
logic/track.go
package logic import ( "github.com/jclebreton/opensirene/database" "github.com/pkg/errors" ) type track struct { Database database.PgxClient } type Tracker interface { Save(action, msg, filename string, isSuccess bool) error } func NewTracker(db database.PgxClient) *track { return &track{Database: db} } // Sa...
package logic import ( "github.com/jclebreton/opensirene/database" "github.com/pkg/errors" ) type track struct { Database database.PgxClient } type Tracker interface { Save(action, msg, filename string, isSuccess bool) error } func NewTracker(db database.PgxClient) *track { return &track{Database: db} } // Sa...
Truncate history during a full import
Truncate history during a full import
Go
mit
jclebreton/opensirene,jclebreton/opensirene
dc03a6bdf11bfe36757e96e7fa2b765d30f8a308
go/src/socialapi/workers/sitemap/sitemapinitializer/main.go
go/src/socialapi/workers/sitemap/sitemapinitializer/main.go
package main import ( "fmt" "socialapi/workers/common/runner" "socialapi/workers/helper" "socialapi/workers/sitemap/sitemapfeeder/feeder" ) var ( Name = "SitemapInitializer" ) func main() { r := runner.New(Name) if err := r.Init(); err != nil { fmt.Println(err) return } defer r.Close() redisConn := he...
package main import ( "fmt" "socialapi/workers/common/runner" "socialapi/workers/helper" "socialapi/workers/sitemap/sitemapfeeder/feeder" ) var ( Name = "SitemapInitializer" ) func main() { r := runner.New(Name) if err := r.Init(); err != nil { fmt.Println(err) return } defer r.Close() conf := *r.Conf...
Add optional redisDB for initializer
Sitemap: Add optional redisDB for initializer
Go
agpl-3.0
koding/koding,gokmen/koding,andrewjcasal/koding,koding/koding,mertaytore/koding,jack89129/koding,sinan/koding,alex-ionochkin/koding,koding/koding,szkl/koding,kwagdy/koding-1,alex-ionochkin/koding,jack89129/koding,drewsetski/koding,sinan/koding,drewsetski/koding,szkl/koding,alex-ionochkin/koding,sinan/koding,kwagdy/kodi...
22efa3b740baf70a73c5f208dd32a3c8eb15099b
mailer_test.go
mailer_test.go
package authboss import ( "bytes" "strings" "testing" ) func TestMailer(t *testing.T) { mailServer := &bytes.Buffer{} config := NewConfig() config.Mailer = LogMailer(mailServer) config.Storer = mockStorer{} Init(config) err := SendMail(Email{ To: []string{"some@email.com", "a@a.com"}, ToNames: [...
package authboss import ( "bytes" "strings" "testing" ) func TestMailer(t *testing.T) { mailServer := &bytes.Buffer{} config := NewConfig() config.Mailer = LogMailer(mailServer) config.Storer = mockStorer{} Init(config) err := SendMail(Email{ To: []string{"some@email.com", "a@a.com"}, ToNames: [...
Make mailer test a bit more inclusive.
Make mailer test a bit more inclusive.
Go
mit
gernest/authboss,pathirana/authboss,orian/authboss,buu700/authboss,go-authboss/authboss
cb3c4850ebe99eee538102eb2c4be7176a757811
policy/event.go
policy/event.go
// Copyright 2015 CodeIgnition. All rights reserved. // Use of this source code is governed by a BSD // license that can be found in the LICENSE file. package policy import "time" // Event data that will be sent by policy handlers type Event struct { Time time.Time Policy Policy Data map[string]interface{} //...
// Copyright 2015 CodeIgnition. All rights reserved. // Use of this source code is governed by a BSD // license that can be found in the LICENSE file. package policy import "time" // Event data that will be sent by policy handlers type Event struct { Time time.Time PolicyName string `bson:"policy_name"`...
Change the Event to not include complete Policy
Change the Event to not include complete Policy As the number of events sent will be high, having a complete Policy in the Event is pointless. Just keep PolicyName and AgentUID as they are the only useful info
Go
bsd-3-clause
codeignition/recon
7a0212fd653bfb7c12b8099477e50e63ae5ef105
data/member.go
data/member.go
package data import ( "time" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) type Memeber struct { ID bson.ObjectId "bson:`_id`" ProjectID bson.ObjectId "bson:`project_id`" AccountID bson.ObjectId "bson:`account_id`" InviterID bson.ObjectId "bson:`inviter_id`" InvitedAt time.Time "bson:`invited_at`" } ...
package data import ( "time" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" ) type Memeber struct { ID bson.ObjectId `bson:"_id"` ProjectID bson.ObjectId `bson:"project_id"` AccountID bson.ObjectId `bson:"account_id"` InviterID bson.ObjectId `bson:"inviter_id"` InvitedAt time.Time `bson:"invited_at"` ...
Add date fields in Member struct
Add date fields in Member struct
Go
bsd-3-clause
FurqanSoftware/papyrus,FurqanSoftware/papyrus,FurqanSoftware/papyrus
fee82ab398a40505de70d583b570cbd5274b0f67
pkg/cfg/cfg.go
pkg/cfg/cfg.go
package cfg /* Configuration of Procession services can be done via either command line options (flags) or via environment variables. *Some* environment variables, e.g. PROCESSION_LOG_LEVEL, may be changed **after** a service is started, and the value of the environment variable will override...
package cfg /* Configuration of Procession services can be done via either command line options (flags) or via environment variables. *Some* environment variables, e.g. PROCESSION_LOG_LEVEL, may be changed **after** a service is started, and the value of the environment variable will override...
Add connection timeout configuration common param
Add connection timeout configuration common param
Go
apache-2.0
jaypipes/procession,jaypipes/procession
1d12f0c27539db3aebfff890e21259f57dff6ae8
main.go
main.go
package main import ( "encoding/json" "fmt" "os" ) func parseObj(in interface{}, out map[string]interface{}, prefix string) { switch vv := in.(type) { case map[string]interface{}: for key, value := range vv { parseObj(value, out, fmt.Sprintf("%s.%s", prefix, key)) } ...
package main import ( "encoding/json" "fmt" "os" ) func parseObj(in interface{}, out map[string]interface{}, prefix string) { switch vv := in.(type) { case map[string]interface{}: for key, value := range vv { parseObj(value, out, fmt.Sprintf("%s.%s", prefix, key)) } ...
Use the correct type for numbers!
Use the correct type for numbers!
Go
mit
stilvoid/buggy
d32d773dd9216db72bef86d94168d1fb53399c6f
lib/buildcfg/cfg_lang_go.go
lib/buildcfg/cfg_lang_go.go
package buildcfg import ( "net/url" "strings" ) func loadGoConfig(remote string, c *Config) { u, _ := url.Parse(remote) importPath := u.Hostname() + strings.Replace(u.Path, ".git", "", 1) // Most part of this just moves everything from builddir to the correct go-import-path setup := []string{ "export GOPATH=...
package buildcfg import ( "net/url" "strings" ) func goImportPath(remote string) string { if strings.Contains(remote, ":") && strings.Contains(remote, "@") { rem := remote[strings.Index(remote, "@")+1:] return strings.Replace(strings.Replace(rem, ".git", "", 1), ":", "/", 1) } u, err := url.Parse(remote) if...
Change the way golang packages are built
Change the way golang packages are built
Go
mit
rikvdh/ci,rikvdh/ci,rikvdh/ci
9e5c624a5635e3b60623bbf033ebe13de6dc5733
testmode.go
testmode.go
package main import ( "fmt" "http" ) // support for running "redwood -test http://example.com" // runURLTest prints debugging information about how the URL and its content would be rated. func runURLTest(u string) { url, err := http.ParseURL(u) if err != nil { fmt.Println("Could not parse the URL.") return ...
package main import ( "fmt" "http" "mahonia.googlecode.com/hg" ) // support for running "redwood -test http://example.com" // runURLTest prints debugging information about how the URL and its content would be rated. func runURLTest(u string) { url, err := http.ParseURL(u) if err != nil { fmt.Println("Could no...
Test mode now scans for phrases.
Test mode now scans for phrases.
Go
bsd-2-clause
andybalholm/redwood,vishnuvaradaraj/redwood,yinheli/redwood-filter,unixabg/redwood,vishnuvaradaraj/redwood,unixabg/redwood,andybalholm/redwood,yinheli/redwood-filter,yinheli/redwood-filter,vishnuvaradaraj/redwood
a646265e8b28ffbc543f320c98346eeea54e3fce
4_2.go
4_2.go
package h2spec import ( "github.com/bradfitz/http2" "github.com/bradfitz/http2/hpack" ) func FrameSizeTestGroup() *TestGroup { tg := NewTestGroup("4.2", "Frame Size") tg.AddTestCase(NewTestCase( "Sends large size frame that exceeds the SETTINGS_MAX_FRAME_SIZE", "The endpoint MUST send a FRAME_SIZE_ERROR erro...
package h2spec import ( "github.com/bradfitz/http2" "github.com/bradfitz/http2/hpack" ) func FrameSizeTestGroup() *TestGroup { tg := NewTestGroup("4.2", "Frame Size") tg.AddTestCase(NewTestCase( "Sends large size frame that exceeds the SETTINGS_MAX_FRAME_SIZE", "The endpoint MUST send a FRAME_SIZE_ERROR erro...
Fix test 4.2 to test for stream error
Fix test 4.2 to test for stream error The test sends an oversized data frame, so the server is required to reset the stream with FRAME_SIZE_ERROR. The server may treat this error as fatal for the connection and send GOAWAY( FRAME_SIZE_ERROR ), or drop the connection instead. These upgraded errors are already handled ...
Go
mit
summerwind/h2spec,shane-kearns/h2spec,rmoorman/h2spec
d577ce14dea31583cc6c6dd6eec1906fad872896
skin/mojang.go
skin/mojang.go
package skin import ( "errors" "fmt" "image/png" "net/http" ) const ( skinURL = "http://skins.minecraft.net/MinecraftSkins/%s.png" ) // Follow all redirects var skinClient = &http.Client{ CheckRedirect: func(*http.Request, []*http.Request) error { return nil }, } func Download(player string) (skin *Skin, e...
package skin import ( "errors" "fmt" "image/png" "net/http" ) const ( skinURL = "http://skins.minecraft.net/MinecraftSkins/%s.png" ) func Download(player string) (skin *Skin, err error) { resp, err := http.Get(fmt.Sprintf(skinURL, player)) if err != nil { return } if resp.StatusCode != http.StatusOK { ...
Remove unused custom http client
Remove unused custom http client
Go
mit
LapisBlue/Lapitar,LapisBlue/Lapitar,LapisBlue/Lapitar
a5b2b56c52161d152b62d2fff84fe5089cb5099f
tracks/segmentfns_test.go
tracks/segmentfns_test.go
package tracks
package tracks import "testing" func elem(s SegmentType) Element { return Element{ Segment: TS_MAP[s], } } func TestNotPossible(t *testing.T) { testCases := []struct { input Element notPossibility Element }{ {elem(ELEM_FLAT_TO_25_DEG_UP), elem(ELEM_LEFT_QUARTER_TURN_5_TILES)}, } for _, tt := r...
Add basic test for generated track
Add basic test for generated track We generated a track that had 25_DEG_UP followed by 3 tile flat left turn, which shouldn't be possible. Adds a test that rules out that possibility in one place in the codebase.
Go
mit
kevinburke/rct,kevinburke/rct,kevinburke/rct,kevinburke/rct
0e2ca28f15f35ace2f4ee78ff7413de5c1909ab7
staticcheck/testdata/dubious/sync-pool-pointers.go
staticcheck/testdata/dubious/sync-pool-pointers.go
package pkg import "sync" func fn() { s := []int{} v := sync.Pool{} v.Put(s) // MATCH /Non-pointer type / v.Put(&s) p := &sync.Pool{} p.Put(s) // MATCH /Non-pointer type / p.Put(&s) }
package pkg import "sync" func fn() { s := []int{} v := sync.Pool{} v.Put(s) // MATCH /non-pointer type/ v.Put(&s) p := &sync.Pool{} p.Put(s) // MATCH /non-pointer type/ p.Put(&s) }
Fix tests for sync.Pool check
Fix tests for sync.Pool check
Go
mit
dominikh/go-tools,dominikh/go-tools,dominikh/go-tools,dominikh/go-tools
527403397ba06f09f0278e370f4e7b87386d6106
wav/wav_test.go
wav/wav_test.go
package wav import ( "fmt" "os" "testing" "time" "github.com/stretchr/testify/require" ) func TestBasicWav(t *testing.T) { fmt.Println("Running Basic Wav") f, err := os.Open("test.wav") fmt.Println(f) require.Nil(t, err) a, err := Load(f) require.Nil(t, err) err = <-a.Play() require.Nil(t, err) time.Sl...
package wav import ( "fmt" "os" "testing" "time" ) func TestBasicWav(t *testing.T) { fmt.Println("Running Basic Wav") f, err := os.Open("test.wav") fmt.Println(f) if err != nil { t.Fatal("expected open err to be nil, was", err) } a, err := Load(f) if err != nil { t.Fatal("expected load err to be nil, w...
Remove require from wav test
Remove require from wav test testify requires cgo on linux without certain go debug flags set. We should stop using it.
Go
apache-2.0
200sc/klangsynthese
20616f9c98218533d9fc1f997a30bed0342f1716
web/handlers.go
web/handlers.go
package web import ( "html/template" "log" "net/http" "github.com/johnmaguire/wbc/database" ) type IndexHandler struct { address string database string } func (ih *IndexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { id := getClient("index", r) // Connect to database db, err := database.Conn...
package web import ( "html/template" "log" "net/http" "strings" "github.com/johnmaguire/wbc/database" ) type IndexHandler struct { address string database string } func (ih *IndexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { id := getClient("index", r) // Connect to database db, err := da...
Drop port from welcome page
Drop port from welcome page
Go
mit
barracudanetworks/wbd
4dea6c902e54088f52b6ef59a4c382d125cce060
log/logrusadapter/adapter.go
log/logrusadapter/adapter.go
// Package logrusadapter provides a logger that writes to a github.com/sirupsen/logrus.Logger // log. package logrusadapter import ( "github.com/jackc/pgx" "github.com/sirupsen/logrus" ) type Logger struct { l *logrus.Logger } func NewLogger(l *logrus.Logger) *Logger { return &Logger{l: l} } func (l *Logger) Lo...
// Package logrusadapter provides a logger that writes to a github.com/sirupsen/logrus.Logger // log. package logrusadapter import ( "github.com/jackc/pgx" "github.com/sirupsen/logrus" ) type Logger struct { l logrus.FieldLogger } func NewLogger(l logrus.FieldLogger) *Logger { return &Logger{l: l} } func (l *Lo...
Use logrus.FieldLogger instead of *logrus.Logger
Use logrus.FieldLogger instead of *logrus.Logger This allows supplying a logrus logger that already has fields configured
Go
mit
jackc/pgx,silviucm/pgx,silviucm/pgx,plopik/pgx,plopik/pgx,jackc/pgx,jackc/pgx,silviucm/pgx,plopik/pgx,jackc/pgx
60bb144532a799d3151daceb77e41568cb1c129c
terraform/azure/template_generator_test.go
terraform/azure/template_generator_test.go
package azure_test import ( "io/ioutil" "github.com/cloudfoundry/bosh-bootloader/storage" "github.com/cloudfoundry/bosh-bootloader/terraform/azure" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("TemplateGenerator", func() { var ( templateGenerator azure.TemplateGenerator ) Befor...
package azure_test import ( "io/ioutil" "github.com/cloudfoundry/bosh-bootloader/storage" "github.com/cloudfoundry/bosh-bootloader/terraform/azure" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) var _ = Describe("TemplateGenerator", func() { var ( templateGenerator azure.TemplateGenerator ) Befor...
Fix azure terraform fixture filename.
Fix azure terraform fixture filename.
Go
apache-2.0
pivotal-cf-experimental/bosh-bootloader,niroyb/bosh-bootloader,pivotal-cf-experimental/bosh-bootloader,niroyb/bosh-bootloader
21dc5cf2e69cf2eac66ec3f0e1e1b2ab13380623
timing_pipe.go
timing_pipe.go
package pipeline import ( "time" ) // TimingPipe invokes a custom callback function with the amount of time required to run a specific Pipe type TimingPipe struct { timedPipe Pipe callback func(begin time.Time, duration time.Duration) } // NewTimingPipe creates a new timing pipe func NewTimingPipe(timedPipe Pipe...
package pipeline import ( "time" ) // TimingPipe invokes a custom callback function with the amount of time required to run a specific Pipe type TimingPipe struct { timedPipe Pipe callback func(begin time.Time, duration time.Duration) } // NewTimingPipe creates a new timing pipe func NewTimingPipe(timedPipe Pipe...
Return pointer from NewTimingPipe function
Return pointer from NewTimingPipe function
Go
mit
skidder/pipeline
5dc526b01ae688ba5d3c89b21a580675898cdd34
tlds_custom.go
tlds_custom.go
package isdomain // ExtendedTLDs is a set of additional "TLDs", allowing decentralized name // systems, like TOR and Namecoin. var ExtendedTLDs = map[string]bool{ "BIT": true, "ONION": true, "ETH": true, }
package isdomain // ExtendedTLDs is a set of additional "TLDs", allowing decentralized name // systems, like TOR and Namecoin. var ExtendedTLDs = map[string]bool{ "BIT": true, "ONION": true, "ETH": true, "BBS": true, "CHAN": true, "CYB": true, "DYN": true, "EPIC": true, "GEEK": true, "GOPHER":tr...
Add OpenNIC domains to extended TLDs.
Add OpenNIC domains to extended TLDs. OpenNIC domain list is from: https://en.wikipedia.org/wiki/OpenNIC OpenNIC domains are non-ICANN TLDs and large free DNS project.
Go
mit
jbenet/go-is-domain,jbenet/go-is-domain
fbe3145728ced5e18f3c139446c1208fd805670a
utils/utils.go
utils/utils.go
package utils import "math" func IsPrime(num int) bool { floatNum := float64(num) for i := 2; i <= int(math.Floor(math.Sqrt(floatNum))); i++ { if num%i == 0 { return false } } return true }
package utils import "math" func IsPrime(num int) bool { floatNum := float64(num) for i := 2; i <= int(math.Floor(math.Sqrt(floatNum))); i++ { if num%i == 0 { return false } } return true } func Gcd(a, b int) int { var min, max int if a < b { min, max = a, b } else { min, max = b, a } for min != ...
Add GCD and prime factors algorithms
Add GCD and prime factors algorithms
Go
mit
rafax/goeuler
f5babce21c18273d9c71a4d3b2f19d63e61005f1
resources/iam/access_key.go
resources/iam/access_key.go
package iam import ( "github.com/jagregory/cfval/constraints" . "github.com/jagregory/cfval/schema" ) // see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-accesskey.html var AccessKey = Resource{ AwsType: "AWS::IAM::AccessKey", Attributes: map[string]Schema{ "SecretAccessKey...
package iam import ( "github.com/jagregory/cfval/constraints" . "github.com/jagregory/cfval/schema" ) // see: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iam-accesskey.html var AccessKey = Resource{ AwsType: "AWS::IAM::AccessKey", Attributes: map[string]Schema{ "SecretAccessKey...
Remove mandatory requirement for AccessKey.Status and add default
Remove mandatory requirement for AccessKey.Status and add default Fixes #43
Go
mit
jagregory/cfval,jagregory/cfval
6af2ac169b29516b44aafd6d905c6e8ece3f6309
metadata/metadata_dell_linux.go
metadata/metadata_dell_linux.go
package metadata // Restrict to Linux because, although omreport runs fine on Windows, the // Windows metadata uses WMI to fetch this information. import ( "strings" "bosun.org/util" ) func init() { metafuncs = append(metafuncs, collectMetadataOmreport) } func collectMetadataOmreport() { _ = util.ReadCommand(f...
package metadata // Restrict to Linux because, although omreport runs fine on Windows, the // Windows metadata uses WMI to fetch this information. import ( "strings" "bosun.org/util" ) func init() { metafuncs = append(metafuncs, collectMetadataOmreport) } func collectMetadataOmreport() { _ = util.ReadCommand(f...
Change dell svctag metakey to be serialNumber
metadata: Change dell svctag metakey to be serialNumber This way it matches the windows machines that get the same info from WMI
Go
mit
vitorboschi/bosun,objStorage/bosun,fisdap/bosun,jareksm/bosun,bookingcom/bosun,cazacugmihai/bosun,dieface/bosun,cyngn/bosun,shanemadden/bosun,youngl98/bosun,bosun-sharklasers/bosun,eMerzh/bosun,trigrass2/bosun,seekingalpha/bosun,leapar/bosun,azhurbilo/bosun,melifaro/bosun,leapar/bosun,gregdel/bosun,fisdap/bosun,objStor...
d3006931ec68b97e671866950af48a9c6de8970c
pos_test.go
pos_test.go
package parse import ( "bytes" "io" "testing" "github.com/tdewolff/test" ) func TestPosition(t *testing.T) { var newlineTests = []struct { pos int s string line int col int err error }{ {0, "x", 1, 1, nil}, {1, "xx", 1, 2, nil}, {2, "x\nx", 2, 1, nil}, {2, "\n\nx", 3, 1, nil}, {3, "\n...
package parse import ( "bytes" "io" "testing" "github.com/tdewolff/test" ) func TestPosition(t *testing.T) { var newlineTests = []struct { pos int s string line int col int err error }{ {0, "x", 1, 1, nil}, {1, "xx", 1, 2, nil}, {2, "x\nx", 2, 1, nil}, {2, "\n\nx", 3, 1, nil}, {3, "\n...
Update position test to use test.V
Update position test to use test.V
Go
mit
tdewolff/parse
11e2f3677a12b873ca92e8d61d1c1553cfa3fea2
src/arp147/computer/fs/fs.go
src/arp147/computer/fs/fs.go
package fs import ( "time" ) var vfs map[string]*Item type Item struct { Contents string Dir bool User string Group string Mode uint CreatedAt time.Time UpdatedAt time.Time } func init() { now := time.Now() vfs = map[string]*Item{ "/": &Item{ Contents: "", Dir: true, ...
package fs import ( "time" ) var vfs map[string]*Item type Item struct { Contents string Dir bool User string Group string Mode uint CreatedAt time.Time UpdatedAt time.Time } func init() { now := time.Now() vfs = map[string]*Item{ "/": &Item{ Contents: "", Dir: true, ...
Change default mode on files that won't exist much longer.
Change default mode on files that won't exist much longer. I know kind of pointless, but still. Also the mode doesn't do anything yet.
Go
bsd-3-clause
lukevers/arp147,lukevers/arp147
e8e5304cc387c482a2cd407b0ae3b1cddecae5f4
templates/_appengine/main_appengine.go
templates/_appengine/main_appengine.go
// +build appengine package main import ( "net/http" "time" _ "gnd.la/admin" // required for make-assets command _ "gnd.la/cache/driver/memcache" // enable memcached cache driver _ "gnd.la/orm/driver/gcs" // enable Google Could Storage blobstore driver // Uncomment the following line to ...
// +build appengine package main import ( "net/http" "time" _ "gnd.la/admin" // required for make-assets command _ "gnd.la/cache/driver/memcache" // enable memcached cache driver _ "gnd.la/orm/blobstore/gcs" // enable Google Could Storage blobstore driver // Uncomment the following line to ...
Fix import path for blobstore gcs driver in project template
Fix import path for blobstore gcs driver in project template
Go
apache-2.0
rainycape/gondolaweb,rainycape/gondolaweb,rainycape/gondolaweb,rainycape/gondolaweb
0b0300cfe6887861745518a25646383936cccb79
staging/src/k8s.io/code-generator/cmd/go-to-protobuf/main.go
staging/src/k8s.io/code-generator/cmd/go-to-protobuf/main.go
/* Copyright 2015 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, ...
/* Copyright 2015 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, ...
Add go flags to go-to-protobuf
Add go flags to go-to-protobuf
Go
apache-2.0
tenxcloud/kubernetes,invenfantasy/kubernetes,ixdy/kubernetes,khenidak/kubernetes,fejta/kubernetes,kokhang/kubernetes,colemickens/kubernetes,mdshuai/kubernetes,nckturner/kubernetes,tpepper/kubernetes,cadmuxe/kubernetes,njuicsgz/kubernetes-1,vmware/kubernetes,castrojo/kubernetes,ingvagabund/kubernetes,humblec/kubernetes,...
497a75db113b61645385c0bcaeab3d096696b313
taue/jobs/slack_reporter.go
taue/jobs/slack_reporter.go
package jobs import ( "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "os" "strconv" "github.com/Yu-taro/taue/taue/models" ) func postSlack(users []models.User) { webHookURL := "https://hooks.slack.com/services/" + os.Getenv("SLACK_WEBHOOK_ENDPOINT") var text string for _, user := range users { ...
package jobs import ( "encoding/json" "fmt" "io/ioutil" "net/http" "net/url" "os" "strconv" "github.com/Yu-taro/taue/taue/models" ) func postSlack(users []models.User) { webHookURL := "https://hooks.slack.com/services/" + os.Getenv("SLACK_WEBHOOK_ENDPOINT") var text string for _, user := range users { ...
Fix select general channel on slack
Fix select general channel on slack
Go
apache-2.0
Yu-taro/taue
4f4589135ce5b4d6bfaeb0b39abc4117a4010737
slackAPI.go
slackAPI.go
package main import "fmt" func main() { fmt.Println("hello world") }
package main import ( "fmt" slackPkg "github.com/nlopes/slack" ) func main() { fmt.Println("hello world") api := slackPkg.New("Your-Token") Users, err := api.GetUsers() if err != nil { fmt.Printf("Get Slack users info failed: %v", err) } for _, user := range Users { fmt.Println(user.Profile.Email, user.I...
Add slack token test function
Add slack token test function
Go
mit
junwangustc/slackbot
2938f8ee621c3005cbd98935150212a565ce38b1
infinite_channel_test.go
infinite_channel_test.go
package channels import "testing" func TestInfiniteChannel(t *testing.T) { var ch Channel ch = NewInfiniteChannel() testChannel(t, "infinite channel", ch) ch = NewInfiniteChannel() testChannelPair(t, "infinite channel", ch, ch) } func BenchmarkInfiniteChannelSerial(b *testing.B) { ch := NewInfiniteChannel() ...
package channels import "testing" func TestInfiniteChannel(t *testing.T) { var ch Channel ch = NewInfiniteChannel() testChannel(t, "infinite channel", ch) ch = NewInfiniteChannel() testChannelPair(t, "infinite channel", ch, ch) } func BenchmarkInfiniteChannelSerial(b *testing.B) { ch := NewInfiniteChannel() ...
Add two more benchmark styles
Add two more benchmark styles
Go
mit
jonahglover/channels,eapache/channels
7d9f5aa81dfdb68cc5e5a82c3b51f40c10fcce03
tests/connection_test.go
tests/connection_test.go
package tests import ( "fmt" networking "git.cyberdust.com/radicalapp/go-networking" "testing" ) func TestGetConnection(t *testing.T) { urlString := "https://jsonplaceholder.typicode.com/posts" params := networking.NewParams() connection := networking.NewConnection(urlString, params) connection.OnReceived = f...
package tests import ( "fmt" networking "git.cyberdust.com/radicalapp/go-networking" "testing" ) func TestGetConnection(t *testing.T) { urlString := "https://jsonplaceholder.typicode.com/posts" params := networking.NewParams() connection := networking.NewConnection(urlString, params) connection.OnReceived = f...
Add test cases for GET and POST
Add test cases for GET and POST
Go
mit
RadicalApp/go-networking
a1c76c2d4798fc7f7f75279eb002d4eeb089288b
db/psql/psql.go
db/psql/psql.go
package psql import ( "errors" _ "github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/postgres" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" "github.com/spf13/cobra" "github.com/spf13/viper" ) var ( DB *gorm.DB DBError error ) func init() { cobra.OnInitialize(ConnectDB...
package psql import ( "errors" "database/sql/driver" "encoding/json" _ "github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/postgres" "github.com/jinzhu/gorm" _ "github.com/jinzhu/gorm/dialects/postgres" "github.com/spf13/cobra" "github.com/spf13/viper" ) var ( DB *gorm.DB DBError error ) fun...
Introduce type for parsing jsonb
Introduce type for parsing jsonb
Go
apache-2.0
eyecuelab/kit
794b4dcd83c62ded650d58a198f3764f5fcc74b7
pu.go
pu.go
// Package pu makes solving projecteuler problems easier and reduces boilerplate. package pu import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // Problem is a Project Euler (.net) problem type Problem struct { // ID is the id of the problem on projecteuler.net ID int // Solver is the function whi...
// Package pu makes solving projecteuler problems easier and reduces boilerplate. package pu import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // Problem is a Project Euler (.net) problem type Problem struct { // ID is the id of the problem on projecteuler.net ID int // Solver is the function whi...
Include attempts when printing answer
Include attempts when printing answer
Go
mit
jacobhands/pu
0b97853e9e164661c95c08e8bbf0a2ed45ddee9c
main.go
main.go
package main import ( "fmt" "github.com/almighty/almighty-core/app" "github.com/almighty/almighty-core/swagger" "github.com/goadesign/goa" "github.com/goadesign/goa/middleware" ) var ( // Commit current build commit set by build script Commit string // BuildTime set by build script BuildTime string ) func ...
package main import ( "fmt" "github.com/almighty/almighty-core/app" "github.com/almighty/almighty-core/swagger" "github.com/goadesign/goa" "github.com/goadesign/goa/middleware" ) var ( // Commit current build commit set by build script Commit = "0" // BuildTime set by build script BuildTime = "0" ) func ma...
Add default values to Build variables
Add default values to Build variables
Go
apache-2.0
ALMighty/almighty-core,ldimaggi/almighty-core,ldimaggi/almighty-core,ldimaggi/almighty-core,ldimaggi/almighty-core
020f42ecec9952e6407aa8c03348377bf0427589
main.go
main.go
package main import ( "fmt" "net/http" _ "net/http/pprof" // import for side effects "github.com/gorilla/mux" ) func main() { r := mux.NewRouter() r.HandleFunc("/hello/{name}", helloHandler) http.Handle("/", r) http.ListenAndServe(":8080", nil) } func helloHandler(w http.ResponseWriter, r *http.Request) { ...
package main import ( "fmt" "net/http" _ "net/http/pprof" // import for side effects "encoding/json" "github.com/gorilla/mux" ) func main() { r := mux.NewRouter() r.HandleFunc("/hello/{name}", helloHandler) r.HandleFunc("/add_job", jobHandler) http.Handle("/", r) http.ListenAndServe(":8080", nil) } func ...
Add /add_job endpoint which takes a POST containing just a audio url (for now)
Add /add_job endpoint which takes a POST containing just a audio url (for now)
Go
mit
hack4impact/audio-transcription-service,hack4impact/transcribe4all,hack4impact/transcribe4all,hack4impact/transcribe4all
4e43283f7bfeb7ef72a8f8b90f783e7a9c1f837a
doc.go
doc.go
// Package src scans directory trees for source code packages. package srcscan
// Package src scans directory trees for source code packages. package srcscan // test imports import _ "github.com/kr/pretty"
Add test imports in non-test code so that `go get` picks them up
Add test imports in non-test code so that `go get` picks them up
Go
apache-2.0
sourcegraph/srcscan,sourcegraph/srcscan,sourcegraph/srcscan,sourcegraph/srcscan,sourcegraph/srcscan
4956392c4712001e408e5c7136935928d271ebd5
url_test.go
url_test.go
package main import ( "testing" . "github.com/onsi/gomega" ) func TestNewURL(t *testing.T) { httpsUrl, err := NewURL("https://github.com/motemen/pusheen-explorer") Expect(httpsUrl.String()).To(Equal("https://github.com/motemen/pusheen-explorer")) Expect(err).To(BeNil()) sshUrl, err := NewURL("git@github.com:mo...
package main import ( "testing" . "github.com/onsi/gomega" ) func TestNewURL(t *testing.T) { RegisterTestingT(t) httpsUrl, err := NewURL("https://github.com/motemen/pusheen-explorer") Expect(httpsUrl.String()).To(Equal("https://github.com/motemen/pusheen-explorer")) Expect(httpsUrl.Host).To(Equal("github.com")...
Fix test to run `url_tesg.go`
Fix test to run `url_tesg.go`
Go
mit
motemen/ghq,jmatsu/ghq_ss,ngtk/ghq,maoe/ghq,motemen/ghq,skatsuta/ghq,uetchy/ghq,motemen/ghq
0a555a58599f797896fc056c3594b8491430d082
cli/cli_test.go
cli/cli_test.go
package cli import ( "bytes" "testing" ) func TestFlagC(t *testing.T) { var in, out, err bytes.Buffer c := CLI{ In: &in, Out: &out, Err: &err, } args := []string{"-c", "echo aaa"} code := c.Run(args) if code != 0 { t.Errorf("Run: got %v, want %v", code, 0) } if got, want := out.String(), "aaa\n"; g...
package cli import ( "bytes" "testing" ) func TestFlagC(t *testing.T) { var in, out, err bytes.Buffer c := CLI{ In: &in, Out: &out, Err: &err, } args := []string{"-c", "echo aaa"} code := c.Run(args) if code != 0 { t.Errorf("Run: got %v, want %v", code, 0) } if got, want := out.String(), "aaa\n"; g...
Print error if it exists
Print error if it exists
Go
mit
elpinal/coco3
412dcc0e30ce3e137a67f445a9095ecd4bf1c190
convert_unix.go
convert_unix.go
// +build darwin freebsd linux netbsd openbsd package flags import ( "syscall" "unsafe" ) type winsize struct { ws_row, ws_col uint16 ws_xpixel, ws_ypixel uint16 } func getTerminalColumns() int { ws := winsize{} syscall.Syscall(syscall.SYS_IOCTL, uintptr(0), uintptr(0x5413), uintptr(unsafe.Pointe...
// +build darwin freebsd linux netbsd openbsd package flags import ( "syscall" "unsafe" ) // #include <sys/ioctl.h> // enum { _GO_TIOCGWINSZ = TIOCGWINSZ }; import "C" type winsize struct { ws_row, ws_col uint16 ws_xpixel, ws_ypixel uint16 } func getTerminalColumns() int { ws := winsize{} syscall.Sysc...
Use the TIOCGWINSZ macro from C to determine correct value of option
Use the TIOCGWINSZ macro from C to determine correct value of option
Go
bsd-3-clause
jessevdk/go-flags,cmars/tools,svent/go-flags,FactomProject/go-flags,cmars/tools,sourcegraph/go-flags,FactomProject/go-flags,fuchsia-mirror/third_party-github.com-jessevdk-go-flags,svent/go-flags,fuchsia-mirror/third_party-github.com-jessevdk-go-flags,sysbot/go-flags,zenoss/go-flags,abates/go-flags,abates/go-flags,sourc...
e7202dfdf5a641950ee33bce0c74d07614d7b78e
x/compliance/types/types.go
x/compliance/types/types.go
package types const ( ZigbeeCertificationType string = "zigbee" MatterCertificationType string = "matter" ) // List of Certification Types type CertificationTypes []string var CertificationTypesList = CertificationTypes{ZigbeeCertificationType, MatterCertificationType} func IsValidCertificationType(certificationT...
package types const ( ZigbeeCertificationType string = "zigbee" MatterCertificationType string = "matter" AccessControlType string = "access control" ProductSecurityType string = "product security" ) // List of Certification Types type CertificationTypes []string var CertificationTypesList = Certificat...
Add new CertificationTypes for section compliance
Add new CertificationTypes for section compliance
Go
apache-2.0
zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger
91baf8de9889ed5053fcff1202c09233a0a0ebd2
lesser.go
lesser.go
package main import ( "os" "github.com/nsf/termbox-go" ) type Lesser struct { file *os.File } func (l Lesser) Run() { for { e := termbox.PollEvent() switch e.Type { case termbox.EventKey: switch e.Ch { case 'q': return } } } } func NewLesser(f *os.File) Lesser { return Lesser{file: f} }
package main import ( "os" "github.com/nsf/termbox-go" ) type Event int const ( EventQuit Event = iota ) type Lesser struct { file *os.File events chan Event } func (l Lesser) listenEvents() { for { e := termbox.PollEvent() switch e.Type { case termbox.EventKey: switch e.Ch { case 'q': l.ev...
Create a channel of Lesser events
Create a channel of Lesser events The main goroutine handles all events.
Go
mit
prattmic/lesser
14fe2d5f2026f28eb99e1f14c91343981618a714
cmd/ctr/pull.go
cmd/ctr/pull.go
package main import ( "fmt" "github.com/containerd/containerd/log" "github.com/urfave/cli" ) var pullCommand = cli.Command{ Name: "pull", Usage: "pull an image from a remote", ArgsUsage: "[flags] <ref>", Description: `Fetch and prepare an image for use in containerd. After pulling an image, it shoul...
package main import ( "fmt" "github.com/containerd/containerd/log" "github.com/urfave/cli" ) var pullCommand = cli.Command{ Name: "pull", Usage: "pull an image from a remote", ArgsUsage: "[flags] <ref>", Description: `Fetch and prepare an image for use in containerd. After pulling an image, it shoul...
Add newline char to avoid mix of logs
Add newline char to avoid mix of logs Add a '\n' after "unpacking xxx..." to avoid mix of logs such as: ``` unpacking sha256:a7776895af32e34b1fef997e26c79fa988b40c5cf2a3fb48dc22e0584b648d82...DEBU[0005] Extraction not needed, layer snapshot exists DEBU[0005] Extraction not needed, layer snapshot exists DEBU[0005] Ext...
Go
apache-2.0
crosbymichael/containerd,mikebrow/containerd,kunalkushwaha/containerd,AkihiroSuda/containerd,mikebrow/containerd,vdemeester/containerd,crosbymichael/containerd,vdemeester/containerd,containerd/containerd,kunalkushwaha/containerd,dmcgowan/containerd,containerd/containerd,estesp/containerd,miaoyq/containerd,thaJeztah/con...
00b0502150bcbf6b50a6fd0695f0f8df03ebd790
filterChecksumAlgos.go
filterChecksumAlgos.go
package main import "crypto" import "strings" // Checksum algos import ( _ "crypto/md5" _ "crypto/sha1" _ "crypto/sha256" _ "crypto/sha512" ) // Man, why don't people allow their table to be exported... var checksumLookupTable = map[string]crypto.Hash{ "md5": crypto.MD5, "sha1": cr...
package main import "crypto" import "strings" // Checksum algos import ( _ "crypto/md5" _ "crypto/sha1" _ "crypto/sha256" _ "crypto/sha512" ) // Man, why don't people allow their table to be exported... var checksumLookupTable = map[string]crypto.Hash{ "md5": crypto.MD5, "sha1": cr...
Format mismatch, can not use historic node name
Format mismatch, can not use historic node name
Go
mit
kormoc/bitrot-scanner
72babd93910d2458ce8764451125e6642149392c
cmd/turtle/writer.go
cmd/turtle/writer.go
package main import ( "encoding/json" "io" "github.com/hackebrot/turtle" ) // JSONWriter writes Emojis as JSON type JSONWriter struct { e *json.Encoder } // NewJSONWriter creates a new JSONWriter func NewJSONWriter(w io.Writer) *JSONWriter { return &JSONWriter{e: json.NewEncoder(w)} } // WriteEmoji to an io.W...
package main import ( "encoding/json" "fmt" "io" "github.com/hackebrot/turtle" ) // JSONWriter writes Emojis as JSON type JSONWriter struct { e *json.Encoder } // NewJSONWriter creates a new JSONWriter func NewJSONWriter(w io.Writer, options ...func(*JSONWriter) error) (*JSONWriter, error) { j := &JSONWriter{...
Implement JSONWriter option for indentation
Implement JSONWriter option for indentation
Go
mit
hackebrot/turtle
b573d5ad08cfc3a909d62aa9464bfdc4b97c452a
config/config.go
config/config.go
package config import ( "encoding/json" "fmt" "io/ioutil" "log" "os" ) type Configuration struct { Username string `json:"username"` Password string RememberMe bool `json:"remember_me"` } func configWizard() *Configuration { configuration := new(Configuration) fmt.Println("Welcome to gotify !\nThis wiz...
package config import ( "encoding/json" "fmt" "io/ioutil" "log" "os" ) type Configuration struct { Username string `json:"username"` Password string RememberMe bool `json:"remember_me"` } // Starts the wizard config func configWizard() *Configuration { configuration := new(Configuration) fmt.Println("W...
Add some docstring and the saveConfiguration method
Add some docstring and the saveConfiguration method
Go
mit
adrien-f/gotify
b6b82dc2bf009343b5210728f5ff9a201ee963b6
cmd/nsm/main.go
cmd/nsm/main.go
package main import ( "github.com/ligato/networkservicemesh/nsmdp" "log" "os" "os/signal" "syscall" ) func main() { log.Println("Starting NSM") dp := nsmdp.NewNSMDevicePlugin() dp.Serve() sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, sys...
package main import ( "github.com/ligato/networkservicemesh/nsmdp" "log" "os" "os/signal" "syscall" ) func main() { log.Println("Starting NSM") dp := nsmdp.NewNSMDevicePlugin() dp.Serve() sigChan := make(chan os.Signal, 1) signal.Notify(sigChan, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, sys...
Use a goroutine to block for the signal
Use a goroutine to block for the signal Experimenting with a more go-friendly way of handling signals. Signed-off-by: Kyle Mestery <9cfbda34e625c7b0454bcb19a48d07c46f9097d2@mestery.com>
Go
apache-2.0
networkservicemesh/networkservicemesh,networkservicemesh/networkservicemesh,networkservicemesh/networkservicemesh,networkservicemesh/networkservicemesh
b38424b6f1c08cbec2416918169f2b3323cb78c7
signature/signature_test.go
signature/signature_test.go
package signature
package signature import ( "bytes" "encoding/base64" "testing" ) const testTs = "1544544948" const testQp = "abc=foo&def=bar" const testBody = `{"a key":"some value"}` const testSignature = "orb0adPhRCYND1WCAvPBr+qjm4STGtyvNDIDNBZ4Ir4=" func TestCalculateSignature(t *testing.T) { v := NewValidator("other-secret"...
Add basic test for calculating signature
Func: Add basic test for calculating signature
Go
bsd-2-clause
messagebird/go-rest-api
1fa40f443b5aeb9204a6d0e63b2d1d1a46316e68
regexp/luaregexp_test.go
regexp/luaregexp_test.go
package regexp_test import ( "github.com/Shopify/go-lua" "github.com/Shopify/goluago/regexp" "testing" ) func TestLuaRegexp(t *testing.T) { l := lua.NewState() lua.OpenLibraries(l) regexp.Open(l) failHook := func(l *lua.State) int { str, ok := lua.ToString(l, -1) if !ok { t.Fatalf("need a string on th...
package regexp_test import ( "github.com/Shopify/go-lua" "github.com/Shopify/goluago/regexp" "testing" ) func TestLuaRegexp(t *testing.T) { l := lua.NewState() lua.OpenLibraries(l) regexp.Open(l) failHook := func(l *lua.State) int { str := lua.CheckString(l, -1) lua.Pop(l, 1) t.Error(str) return 0 }...
Use `CheckString` for test harness related func arguments.
Use `CheckString` for test harness related func arguments.
Go
mit
Shopify/goluago,Shopify/goluago
9c195e0ab9de746af9602c88ca7f9f95580f3ec6
config/config.go
config/config.go
package config import ( "bufio" "fmt" "os" "strings" ) type Config struct { ConfigFile string Paths map[string]string } func (c *Config) readConfig() error { c.Paths = make(map[string]string) file, err := os.Open(c.ConfigFile) defer file.Close() if err == nil { scanner := bufio.NewScanner(file) f...
package config import ( "io/ioutil" "gopkg.in/yaml.v2" ) type Config struct { ConfigFile string Paths map[string]string } func (c *Config) readConfig() error { c.Paths = make(map[string]string) content, err := ioutil.ReadFile(c.ConfigFile) if err != nil { return err } m := make(map[interface{}]inte...
Use yaml for file format...
Use yaml for file format...
Go
mit
dmcbane/curd,dmcbane/curd
e5756de03d7c5d651cdb9013b749e40e1a561716
gohr.go
gohr.go
package gohr import ( "fmt" "log" "os" "golang.org/x/crypto/ssh/terminal" ) // getWidth gets number of width of terminal from crypto subdirectory ssh/terminal func getWidth() (int, error) { w, _, err := terminal.GetSize(int(os.Stdout.Fd())) if err != nil { return -1, err } return w, nil } // Draw fills a ...
package gohr import ( "fmt" "log" "os" "golang.org/x/crypto/ssh/terminal" ) // getWidth gets number of width of terminal from crypto subdirectory ssh/terminal func getTerminalWidth() (int, error) { w, _, err := terminal.GetSize(int(os.Stdout.Fd())) if err != nil { return -1, err } return w, nil } // Draw ...
Update function and variable names to be more descriptive
Update function and variable names to be more descriptive
Go
mit
hasit/gohr
adedb81854fbe6263e409bb510947b39331d39a0
example_test.go
example_test.go
package tricks_test import ( "fmt" "strings" "github.com/aviddiviner/tricks" ) var animals = []string{"dog", "cat", "bear", "cow", "bull", "pig", "iguana"} func ExampleSlice() { bearCow := tricks.Slice(animals). Map(strings.ToUpper). Last(5). First(2). Value().([]string) fmt.Println(bearCow) // Outp...
package tricks_test import ( "fmt" "strings" "github.com/aviddiviner/tricks" ) func ExampleSlice() { animals := []string{"dog", "cat", "bear", "cow", "bull", "pig", "iguana"} bearCow := tricks.Slice(animals). Map(strings.ToUpper). Last(5). First(2). Value().([]string) fmt.Println(bearCow) // Output:...
Tweak examples to look better
Tweak examples to look better
Go
mit
aviddiviner/tricks
6fdfddc8784b517b5a0e3ed71d7b2df25028ae35
engine/parser/interface.go
engine/parser/interface.go
package parser func ParseInstruction(instruction string) ([]Instruction, error) { l := lexer{} tokens, err := l.lex([]byte(instruction)) if err != nil { return nil, err } p := parser{} instructions, err := p.parse(tokens) if err != nil { return nil, err } return instructions, nil }
package parser import ( "errors" ) func ParseInstruction(instruction string) ([]Instruction, error) { l := lexer{} tokens, err := l.lex([]byte(instruction)) if err != nil { return nil, err } p := parser{} instructions, err := p.parse(tokens) if err != nil { return nil, err } if len(instructions) == 0...
Fix deadlock when no instructions are parsed
Fix deadlock when no instructions are parsed
Go
bsd-3-clause
proullon/ramsql,mlhoyt/ramsql
162c6afaa4d6d08e83e46d7e85acfad2be69ff53
consts/consts.go
consts/consts.go
/*Package consts implements constants for the entire project */ package consts // ConfigurationFileName is the configuration file name of Goyave const ConfigurationFileName = ".goyave" // GitFileName is the name of the git directory, in a git repository const GitFileName = ".git" //////////////// //// ERRORS //// /...
/*Package consts implements constants for the entire project */ package consts // VisibleFlag is the constant given for a visible repository const VisibleFlag = "VISIBLE" // HiddenFlag is the constant given for an hidden repository const HiddenFlag = "HIDDEN" // ConfigurationFileName is the configuration file name ...
Add two new constants to get the visibility of a given repository
Add two new constants to get the visibility of a given repository
Go
mit
k0pernicus/goyave
86c1b4254099d44ab9e9b7afe228d0aa074b6512
example/main.go
example/main.go
package main import ( "flag" "io/ioutil" "log" "os" "os/signal" "github.com/localhots/satan" "github.com/localhots/satan/example/daemons" ) func main() { var debug bool flag.BoolVar(&debug, "v", false, "Verbose mode") flag.Parse() if !debug { log.SetOutput(ioutil.Discard) } s := satan.Summon() s.Add...
package main import ( "flag" "io/ioutil" "log" "os" "os/signal" "github.com/localhots/satan" "github.com/localhots/satan/example/daemons" ) func main() { var debug bool flag.BoolVar(&debug, "v", false, "Verbose mode") flag.Parse() if !debug { log.SetOutput(ioutil.Discard) } s := satan.Summon() s.Add...
Use less code to catch the interrupt signal
Use less code to catch the interrupt signal
Go
mit
localhots/satan,localhots/satan,localhots/satan,localhots/satan
c8f432d96a4c035b1036143874600a53ff9006e0
core/core.go
core/core.go
package core import ( "github.com/akutz/gofig" ) func init() { initDrivers() gofig.Register(globalRegistration()) gofig.Register(driverRegistration()) } func globalRegistration() *gofig.Registration { r := gofig.NewRegistration("Global") r.Yaml(` rexray: host: tcp://:7979 logLevel: warn `) r.Key(gofig...
package core import ( "fmt" "github.com/akutz/gofig" "github.com/akutz/gotil" "github.com/emccode/rexray/util" ) func init() { initDrivers() gofig.SetGlobalConfigPath(util.EtcDirPath()) gofig.SetUserConfigPath(fmt.Sprintf("%s/.rexray", gotil.HomeDir())) gofig.Register(globalRegistration()) gofig.Register(d...
Fix for not setting Gofig config dirs (Rebased)
Fix for not setting Gofig config dirs (Rebased) This patch was originally commit d04023572e47e5c18fa549fe7f7de301e8470c63, but it failed to build in CI as it was not rebased off of master prior to being merged. This is the rebased patch. This patch fixes the issue where the Gofig's global (/etc) and user ($HOME) dire...
Go
apache-2.0
oppodeldoc/rexray,emccode/rexray,oppodeldoc/rexray,codedellemc/rexray,thecodeteam/rexray,clintonskitson/rexray,emccode/rexray,akutz/rexray,oppodeldoc/rexray,oppodeldoc/rexray,clintonskitson/rexray,oppodeldoc/rexray,thecodeteam/rexray,thecodeteam/rexray,clintonskitson/rexray,oppodeldoc/rexray,cduchesne/rexray,cduchesne/...
0194aff9e0cae475df41f9d4bd4b650e630ce65f
meta/cuesheet.go
meta/cuesheet.go
package meta // CueSheet contains the track information of a cue sheet. // // https://www.xiph.org/flac/format.html#metadata_block_cuesheet type CueSheet struct{}
package meta // A CueSheet describes how tracks are layed out within a FLAC stream. // // ref: https://www.xiph.org/flac/format.html#metadata_block_cuesheet type CueSheet struct { // Media catalog number. MCN string // Number of lead-in samples. This field only has meaning for CD-DA cue // sheets; for other uses i...
Add CueSheet, CueSheetTrack and CueSheetTrackIndex definitions.
meta: Add CueSheet, CueSheetTrack and CueSheetTrackIndex definitions.
Go
unlicense
mewkiz/flac
9ff243e677d44894259071b75222d9eb37a253f2
gettext/hello.go
gettext/hello.go
// Copyright 2013 <chaishushan{AT}gmail.com>. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore package main import ( "fmt" "code.google.com/p/gettext-go/gettext" ) func main() { gettext.SetLocale("zh_CN") gettext.BindT...
// Copyright 2013 <chaishushan{AT}gmail.com>. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build ignore package main import ( "fmt" "github.com/chai2010/gettext-go" ) func main() { gettext.SetLocale("zh_CN") gettext.BindTextdom...
Fix example import path for gvt-fetch support
Fix example import path for gvt-fetch support
Go
bsd-3-clause
chai2010/gettext-go
8a07b4ba433f108fbcc5b3f8732c67a50d527278
device/device.go
device/device.go
package device import ( "sync" "github.com/tarm/serial" ) type Manager struct { devices map[string]serial.Config mu sync.RWMutex } func (m *Manager) AddDevice(name string) error { cfg := serial.Config{Name: name} m.mu.Lock() m.devices[name] = cfg m.mu.Unlock() return nil } func (m *Manager) RemoveDev...
package device import ( "sync" "github.com/tarm/serial" ) type Manager struct { devices map[string]serial.Config conn []*Conn mu sync.RWMutex } func (m *Manager) AddDevice(name string) error { cfg := serial.Config{Name: name} m.mu.Lock() m.devices[name] = cfg m.mu.Unlock() return nil } func (m *M...
Use slice of *Conn instead of a map
Use slice of *Conn instead of a map These is very very devices at had. SO no need for a map
Go
mit
FarmRadioHangar/fessboxconfig,FarmRadioHangar/fessboxconfig
90e787723d4efbc080f0491e18a205f964c47326
uploader/uploader_test.go
uploader/uploader_test.go
package uploader import ( "github.com/matthew-andrews/s3up/objects" "testing" "time" ) type stubS3Client struct{} func (stub stubS3Client) UploadFile(string, objects.File) error { time.Sleep(50 * time.Millisecond) return nil } func uploadThreeFilesWithConcurrency(concurrency int) int64 { startTime := time.Now...
package uploader import ( "github.com/matthew-andrews/s3up/objects" "strings" "testing" "time" ) type stubS3Client struct{} func (stub stubS3Client) UploadFile(string, objects.File) error { time.Sleep(50 * time.Millisecond) return nil } func uploadThreeFilesWithConcurrency(concurrency int) int64 { startTime ...
Add a test for no files
Add a test for no files
Go
mit
matthew-andrews/s3up
6355d3a293054747b3344a9fe4bf153e4c9cff34
egroot/src/io/interfaces.go
egroot/src/io/interfaces.go
package io type Reader interface { Read([]byte) (int, error) } type Writer interface { Write([]byte) (int, error) } type ReadWriter interface { Reader Writer }
package io type Reader interface { Read([]byte) (int, error) } type Writer interface { Write([]byte) (int, error) } type ReadWriter interface { Reader Writer } type Closer interface { Close() error } type ReadCloser interface { Reader Closer } type WriteCloser interface { Writer Closer } type ReadWriteC...
Add Closer, ReadCloser, WriteCloser, ReadWriteCloser.
io: Add Closer, ReadCloser, WriteCloser, ReadWriteCloser.
Go
bsd-3-clause
ziutek/emgo,ziutek/emgo,ziutek/emgo,ziutek/emgo
f952f5ac6f80d952248256b1061334bca89036c9
help_test.go
help_test.go
package cli_test import ( "bytes" "testing" "github.com/codegangsta/cli" ) func TestShowAppHelp(t *testing.T) { output := new(bytes.Buffer) app := cli.NewApp() app.Writer = output c := cli.NewContext(app, nil, nil) cli.ShowAppHelp(c) if bytes.Index(output.Bytes(), []byte("AUTHOR(S):")) != -1 { t.Errorf...
package cli_test import ( "bytes" "testing" "github.com/codegangsta/cli" ) func Test_ShowAppHelp_NoAuthor(t *testing.T) { output := new(bytes.Buffer) app := cli.NewApp() app.Writer = output c := cli.NewContext(app, nil, nil) cli.ShowAppHelp(c) if bytes.Index(output.Bytes(), []byte("AUTHOR(S):")) != -1 { ...
Rename TestShowAppHelp to be more verbose
Rename TestShowAppHelp to be more verbose Follow golang convention
Go
mit
minio/cli,jgeewax/cli,minio/cli,minio/cli,murdinc/cli,cmars/tools,pjvds/cli,txgruppi/cli,murdinc/cli,squillace/cli,cmars/tools,pjvds/cli,nodirt/cli,oiooj/cli,klueska/cli,DirtyHairy/cli,codegangsta/cli,DirtyHairy/cli,keybase/cli,squillace/cli,masterlink720/cli,w4ngyi/cli,motain/cli,ykanda/cli,klueska/cli,jgeewax/cli,key...
eb88e3d88f3402a2373f83feae265d276d57aac3
logger/logger.go
logger/logger.go
package logger import ( "encoding/json" "log" "github.com/bsphere/le_go" "github.com/emreler/finch/config" ) // Logger . type Logger struct { conn *le_go.Logger } // NewLogger . func NewLogger(token config.LogentriesConfig) *Logger { le, err := le_go.Connect(string(token)) if err != nil { panic(err) } ...
package logger import ( "encoding/json" "log" "github.com/bsphere/le_go" "github.com/emreler/finch/config" ) const ( levelInfo = "INFO" levelError = "ERROR" ) // Logger . type Logger struct { conn *le_go.Logger } // LogMessage . type LogMessage struct { Level string `json:"level"` Message string `json:...
Add log levels to messages
Add log levels to messages
Go
mit
emreler/finch,emreler/finch
1038cc56ae8b5bc51c6cafbbb85d5dea3822609b
metric/metric.go
metric/metric.go
// Copyright 2015 Eleme Inc. All rights reserved. package metric // Metric with name and value type Metric struct { Name string // metric name Stamp uint32 // metric timestamp (able to use for 90 years from now) Value float64 // metric value Score float64 // metric anomaly score AvgOld float64 // previous...
// Copyright 2015 Eleme Inc. All rights reserved. package metric // Metric with name and value type Metric struct { // Name Name string // Timestamp in seconds, able to use for 90 years from now. Stamp uint32 // Current value Value float64 // metric value // Current anomaly score Score float64 // Current sta...
Add `Std` field to Metric
Add `Std` field to Metric
Go
mit
facesea/banshee,eleme/banshee,facesea/banshee,eleme/banshee,facesea/banshee,facesea/banshee,eleme/banshee,eleme/banshee,eleme/banshee
7e344772ede68f7cb8b2dbda8be81ac3dd251436
loadavg_stub.go
loadavg_stub.go
// +build !linux,!darwin package loadavg import ( "fmt" "runtime" ) func LoadAvg() ([3]float64, error) { return [...]float64{-1, -1, -1}, fmt.Errorf("loadavg: unsupported platform %q", runtime.GOOS) }
// +build !linux,!darwin package loadavg import ( "fmt" "runtime" ) func loadAvg() ([3]float64, error) { return [...]float64{-1, -1, -1}, fmt.Errorf("loadavg: unsupported platform %q", runtime.GOOS) }
Fix bug with stub loadAvg function.
Fix bug with stub loadAvg function.
Go
bsd-2-clause
davecheney/loadavg
20eb61f2d513968ae7c916473f377f537f2fc19c
package_test.go
package_test.go
package main import ( "testing" ) var sourceURITests = []struct { src string dst string }{ { "https://github.com/sunaku/vim-unbundle", "https://github.com/sunaku/vim-unbundle", }, } func TestSourceURI(t *testing.T) { for _, test := range sourceURITests { expect := test.dst actual, err := ToSourceURI(te...
package main import ( "testing" ) var sourceURITests = []struct { src string dst string }{ { "https://github.com/sunaku/vim-unbundle", "https://github.com/sunaku/vim-unbundle", }, { "Shougo/neobundle.vim", "https://github.com/Shougo/neobundle.vim", }, { "thinca/vim-quickrun", "https://github.com/...
Add case of short GitHub URI for ToSourceURI
Add case of short GitHub URI for ToSourceURI
Go
mit
kusabashira/vub
55150389a7df5078332274f7a042f835a3da7d9c
turbulence.go
turbulence.go
package main import ( "net" "os" ) func handleConnection(conn net.Conn) { connection := NewConnection(conn) defer connection.Close() connection.Handle() } func acceptedConnsChannel(listener net.Listener) chan net.Conn { channel := make(chan net.Conn) go func() { for { conn, err := listener.Accept() if...
package main import ( "net" "os" "flag" "strconv" ) func handleConnection(conn net.Conn) { connection := NewConnection(conn) defer connection.Close() connection.Handle() } func acceptedConnsChannel(listener net.Listener) chan net.Conn { channel := make(chan net.Conn) go func() { for { conn, err := list...
Make the proxy server listen port configurable
Make the proxy server listen port configurable
Go
mit
film42/turbulence
06b4a129a7b0c469553182195721a97cf170e181
utils.go
utils.go
package main import ( "code.google.com/p/gcfg" //Ref: http://code.google.com/p/gcfg/ "fmt" "os" "os/user" ) type Config struct { Auth struct { AccessKey string SecretKey string } } //Get the configurations from ~/.s3upload.conf func getConfigs() Config { usr, err := user.Current() if err != nil { fmt.P...
package main import ( "code.google.com/p/gcfg" //Ref: http://code.google.com/p/gcfg/ "fmt" "os" "os/user" ) type Config struct { Auth struct { AccessKey string SecretKey string } Locations struct { Source []string Destination []string } } //Get the configurations from ~/.s3upload.conf func getC...
Allow multiple sources and destination in config.
Allow multiple sources and destination in config.
Go
bsd-3-clause
codehill/s3upload
fa33810efaf76a30f8426f5001a217fc04f86782
utils.go
utils.go
package scipipe import ( // "github.com/go-errors/errors" //"os" "os" "os/exec" re "regexp" ) func ExecCmd(cmd string) string { Info.Println("Executing command: ", cmd) combOutput, err := exec.Command("bash", "-lc", cmd).CombinedOutput() if err != nil { Error.Println("Could not execute command `" + cmd + "`...
package scipipe import ( // "github.com/go-errors/errors" //"os" "os" "os/exec" re "regexp" ) func ExecCmd(cmd string) string { Info.Println("Executing command: ", cmd) combOutput, err := exec.Command("bash", "-lc", cmd).CombinedOutput() if err != nil { Error.Println("Could not execute command `" + cmd + "`...
Print both custom and original error messages
Print both custom and original error messages
Go
mit
scipipe/scipipe,scipipe/scipipe,samuell/scipipe
08c9e67dfb30d14fb5346e958ddf68b7223d8e84
prototype/main.go
prototype/main.go
package main import ( "io" "log" "os" "os/exec" "time" ) func runner(what string) { f, err := os.OpenFile("testlogfile", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if err != nil { panic("NOOOOO") } defer f.Close() log.SetOutput(f) log.Println("### Starting:") cmd := exec.Command(what) ...
package main import ( "fmt" "io" "log" "os" "os/exec" "time" ) func runner(what string) { f, err := os.OpenFile("testlogfile", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) if err != nil { panic("NOOOOO") } defer f.Close() log.SetOutput(f) log.Println("### Starting:") defer log.Println(...
Fix issues with capturing stdout and error messages for the runner.
Fix issues with capturing stdout and error messages for the runner.
Go
mit
elezar/go-faster,elezar/go-faster
c5cd9c7ed6f0e13b7c7b843d50311f72bcea6759
sux.go
sux.go
package main import ( "flag" "fmt" "github.com/nsf/termbox-go" ) func MaybePanic(err error) { if err != nil { panic(err) } } var ( Quit chan struct{} Redraw chan struct{} ) func main() { flag.Parse() if len(flag.Args()) == 0 { fmt.Println("sux: no commands given") fmt.Println("Usage sux [command .....
package main import ( "flag" "fmt" "github.com/nsf/termbox-go" ) func MaybePanic(err error) { if err != nil { panic(err) } } var ( Quit chan struct{} Redraw chan struct{} ) func main() { flag.Parse() if len(flag.Args()) == 0 { fmt.Println("sux: no commands given") fmt.Println("Usage sux [command .....
Set output mode to 256 by default
Set output mode to 256 by default
Go
mit
chrisseto/Sux
47d1899c4c5b8eaf3899d7131c7bc1a5e811098a
api/about.go
api/about.go
package api import ( "net/http" "fmt" ) var AboutPath = "/about/" func AboutHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "About, %s!", r.URL.Path[1:]) }
package api import ( "net/http" "encoding/json" ) type Message struct{ Text string } var AboutPath = "/about/" func AboutHandler(w http.ResponseWriter, r *http.Request) { msg := Message{"goapi API v0a (alpha)"} jsonMsg, err := json.Marshal(msg) if err != nil { panic(err) } w.Write(jsonMsg) }
Add send json in api response for AboutHandler
Add send json in api response for AboutHandler
Go
apache-2.0
mwharris1313/goapi,mwharris1313/goapi,mwharris1313/goapi
61b5fe7f2fcb11a25696b2232359958dfef63869
stringutil_test.go
stringutil_test.go
package venom import ( "testing" "github.com/stretchr/testify/assert" ) func TestParseEmpty(t *testing.T) { m, err := parseMapStringString("", ",", "=") assert.Nil(t, err) assert.Equal(t, m, map[string]string{}) } func TestParseSingle(t *testing.T) { m, err := parseMapStringString("foo=bar", ",", "=") assert...
package venom import ( "testing" "github.com/stretchr/testify/assert" ) type setup struct { s string m map[string]string } var ( table = map[string]setup{ "empty": { s: "", m: map[string]string{}, }, "single": { s: "foo=bar", m: map[string]string{ "foo": "bar", }, }, "multiple": { ...
Add tests for parse & serialize
Add tests for parse & serialize
Go
mit
themalkolm/venom
f20d09acce7fdae6c6a9ac6c4596a90ec4b596b5
blog_info.go
blog_info.go
package tumblr import ( "encoding/json" ) // Blog Info func (blog Blog) Info() (*BlogInfo, error) { url, err := blog.blogEntityURL("info") if err != nil { return nil, err } data, err := callAPI(url) var v BlogInfo json.Unmarshal(data, &v) return nil, nil } // Type returned by blog.Info() type BlogInfo str...
package tumblr import ( ) // Blog Info func (blog Blog) Info() (*BlogInfo, error) { // url, err := blog.blogEntityURL("info") // if err != nil { // return nil, err // } //res, err := callAPI(url) return nil, nil } // Type returned by blog.Info() type BlogInfo struct { Title string Posts int64...
Comment this out so it compiles for now
Comment this out so it compiles for now
Go
mit
hut8/tumblr-go
8db782f83c1e97472e09b7e4dc1639eed65f98fd
ldap.go
ldap.go
package vaultutil import ( vaultapi "github.com/hashicorp/vault/api" ) func GetGroups(c *vaultapi.Client) (*vaultapi.Secret, error) { resp, err := c.Logical().List("auth/ldap/groups") if err != nil { return resp, err } return resp, err } func DeleteGroups(c *vaultapi.Client, groupname string) (*vaultapi.Secre...
package vaultutil import ( vaultapi "github.com/hashicorp/vault/api" ) func GetGroups(c *vaultapi.Client) (*vaultapi.Secret, error) { resp, err := c.Logical().List("auth/ldap/groups") if err != nil { return resp, err } return resp, err } func DeleteGroup(c *vaultapi.Client, groupname string) (*vaultapi.Secret...
Fix logical path for DeleteGroup call
Fix logical path for DeleteGroup call
Go
apache-2.0
gobins/vaultutil
b4039d9645e7c9479ab84427030da6e01acb7ed1
main.go
main.go
package main import ( "fmt" "net/http" "os" ) func hello(resp http.ResponseWriter, req *http.Request) { fmt.Fprintln(resp, "<html><head><title>How about them apples?!</title></head><body><h1>") fmt.Fprintln(resp, "Hello world!") fmt.Fprintln(resp, "</h1></body></html>") } func main() { http.HandleFunc("/", he...
package main import ( "html/template" "net/http" "os" ) func hello(resp http.ResponseWriter, req *http.Request) { content, err := template.New("").Parse("<html><head><title>{{.title}}</title></head><body><ul>{{range .envs}}<li>{{.}}</li>{{end}}</ul></body></html>") if err != nil { panic(err) } ctx := map[st...
Use templates to print env.
Use templates to print env.
Go
mit
jgastal/mural,jgastal/mural,jgastal/mural,jgastal/mural
674cfed2ec1f4f196760464d42a7c3b72f7aa197
main.go
main.go
package main import ( "fmt" "os" "path/filepath" rat "github.com/ericfreese/rat/lib" flag "github.com/spf13/pflag" ) var ( RatVersion = "0.0.2" ) var flags struct { cmd string mode string version bool } func init() { flag.StringVarP(&flags.cmd, "cmd", "c", "cat ~/.config/rat/ratrc", "command to ru...
package main import ( "fmt" "os" "path/filepath" rat "github.com/ericfreese/rat/lib" flag "github.com/spf13/pflag" ) var ( RatVersion = "0.0.2" ) var flags struct { cmd string mode string version bool } func init() { flag.StringVarP(&flags.cmd, "cmd", "c", "", "command to run (required)") flag.St...
Remove default for 'cmd' flag
Remove default for 'cmd' flag See GitHub issue #20
Go
mit
ericfreese/rat,ericfreese/rat
78993420d67f70ffa6d5b77e22eece9e4add01b4
routerparams.go
routerparams.go
package minion import ( "mime/multipart" "github.com/pressly/chi" ) func (c *Context) ByGet(name string) string { return chi.URLParam(c.Req, name) } func (c *Context) ByQuery(name string) string { values := c.Req.URL.Query() if len(values) == 0 { return "" } return values[name][0] } func (c *Context) ByP...
package minion import ( "mime/multipart" "github.com/pressly/chi" ) // ByGet shortcut to chi.URLParam // returns the url parameter from a http.Request object. func (c *Context) ByGet(name string) string { return chi.URLParam(c.Req, name) } // ByQuery shortcut to (u *URL) Query() // parses RawQuery and returns th...
Add comment to params funcs
Add comment to params funcs
Go
mit
ustrajunior/minion
f47cde8a0ba3994cc17f9517f0bf217a2c9756a3
src/main/main.go
src/main/main.go
package main import ( "errors" "sdl" ) const ( defaultWidth, defaultHeight = 1024, 768 gameName = "gogame" ) func main() { ctx, err := sdl.NewContext(gameName, defaultWidth, defaultHeight) if err != nil { panic(err) } defer ctx.Close() quit := errors.New("quitting") for { err = sdl.HandleEvents(func(...
package main import ( "errors" "sdl" ) const ( defaultWidth, defaultHeight = 1024, 768 gameName = "gogame" ) var ( quitting = errors.New("quitting") ) func eventHandler(e interface{}) error { switch v := e.(type) { case sdl.QuitEvent: return quitting case sdl.KeyEvent: if v.Type == sdl.KeyUp { switch...
Put event handler in separate func
Put event handler in separate func
Go
mit
DrJosh9000/gogame,DrJosh9000/gogame
3619a796dc015f673260575a1910b31bb924ebc8
internal/ui/ui_windows.go
internal/ui/ui_windows.go
// Copyright 2016 Hajime Hoshi // // 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 2016 Hajime Hoshi // // 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...
Check the return value of ReleaseDC()
ui: Check the return value of ReleaseDC()
Go
apache-2.0
hajimehoshi/ebiten,hajimehoshi/ebiten
a3b2d4ac6387d4aa149357f15ff5fc7eea79b6f0
pdf/file_test.go
pdf/file_test.go
package pdf import "testing" func TestTestFile (t *testing.T) { f := NewFile("/tmp/foo.pdf") f.Close() }
package pdf import "testing" func TestTestFile (t *testing.T) { f := NewFile("/tmp/foo.pdf") obj1 := f.AddObject (NewNumeric(3.14)) obj2 := f.AddObject (NewNumeric(2.718)) f.DeleteObject (obj1) f.AddObject (NewNumeric(3)) f.DeleteObject (obj2) f.Close() }
Add File.AddObject() and File.DeleteObject() to unit test.
Add File.AddObject() and File.DeleteObject() to unit test.
Go
apache-2.0
mawicks/PDFiG
09f9059971da62e8e8716ce7c80707884a8e3002
slackapi_test.go
slackapi_test.go
package slackapi import ( "encoding/json" "testing" ) func CheckResponse(t *testing.T, x interface{}, y string) { out, err := json.Marshal(x) if err != nil { t.Fatal("json fromat;", err) } if string(out) != y { t.Fatalf("invalid json response;\n- %s\n+ %s\n", y, out) } } func TestAPITest(t *testing.T) { ...
package slackapi import ( "encoding/json" "testing" ) func CheckResponse(t *testing.T, x interface{}, y string) { out, err := json.Marshal(x) if err != nil { t.Fatal("json fromat;", err) } if string(out) != y { t.Fatalf("invalid json response;\n- %s\n+ %s\n", y, out) } } func TestAPITest(t *testing.T) { ...
Remove apps.list unit test due to API uncertanties
Remove apps.list unit test due to API uncertanties
Go
mit
cixtor/slackapi
f10c846ab60d234aa449c042068ce461b2f6ed9a
internal/vm/errors/errors.go
internal/vm/errors/errors.go
// Copyright 2015 Google Inc. All Rights Reserved. // This file is available under the Apache license. package errors import ( "fmt" "github.com/google/mtail/internal/vm/position" "github.com/pkg/errors" ) type compileError struct { pos position.Position msg string } func (e compileError) Error() string { re...
// Copyright 2015 Google Inc. All Rights Reserved. // This file is available under the Apache license. package errors import ( "fmt" "strings" "github.com/google/mtail/internal/vm/position" "github.com/pkg/errors" ) type compileError struct { pos position.Position msg string } func (e compileError) Error() s...
Use strings.Builder instead of string concatenation.
Use strings.Builder instead of string concatenation. #lint
Go
apache-2.0
SuperQ/mtail,google/mtail,google/mtail,SuperQ/mtail