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
b5838e3ce503c8ccd54bc29ff91a9bb83b8bab09
examples/main.go
examples/main.go
package main import ( "image/color" "github.com/ajhager/rog" ) func game(w *rog.Window) { grey := color.RGBA{20, 20, 20, 255} for x := 0; x < 40; x++ { for y := 0; y < 20; y++ { purple := color.RGBA{uint8(150 + x%255), uint8(y * x), uint8((y * 4) % 255), 255} w.Set(x, y, rune(1000+(2*(x+(x*y))...
package main import ( "image/color" "github.com/ajhager/rog" ) func game(w *rog.Window) { grey := color.RGBA{20, 20, 20, 255} for x := 0; x < w.Width(); x++ { for y := 0; y < w.Height(); y++ { purple := color.RGBA{uint8(200), uint8(y * x), uint8((y * 4) % 255), 255} w.Set(x, y, rune(1000+(2*(x...
Make example use Console.Width() and .Height()
Make example use Console.Width() and .Height()
Go
bsd-2-clause
dparis/rog,dparis/rog,ajhager/rog,ajhager/rog
e123487753c06bc1461198e95ffd599092cde9be
interrupt_windows_test.go
interrupt_windows_test.go
package main import ( "fmt" "os" "syscall" ) func interruptProcess() { pid := os.Getpid() d, e := syscall.LoadDLL("kernel32.dll") if e != nil { panic(fmt.Sprintf("LoadDLL: %v", e)) } p, e := d.FindProc("GenerateConsoleCtrlEvent") if e != nil { panic(fmt.Sprintf("FindProc: %v", e)) } r, _, e := p.Call(s...
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the GO_LICENSE file. // // This is based on code from the os/signal tests package main import ( "fmt" "os" "syscall" ) func interruptProcess() { pid := os.Getpid() d, err ...
Add Go copyright and licence for some of the code
Add Go copyright and licence for some of the code
Go
unknown
vlifesystems/rulehunter,vlifesystems/rulehuntersrv,vlifesystems/rulehuntersrv,vlifesystems/rulehunter
4428079a68dd0876bd27a1f2e7ccdb35cda23ede
builder/amazon/common/regions.go
builder/amazon/common/regions.go
package common func listEC2Regions() []string { return []string{ "ap-northeast-1", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "cn-north-1", "eu-central-1", "eu-west-1", "sa-east-1", "us-east-1", "us-gov-west-1", "us-west-1", "us-west-2", } } // ValidateRegion returns true if the s...
package common func listEC2Regions() []string { return []string{ "ap-northeast-1", "ap-northeast-2", "ap-south-1", "ap-southeast-1", "ap-southeast-2", "cn-north-1", "eu-central-1", "eu-west-1", "sa-east-1", "us-east-1", "us-gov-west-1", "us-west-1", "us-west-2", } } // ValidateRegion retur...
Add support for ap-south-1 in AWS
Add support for ap-south-1 in AWS Amazon recently announced support for ap-south-1 in Mumbai, adding this to the list of known regions to Packer
Go
mpl-2.0
pecigonzalo/packer,jimmythedog/packer,timsutton/packer,mayflower/packer,markpeek/packer,zhuzhih2017/packer,taliesins/packer,pecigonzalo/packer,taliesins/packer,p1-nico/packer,mkuzmin/packer,youhong316/packer,bryson/packer,paulmey/packer,Akasurde/packer,samdunne/packer,tb3088/packer,paulmey/packer,dayglojesus/packer,tsm...
52cbab29712b1448aa587ac3b3f9414b16a40800
ghs.go
ghs.go
package main import ( "bytes" "fmt" "log" "net/http" "strings" ) const baseURL = "https://api.github.com/search/repositories" func escapeSearch(s string) string { return strings.Replace(s, " ", "+", -1) } func searchString(q string, lang string, limit int) string { var buffer bytes.Buffer buffer.WriteString...
package main import ( "bytes" "fmt" "log" "net/http" "strings" ) const baseURL = "https://api.github.com/search/repositories" type Query struct { Q string Lang string Limit int } func escapeSearch(s string) string { return strings.Replace(s, " ", "+", -1) } func searchString(q Query) string { var buffer ...
Use Query struct for searchString method
Use Query struct for searchString method
Go
mit
keith/ghs
48f42b22f314edb46d924f9425d7ab3b49067a5d
net.go
net.go
package tools import ( "net/http" ) //Get the client ip address... func GetClientAddr(r *http.Request) string { ip := r.Header.Get("X-Real-IP") if 0 == len(ip) { ip = r.Header.Get("X-Forwarded-For") if 0 == len(ip) { ip = r.RemoteAddr } } return ip }
package tools import ( "net/http" ) //Get the client ip address... func GetClientAddr(r *http.Request) string { ip := r.Header.Get("X-Real-IP") if 0 == len(ip) { ip = r.Header.Get("X-Forwarded-For") if 0 == len(ip) { ip = r.RemoteAddr } } return ip } //Look into the headers or into the Query parameters...
Add a method that reads in the Header and in the Query parameters for a given information
Add a method that reads in the Header and in the Query parameters for a given information
Go
mit
scritch007/go-tools
3650d79be34b44621a0948e662a010a4d0d7c0d8
_example/run_build.go
_example/run_build.go
package main import ( "fmt" "os" "github.com/sylphon/build-runner" "github.com/sylphon/build-runner/builderfile" ) var example = &builderfile.UnitConfig{ Version: 1, ContainerArr: []*builderfile.ContainerSection{ &builderfile.ContainerSection{ Name: "app", Dockerfile: "Dockerfile", Registry: ...
package main import ( "fmt" "os" "github.com/sylphon/build-runner" "github.com/sylphon/build-runner/unit-config" ) var example = &unitconfig.UnitConfig{ Version: 1, ContainerArr: []*unitconfig.ContainerSection{ &unitconfig.ContainerSection{ Name: "app", Dockerfile: "Dockerfile", Registry: "q...
Update _example code to reflect package name changes
Update _example code to reflect package name changes
Go
mit
winchman/builder-core
973cf690886f8dc989767c4bb8e80bc8d6540ed1
resource/api/server/server.go
resource/api/server/server.go
// Copyright 2015 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package server import ( "github.com/juju/loggo" ) var logger = loggo.GetLogger("juju.resource.api.server") // State is the functionality of Juju's state needed for the resources API. type State interface { specState } //...
// Copyright 2015 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package server import ( "github.com/juju/loggo" ) var logger = loggo.GetLogger("juju.resource.api.server") // Version is the version number of the current Facade. const Version = 0 // State is the functionality of Juju's ...
Add a constant for the API facade version.
Add a constant for the API facade version.
Go
agpl-3.0
waigani/juju,mikemccracken/juju,frankban/juju,dimitern/juju,waigani/juju,mikemccracken/juju,mikemccracken/juju,ericsnowcurrently/juju,ericsnowcurrently/juju,voidspace/juju,perrito666/juju,mjs/juju,makyo/juju,dooferlad/juju,howbazaar/juju,fwereade/juju,AdamIsrael/juju,dooferlad/juju,waigani/juju,bz2/juju,bac/juju,fwerea...
244143baf3ef64c3419b6f33a20e3a94fc3362ca
routing_api_cli_suite_test.go
routing_api_cli_suite_test.go
package main_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" "testing" ) func TestRoutingApiCli(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "RoutingApiCli Suite") } var path string var _ = BeforeSuite(func() { var err error path, err = gexec.Buil...
package main_test import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/onsi/gomega/gexec" "testing" ) func TestRoutingApiCli(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "RoutingApiCli Suite") } var path string var _ = SynchronizedBeforeSuite(func() []byte { binaryPath, err :=...
Build binary once when running tests parallel
Build binary once when running tests parallel
Go
apache-2.0
cloudfoundry-incubator/routing-api-cli,cloudfoundry-incubator/routing-api-cli
86767d3ccbe39cd65a00caffd1fbc35ee73a5a55
worker/diskmanager/diskmanager_unsupported.go
worker/diskmanager/diskmanager_unsupported.go
// Copyright 2014 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. // +build !linux package diskmanager import ( "runtime" "github.com/juju/juju/storage" "github.com/juju/juju/version" ) var blockDeviceInUse = func(storage.BlockDevice) (bool, error) { panic("not supported") } func li...
// Copyright 2014 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. // +build !linux package diskmanager import ( "runtime" "github.com/juju/juju/storage" ) var blockDeviceInUse = func(storage.BlockDevice) (bool, error) { panic("not supported") } func listBlockDevices() ([]storage.Bloc...
Remove now unused version import in diskmanager
Remove now unused version import in diskmanager File is only compiled on windows, but breaks the build there as go is strict about redundant imports.
Go
agpl-3.0
dooferlad/juju,mikemccracken/juju,mikemccracken/juju,ericsnowcurrently/juju,mjs/juju,bz2/juju,dimitern/juju,davecheney/juju,dimitern/juju,howbazaar/juju,makyo/juju,bogdanteleaga/juju,wwitzel3/juju,bogdanteleaga/juju,cloud-green/juju,fwereade/juju,howbazaar/juju,perrito666/juju,macgreagoir/juju,axw/juju,voidspace/juju,a...
de80557a1bd3e2ff1e06e8a1d8d382b4fff9b8d6
pkg/artnet/ip.go
pkg/artnet/ip.go
package artnet import ( "fmt" "net" "strings" ) const ( // addressRange specifies the network CIDR an artnet network should have addressRange = "2.0.0.0/8" ) // FindArtNetIP finds the matching interface with an IP address inside of the addressRange func FindArtNetIP() (net.IP, error) { var ip net.IP _, cidrn...
package artnet import ( "fmt" "net" "strings" ) const ( // addressRange specifies the network CIDR an artnet network should have addressRange = "2.0.0.0/8" ) // FindArtNetIP finds the matching interface with an IP address inside of the addressRange func FindArtNetIP() (net.IP, error) { _, cidrnet, _ := net.Par...
Fix wrongly as ArtNet Subnet identified IPv6 interface
Fix wrongly as ArtNet Subnet identified IPv6 interface
Go
mit
StageAutoControl/controller
62ca57238b5b706993491bef9a8d43e863bb2190
validates/validates.go
validates/validates.go
package validates import ( "github.com/mitsuse/matrix-go" ) const ( NON_POSITIVE_SIZE_PANIC = iota DIFFERENT_SIZE_PANIC OUT_OF_RANGE_PANIC ) func ShapeShouldBePositive(row, column int) { if row > 0 && column > 0 { return } panic(NON_POSITIVE_SIZE_PANIC) } func ShapeShouldBeSame(m, n matrix.Matrix) { mRow...
package validates const ( NON_POSITIVE_SIZE_PANIC = iota DIFFERENT_SIZE_PANIC OUT_OF_RANGE_PANIC ) func ShapeShouldBePositive(row, column int) { if row > 0 && column > 0 { return } panic(NON_POSITIVE_SIZE_PANIC) } type HasShape interface { Shape() (rows, columns int) } func ShapeShouldBeSame(m, n HasShape...
Define "HasShape" interface" to avoid dependency cycle.
Define "HasShape" interface" to avoid dependency cycle.
Go
mit
mitsuse/matrix-go,jmptrader/matrix-go
c7d6b7885982b589134835f11c7cae0c60a059f2
smoke/helpers.go
smoke/helpers.go
package smoke import ( "time" "github.com/cloudfoundry-incubator/cf-test-helpers/cf" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) const ( SimpleBinaryAppBitsPath = "../../assets/binary" SimpleDotnetAppBitsPath = "../../assets/dotnet_simple/NetSimple" ) func SkipIfN...
package smoke import ( "time" "github.com/cloudfoundry-incubator/cf-test-helpers/cf" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" . "github.com/onsi/gomega/gexec" ) const ( SimpleBinaryAppBitsPath = "../../assets/binary" SimpleDotnetAppBitsPath = "../../assets/dotnet_simple/Published" ) func SkipIfN...
Revert "Use NetSimple source bits path"
Revert "Use NetSimple source bits path" This reverts commit 5d8cf1b3039723bb8de903b6dcfb82482d5dbac1.
Go
apache-2.0
cloudfoundry/cf-smoke-tests,cloudfoundry/cf-smoke-tests,cloudfoundry/cf-smoke-tests,cloudfoundry/cf-smoke-tests
f363f262a11ce804f01bf8fbb9674796bb9ad4b3
web/env_session.go
web/env_session.go
package web import ( "net/http" "github.com/gorilla/sessions" ) const SESSION_NAME = "funrepo" const SESSION_USER_KEY = "auth_user" type Session struct { *sessions.Session } func (session *Session) AuthUser() *User { rawUser := session.Values[SESSION_USER_KEY] if user, ok := rawUser.(*User); ok { return use...
package web import ( "net/http" "github.com/gorilla/sessions" ) const SESSION_NAME = "vmango" const SESSION_USER_KEY = "auth_user" type Session struct { *sessions.Session } func (session *Session) AuthUser() *User { rawUser := session.Values[SESSION_USER_KEY] if user, ok := rawUser.(*User); ok { return user...
Change hardcoded session cookie name
Change hardcoded session cookie name
Go
mit
subuk/vmango,subuk/vmango,subuk/vmango,subuk/vmango,subuk/vmango,subuk/vmango
b1db929263028b3c26c38fa67fcbaf70c5a1a8f1
labb1/index/index.go
labb1/index/index.go
package index import () // Pointer within a file type filePointer uint64 // Index of word positions in the lexicon file type fileIndex map[string][]filePointer // Adds a lexicon position for a word func (fi fileIndex) add(word string, position filePointer) { fi[word] = append(fi[word], position) } // Index of wor...
package index import ( "github.com/maxnordlund/adk/labb1/lexer" "io" "os" ) // Pointer within a file type filePointer uint64 // Index of word positions in the lexicon file type fileIndex map[string][]filePointer func NewFileIndex(name string) (fi fileIndex, err error) { korpus, err := os.Open(name) if err != n...
Add NewFileIndex using the lexer
Add NewFileIndex using the lexer
Go
mit
maxnordlund/adk,maxnordlund/adk,maxnordlund/adk,maxnordlund/adk
485ef3766dec44caa52fa5731e6cb66f8ab4664b
go/misc/test.go
go/misc/test.go
package main import ( "fmt" "github.com/satori/go.uuid" ) func main() { u := uuid.NewV4() fmt.Println(u) }
package main import ( "fmt" "io/ioutil" ) func main() { if err := ioutil.WriteFile("/tmp/tmp/tmp/tmp", []byte(""), 0644); err != nil { panic(fmt.Sprintf("Error writing file: %s", err)) } /* // import "github.com/satori/go.uuid" u := uuid.NewV4() fmt.Println(u) */ }
Test panic message while writing a file
Test panic message while writing a file
Go
mit
bmaupin/junkpile,bmaupin/junkpile,bmaupin/junkpile,bmaupin/junkpile,bmaupin/junkpile,bmaupin/junkpile,bmaupin/junkpile,bmaupin/junkpile,bmaupin/junkpile
8c8ff0e77793ab4db1dfef9ccc16e92a8d056e6d
imapclient/date_test.go
imapclient/date_test.go
// Copyright 2015 NF Design UG (haftungsbeschraenkt). All rights reserved. // Use of this source code is governed by the Apache License v2.0 // which can be found in the LICENSE file. package imapclient import ( "testing" "time" ) const utilsTestLogPrefix = "date_test.go: " func TestDateParse(t *testing.T) { va...
// Copyright 2015 NF Design UG (haftungsbeschraenkt). All rights reserved. // Use of this source code is governed by the Apache License v2.0 // which can be found in the LICENSE file. package imapclient import ( "testing" "time" ) const utilsTestLogPrefix = "date_test.go: " func TestDateParse(t *testing.T) { va...
Use RFC822 date strings for date parser unit tests
Use RFC822 date strings for date parser unit tests
Go
apache-2.0
nfdesign/maping
3b13756dd8d6a00e9177e9f5769cca5a42b64c76
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 Radius to the DrawingInstruction
Add Radius to the DrawingInstruction
Go
mit
rustyoz/svg
1d5872ab710a532675e33e46fe97a18ac61f5ccf
config/wizard.go
config/wizard.go
package config import ( "bufio" "fmt" "log" "os" "strings" ) func getUsername(configuration *Configuration) { for { reader := bufio.NewReader(os.Stdin) fmt.Print("Spotify Username: ") username, err := reader.ReadString('\n') if err != nil { log.Fatal(err) } if len(username)-1 > 0 { configurati...
package config import ( "bufio" "fmt" "github.com/howeyc/gopass" "log" "os" "strings" ) func getUsername(configuration *Configuration) { for { reader := bufio.NewReader(os.Stdin) fmt.Print("Spotify Username: ") username, err := reader.ReadString('\n') if err != nil { log.Fatal(err) } if len(user...
Use gopass to catch the password without displaying it
Use gopass to catch the password without displaying it
Go
mit
adrien-f/gotify
0f76bcd6c8057d70ca1a1022c800aa1e048c0f01
command/register.go
command/register.go
package command import ( "strings" "os" "log" "fmt" "github.com/wantedly/developers-account-mapper/store" "github.com/wantedly/developers-account-mapper/models" ) type RegisterCommand struct { Meta } func (c *RegisterCommand) Run(args []string) int { var loginName, githubUsername string if len(args) == 1 { ...
package command import ( "strings" "os" "log" "fmt" "github.com/wantedly/developers-account-mapper/store" "github.com/wantedly/developers-account-mapper/models" ) type RegisterCommand struct { Meta } func (c *RegisterCommand) Run(args []string) int { var loginName, githubUsername string if len(args) == 1 { ...
Move var err inside if statement
Move var err inside if statement
Go
mit
wantedly/developers-account-mapper
b9a1580c3ffe489eae3c71be58ec07d2ccf9e82e
pkg/logger/syslog.go
pkg/logger/syslog.go
// +build linux darwin package logger import ( "log/syslog" "github.com/sirupsen/logrus" logrus_syslog "github.com/sirupsen/logrus/hooks/syslog" ) func syslogHook() (logrus.Hook, error) { return logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO, "cozy") }
// +build !windows package logger import ( "log/syslog" "github.com/sirupsen/logrus" logrus_syslog "github.com/sirupsen/logrus/hooks/syslog" ) func syslogHook() (logrus.Hook, error) { return logrus_syslog.NewSyslogHook("", "", syslog.LOG_INFO, "cozy") }
Fix building cozy-stack on FreeBSD
Fix building cozy-stack on FreeBSD
Go
agpl-3.0
nono/cozy-stack,nono/cozy-stack,nono/cozy-stack,nono/cozy-stack,nono/cozy-stack
a0aad9fd1cb9114c8e4e974c9ac4bdc6ea1926f3
window/events.go
window/events.go
package window /* #include <SDL2/SDL.h> int getEventType(SDL_Event e) { return e.type; } int getEventKey(SDL_Event e) { return e.key.keysym.scancode; } int getEventKeyState(SDL_Event e) { return e.key.state; } */ import "C" const ( WindowQuit int = int(C.SDL_QUIT) KeyEventDown int = int(C.SDL...
package window /* #include <SDL2/SDL.h> int getEventType(SDL_Event e) { return e.type; } int getEventKey(SDL_Event e) { return e.key.keysym.scancode; } int getEventKeyState(SDL_Event e) { return e.key.state; } SDL_TextInputEvent getInputText(SDL_Event e) { return e.text; } */ import "C" const ( Window...
Add in utf8 text entry
Add in utf8 text entry
Go
mit
anthonyrego/gosmf,anthonyrego/dodge
03517118034de160a85b2b693c23089c491d8a3e
v2/util.go
v2/util.go
// Copyright 2013 Michael Yang. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package v2 func isBitSet(flag, index byte) bool { return flag&(1<<index) == 1 }
// Copyright 2013 Michael Yang. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. package v2 func isBitSet(flag, index byte) bool { return flag&(1<<index) != 0 }
Fix flag truth value issue
Fix flag truth value issue
Go
mit
mikkyang/id3-go
906f709e0c779acdc3904b3127dd6be2a9cf1cee
internal/nbconn/nbconn_fake_non_block.go
internal/nbconn/nbconn_fake_non_block.go
//go:build !(aix || android || darwin || dragonfly || freebsd || hurd || illumos || ios || linux || netbsd || openbsd || solaris) package nbconn // Not using unix build tag for support on Go 1.18. func (c *NetConn) realNonblockingWrite(b []byte) (n int, err error) { return fakeNonblockingWrite(b) } func (c *NetCon...
//go:build !(aix || android || darwin || dragonfly || freebsd || hurd || illumos || ios || linux || netbsd || openbsd || solaris) package nbconn // Not using unix build tag for support on Go 1.18. func (c *NetConn) realNonblockingWrite(b []byte) (n int, err error) { return c.fakeNonblockingWrite(b) } func (c *NetC...
Fix typo in Windows code
Fix typo in Windows code https://github.com/jackc/pgx/issues/1274
Go
mit
jackc/pgx,jackc/pgx,jackc/pgx,jackc/pgx
f73a37c7aa78775701db4302185bd128dff3dbfe
goat/apiFiles.go
goat/apiFiles.go
package goat import ( "encoding/json" "log" ) // GetFilesJSON returns a JSON representation of one or more FileRecords func GetFilesJSON(ID int, resChan chan []byte) { // Check for a valid integer ID if ID > 0 { // Load file file := new(FileRecord).Load(ID, "id") // Marshal into JSON res, err := json.Mar...
package goat import ( "encoding/json" "log" ) // GetFilesJSON returns a JSON representation of one or more FileRecords func GetFilesJSON(ID int, resChan chan []byte) { // Check for a valid integer ID if ID > 0 { // Load file file := new(FileRecord).Load(ID, "id") // Marshal into JSON res, err := json.Mar...
Make GetFilesJSON return after sending on channel
Make GetFilesJSON return after sending on channel
Go
mit
mdlayher/goat
c9af83722b7c0de1aa0dbb5d9f62afa1f17a513b
cmd.go
cmd.go
package rerun import ( "os" "os/exec" ) type Cmd struct { cmd *exec.Cmd args []string } func Run(args ...string) (*Cmd, error) { cmd := &Cmd{ args: args, } if err := cmd.run(); err != nil { return nil, err } return cmd, nil } func (c *Cmd) run() error { c.cmd = nil cmd := exec.Command(c.args[0], c...
package rerun import ( "fmt" "os" "os/exec" "syscall" ) type Cmd struct { cmd *exec.Cmd args []string } func Command(args ...string) (*Cmd, error) { c := &Cmd{ args: args, } if err := c.Start(); err != nil { return nil, err } return c, nil } func (c *Cmd) Start() error { cmd := exec.Command(c.args...
Kill the process group (children of children)
Kill the process group (children of children)
Go
mit
VojtechVitek/rerun
d618440ac9c78b20a44a2372ec6a9991a36b47ae
config/admin/funcmap.go
config/admin/funcmap.go
package admin import ( "time" "github.com/qor/qor-example/app/models" ) func initFuncMap() { Admin.RegisterFuncMap("latest_orders", latestOrders) // Admin.RegisterFuncMap("last_week_orders_chart", lastWeekOrderChart) // Admin.RegisterFuncMap("last_week_users_chart", lastWeekUserChart) } func latestOrders() (or...
package admin import "github.com/qor/qor-example/app/models" func initFuncMap() { Admin.RegisterFuncMap("latest_orders", latestOrders) } func latestOrders() (orders []models.Order) { Admin.Config.DB.Order("id desc").Limit(5).Find(&orders) return }
Remove uncessary codes from qor-example
Remove uncessary codes from qor-example
Go
mit
grengojbo/qor-example,qor/qor-example,grengojbo/qor-example,qor/qor-example,qor/qor-example,firestudios/qor-example,grengojbo/qor-example,firestudios/qor-example,firestudios/qor-example
a3c84182c0b36519c89ef0a6233aed44ac5a9e6b
netflow9/dump.go
netflow9/dump.go
package netflow9 import ( "encoding/hex" "fmt" ) func Dump(p *Packet) { fmt.Println("NetFlow version 9 packet") for _, ds := range p.DataFlowSets { fmt.Println(" data set") if ds.Records == nil { fmt.Printf(" %d raw bytes:\n", len(ds.Bytes)) fmt.Println(hex.Dump(ds.Bytes)) continue } fmt.Prin...
package netflow9 import ( "encoding/hex" "fmt" ) func Dump(p *Packet) { fmt.Println("NetFlow version 9 packet") for _, ds := range p.DataFlowSets { fmt.Printf(" data set template %d, length: %d\n", ds.Header.ID, ds.Header.Length) if ds.Records == nil { fmt.Printf(" %d raw bytes:\n", len(ds.Bytes)) f...
Print out headers with packet data
Print out headers with packet data
Go
mit
tehmaze/netflow
fc9c00598b60c6d17d4d16788cda65e062e0b58b
rem.go
rem.go
package main import ( "encoding/json" "log" "net/http" "os" ) const ( version = "0.6.0" ) type App struct { Notification Domain string Path string Port string } func main() { app := new(App) app.Notification = *&Notification{} app.loadConfigurationFile() mux := http.NewServeMux() mux.Handle("/", C...
package main import ( "encoding/json" "log" "net/http" "os" ) const ( version = "0.6.0" ) type App struct { Notification Domain string Path string Port string } func main() { app := new(App) app.Notification = *&Notification{} app.loadConfigurationFile() mux := http.NewServeMux() mux.Handle("/", C...
Move config file to $HOME dir
Move config file to $HOME dir
Go
mit
sdaros/rem,sdaros/rem
c8bbd90dae2ccbb223b4c6d1d3f3a530baa59616
testing/constants.go
testing/constants.go
// Copyright 2012, 2013 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package testing import ( "time" "launchpad.net/juju-core/utils" ) // ShortWait is a reasonable amount of time to block waiting for something that // shouldn't actually happen. (as in, the test suite will *actually* ...
// Copyright 2012, 2013 Canonical Ltd. // Licensed under the AGPLv3, see LICENCE file for details. package testing import ( "time" "launchpad.net/juju-core/utils" ) // ShortWait is a reasonable amount of time to block waiting for something that // shouldn't actually happen. (as in, the test suite will *actually* ...
Add utopic to supported series
Add utopic to supported series
Go
agpl-3.0
reedobrien/store
d5aec0848a30fb6b7526384db9cc04727d69de09
native_darwin.go
native_darwin.go
package glfw3 //#define GLFW_EXPOSE_NATIVE_COCOA //#define GLFW_EXPOSE_NATIVE_NSGL //#include "glfw/include/GLFW/glfw3.h" //#include "glfw/include/GLFW/glfw3native.h" import "C" func (w *Window) GetCocoaWindow() C.id { return C.glfwGetCocoaWindow(w.data) } func (w *Window) GetNSGLContext() C.id { return C.glfwGetN...
package glfw3 //#define GLFW_EXPOSE_NATIVE_COCOA //#define GLFW_EXPOSE_NATIVE_NSGL //#include "glfw/include/GLFW/glfw3.h" //#include "glfw/include/GLFW/glfw3native.h" import "C" // See: https://github.com/go-gl/glfw3/issues/82 /* func (w *Window) GetCocoaWindow() C.id { return C.glfwGetCocoaWindow(w.data) } func (w...
Fix OS X build - lose GetCocoaWindow() and GetNSGLContext().
Fix OS X build - lose GetCocoaWindow() and GetNSGLContext().
Go
bsd-3-clause
azul3d/native-glfw,azul3d/native-glfw
56bfaeda70752ff87e8fac957b4c4bad59c4ef17
timing_test.go
timing_test.go
package gomol import ( "time" . "gopkg.in/check.v1" ) type testClock struct { curTime time.Time } func newTestClock(curTime time.Time) *testClock { return &testClock{curTime: curTime} } func (c *testClock) Now() time.Time { return c.curTime } func (s *GomolSuite) TestTestClockNow(c *C) { realNow := time.Now...
package gomol import ( "time" . "gopkg.in/check.v1" ) type testClock struct { curTime time.Time } func newTestClock(curTime time.Time) *testClock { return &testClock{curTime: curTime} } func (c *testClock) Now() time.Time { return c.curTime } func (s *GomolSuite) TestTestClockNow(c *C) { realNow := time.Now...
Make more red go away
Make more red go away
Go
mit
aphistic/gomol
a155efab14cbe6b7f376668c905dd185e36a0437
examples/pebble_accelerometer.go
examples/pebble_accelerometer.go
package main import ( "fmt" "github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot/api" "github.com/hybridgroup/gobot/platforms/pebble" ) func main() { gbot := gobot.NewGobot() api.NewAPI(gbot).Start() pebbleAdaptor := pebble.NewPebbleAdaptor("pebble") pebbleDriver := pebble.NewPebbleDriver(pebbleAdap...
package main import ( "fmt" "github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot/api" "github.com/hybridgroup/gobot/platforms/pebble" ) func main() { gbot := gobot.NewGobot() a := api.NewAPI(gbot) a.Port = "8080" a.Start() pebbleAdaptor := pebble.NewPebbleAdaptor("pebble") pebbleDriver := pebble.N...
Update example to use default Watchbot http port
Update example to use default Watchbot http port
Go
apache-2.0
nzmichaelh/gobot,nzmichaelh/gobot
4032210a0d0482d6b473fa92bc6fa39346683155
division_test.go
division_test.go
package main import ( "testing" ) func BenchmarkDivisionMod(b *testing.B) { d := NewDivisionMod(1000) // run the dividable check function b.N times for n := 0; n < b.N; n++ { d.IsRestlessDividable(uint64(n)) } } func BenchmarkDivisionPow2(b *testing.B) { d := NewDivisionPow2(1024) // run the dividable check...
package main import ( "testing" ) func BenchmarkDivisionMod(b *testing.B) { d := NewDivisionMod(1024) // run the dividable check function b.N times for n := 0; n < b.N; n++ { d.IsRestlessDividable(uint64(n)) } } func BenchmarkDivisionPow2(b *testing.B) { d := NewDivisionPow2(1024) // run the dividable check...
Change dividend for all benchmark tests to 1024
Change dividend for all benchmark tests to 1024
Go
mit
breml/zeroremainder,breml/zeroremainder
38e08c9a6016d98926ce49a8850d75ddf6663e19
examples/popl17/jobsched/main.go
examples/popl17/jobsched/main.go
package main import ( "fmt" "time" ) func worker(id int, jobQueue <-chan int, done <-chan struct{}) { for { select { case jobID := <-jobQueue: fmt.Println(id, "Executing job", jobID) case <-done: fmt.Println(id, "Quits") return } } } func producer(q chan int, done chan struct{}) { cond := true ...
package main import ( "fmt" "time" ) var i int func worker(id int, jobQueue <-chan int, done <-chan struct{}) { for { select { case jobID := <-jobQueue: fmt.Println(id, "Executing job", jobID) case <-done: fmt.Println(id, "Quits") return } } } func morejob() bool { i++ return i < 20 } func p...
Revert example to paper version
Revert example to paper version
Go
apache-2.0
nickng/dingo-hunter,nickng/dingo-hunter,nickng/dingo-hunter
9cff936277f5779ac06c29ac67ebfb400c0bf100
building/build-debs/homeworld-keyserver/src/keycommon/knc/knc.go
building/build-debs/homeworld-keyserver/src/keycommon/knc/knc.go
package knc import ( "fmt" "os/exec" ) func Request(host string, data []byte) ([]byte, error) { cmd := exec.Command("/usr/bin/knc", fmt.Sprintf("host@%s", host), "20575") stdin, err := cmd.StdinPipe() if err != nil { return nil, err } go func() { defer stdin.Close() stdin.Write(data) }() response, e...
package knc import ( "fmt" "os/exec" "encoding/json" "keycommon/reqtarget" ) type KncServer struct { Hostname string } func (k KncServer) kncRequest(data []byte) ([]byte, error) { cmd := exec.Command("/usr/bin/knc", fmt.Sprintf("host@%s", k.Hostname), "20575") stdin, err := cmd.StdinPipe() if err != nil { ...
Make KncServer a reqtarget implementation
Make KncServer a reqtarget implementation
Go
mit
sipb/homeworld,sipb/homeworld,sipb/homeworld,sipb/homeworld
d3e7c9060a14ac579f899fd01c936319132cbc97
storage/filesystem/internal/dotgit/dotgit_setref_norwfs.go
storage/filesystem/internal/dotgit/dotgit_setref_norwfs.go
// +build norwfs package dotgit import "gopkg.in/src-d/go-git.v4/plumbing" // There are some filesystems tha don't support opening files in RDWD mode. // In these filesystems the standard SetRef function can not be used as i // reads the reference file to check that it's not modified before updating it. // // This v...
// +build norwfs package dotgit import ( "fmt" "gopkg.in/src-d/go-git.v4/plumbing" ) // There are some filesystems that don't support opening files in RDWD mode. // In these filesystems the standard SetRef function can not be used as i // reads the reference file to check that it's not modified before updating it...
Check reference also in norwfs SetRef
Check reference also in norwfs SetRef Signed-off-by: Javi Fontan <bd6f2f0212e303b54f36d84bb19ae60fa8e400a6@gmail.com>
Go
apache-2.0
go-git/go-git,src-d/go-git,src-d/go-git,mcuadros/go-git,mcuadros/go-git,go-git/go-git
6776724d9cb31b9ff6ad959d3167159ec5abebed
app.go
app.go
package gogist import ( "fmt" "net/http" "github.com/gorilla/mux" ) const t = ` <html> <head> <meta name="go-import" content="%s git https://gist.github.com/%s.git" /> <script>window.location='https://github.com/ImJasonH/go-gist/';</script> </head> </html> ` func init() { r := mux.NewRouter() h := ...
package gogist import ( "fmt" "net/http" "github.com/gorilla/mux" ) const t = ` <html> <head> <meta name="go-import" content="%s git https://gist.github.com/%s.git" /> <script>window.location='https://github.com/ImJasonH/go-gist/';</script> </head> </html> ` func init() { r := mux.NewRouter() h := ...
Support new gist ID format
Support new gist ID format
Go
apache-2.0
ImJasonH/go-gist
605ca2cc43ff3ac0971da11ca974738000896fd1
app.go
app.go
package main import ( "fmt" "net" "os" "sync" "time" ) var ( host string // The host address to scan ) func init() { if len(os.Args) != 2 { fmt.Fprintf(os.Stderr, "Usage: %s host\n", os.Args[0]) os.Exit(1) } host = os.Args[1] } func main() { d := net.Dialer{Timeout: 10 * time.Second} p := make(chan b...
package main import ( "fmt" "net" "os" "sync" "time" ) var ( host string // The host address to scan ) func init() { if len(os.Args) != 2 { fmt.Fprintf(os.Stderr, "Usage: %s host\n", os.Args[0]) os.Exit(1) } host = os.Args[1] } func main() { d := net.Dialer{Timeout: 10 * time.Second} p := make(chan s...
Use empty struct as chan element type
Use empty struct as chan element type
Go
mit
redforks/portscan
87ae2b2f43752068e9d644f2dbac5b32af1d7060
devserver/server.go
devserver/server.go
package main import ( "fmt" "io" "net/http" ) type agent struct { name string value int } var agents []*agent var broadcastGroup []chan bool func broadcastTick(cs []chan bool) { for _, c := range cs { c <- true } } func hello(w http.ResponseWriter, r *http.Request) { broadcastTick(broadcastGroup) for _...
package main import ( "fmt" "io" "net/http" ) type agent struct { name string value int } var tick int var agents []*agent var broadcastGroup []chan bool func broadcastTick(cs []chan bool) { for _, c := range cs { c <- true } } func hello(w http.ResponseWriter, r *http.Request) { broadcastTick(broadcast...
Fix tick, prepare for pending contracts
Fix tick, prepare for pending contracts
Go
apache-2.0
sillsm/econix-proto,sillsm/econix-proto
a8a7b56e02a611ebfef846f2b3002c8ffb34397f
main.go
main.go
// +build !appengine package main import ( "github.com/raphael/goa" "github.com/raphael/goa-cellar/app" "github.com/raphael/goa-cellar/controllers" "github.com/raphael/goa-cellar/js" "github.com/raphael/goa-cellar/schema" "github.com/raphael/goa-cellar/swagger" ) func main() { // Create goa service service :...
// +build !appengine package main import ( "github.com/raphael/goa" "github.com/raphael/goa-cellar/app" "github.com/raphael/goa-cellar/controllers" "github.com/raphael/goa-cellar/js" "github.com/raphael/goa-cellar/schema" "github.com/raphael/goa-cellar/swagger" "github.com/raphael/goa-middleware/middleware" ) ...
Update to reflect the move of all goa middlewares to the goa-middleware repo
Update to reflect the move of all goa middlewares to the goa-middleware repo
Go
mit
raphael/goa-cellar,lxgxiong/goa-cellar,goadesign/goa-cellar,goadesign/goa-cellar,raphael/goa-cellar,lxgxiong/goa-cellar,lxgxiong/goa-cellar,goadesign/goa-cellar,raphael/goa-cellar
2bc6be281a56e846895c02ae8921aabf1797199d
silences_test.go
silences_test.go
package main import ( "sort" "testing" "time" "github.com/prometheus/alertmanager/types" "github.com/stretchr/testify/assert" ) func TestByStatus(t *testing.T) { s1 := types.Silence{EndsAt: time.Now().Add(-2 * time.Minute)} s2 := types.Silence{EndsAt: time.Now().Add(-1 * time.Minute)} s3 := types.Silence{End...
package main import ( "testing" "time" "github.com/prometheus/alertmanager/types" "github.com/stretchr/testify/assert" ) func TestResolved(t *testing.T) { s := types.Silence{} assert.False(t, Resolved(s)) s.EndsAt = time.Now().Add(time.Minute) assert.False(t, Resolved(s)) s.EndsAt = time.Now().Add(-1 * ti...
Remove obsolete test for ByStatus slice
Remove obsolete test for ByStatus slice
Go
mit
metalmatze/alertmanager-bot,metalmatze/alertmanager-bot
6de1e967d90ef22c6224e7d47ac6f437f0c18924
server/reverse_proxy.go
server/reverse_proxy.go
package server import ( "github.com/vulcand/oxy/forward" "github.com/vulcand/oxy/roundrobin" "github.com/vulcand/oxy/stream" "github.com/vulcand/oxy/cbreaker" "net/http" "net/url" ) type ReverseProxy struct { stream *stream.Streamer } func NewReverseProxy(backends []string) *ReverseProxy { fwd, _ := forward....
package server import ( "github.com/vulcand/oxy/forward" "github.com/vulcand/oxy/roundrobin" "github.com/vulcand/oxy/buffer" "github.com/vulcand/oxy/cbreaker" "net/http" "net/url" ) type ReverseProxy struct { handler http.Handler } func NewReverseProxy(backends []string) *ReverseProxy { fwd, _ := forward.New...
Rename stream to buffer (oxy stream lib update) + move circuit breaker in the middleware chain
Rename stream to buffer (oxy stream lib update) + move circuit breaker in the middleware chain
Go
mit
xaviergodart/gydro
75db787c87b48022251fc4de4f56cf1c11a9efeb
service/service_test.go
service/service_test.go
package service
package service import ( "reflect" "testing" "github.com/stretchr/testify/assert" ) func TestServiceNameShouldDropPackage(t *testing.T) { nf := &NotFound{} name := Name(nf) assert.Equal(t, "notfound", name) } func TestForNameShouldReturnErrorWhenNoService(t *testing.T) { svc, err := ForName("foo") assert.No...
Add tests for service names
Add tests for service names
Go
mit
hoop33/limo
50f3f315518d56a8eea76c3d120cd275c6b6d41c
util/util.go
util/util.go
package util import ( "math/big" "math/rand" "strconv" "time" "github.com/ethereum/go-ethereum/common" ) var pow256 = common.BigPow(2, 256) func Random() string { min := int64(100000000000000) max := int64(999999999999999) n := rand.Int63n(max-min+1) + min return strconv.FormatInt(n, 10) } func MakeTimest...
package util import ( "math/big" "math/rand" "strconv" "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" ) var pow256 = math.BigPow(2, 256) func Random() string { min := int64(100000000000000) max := int64(999999999999999) n := rand.Int63n(max-min+1) + min retur...
Fix compatibility with go-ethereum/common package
Fix compatibility with go-ethereum/common package
Go
mit
sammy007/ether-proxy,sammy007/ether-proxy,sammy007/ether-proxy,sammy007/ether-proxy
ffa15356101da9e453bd5bbe85421684648841a2
parse.go
parse.go
package sign import ( "crypto/rsa" "crypto/x509" "encoding/pem" "fmt" ) func parsePrivateKey(data []byte) (*rsa.PrivateKey, error) { pemData, err := pemParse(data, "PRIVATE KEY") if err != nil { return nil, err } return x509.ParsePKCS1PrivateKey(pemData) } func parsePublicKey(data []byte) (*rsa.PublicKey,...
package sign import ( "crypto/rsa" "crypto/x509" "encoding/pem" "fmt" ) func parsePrivateKey(data []byte) (*rsa.PrivateKey, error) { pemData, err := pemParse(data, "RSA PRIVATE KEY") if err != nil { return nil, err } return x509.ParsePKCS1PrivateKey(pemData) } func parsePublicKey(data []byte) (*rsa.Public...
Fix pem type for parsing private RSA keys
Fix pem type for parsing private RSA keys
Go
apache-2.0
AaronO/go-rsa-sign
19bb14f1a04668c77bfdb55a8ea064264d11b3f0
src/github.com/getlantern/osversion/cmd/main_android.go
src/github.com/getlantern/osversion/cmd/main_android.go
package main import ( "log" "github.com/getlantern/osversion" "golang.org/x/mobile/app" ) func main() { // checkNetwork runs only once when the app first loads. app.Main(func(a app.App) { str, err := osversion.GetString() if err != nil { log.Println("Error") } log.Println(str) str, err = osversio...
package main import ( "log" "github.com/getlantern/osversion" "golang.org/x/mobile/app" ) func main() { // checkNetwork runs only once when the app first loads. app.Main(func(a app.App) { str, err := osversion.GetString() if err != nil { log.Printf("Error in osversion.GetString: %v", err) } log.Prin...
Use GetSemanticVersion in Android test app
Use GetSemanticVersion in Android test app
Go
apache-2.0
onlynight/lantern,lioonline/lantern,lfckop/lantern,CJstar/lantern,kmingee/lantern,lozybean/lantern,roceys/lantern,Minghi/lantern,jp1017/lantern,ChenZeXian/lantern,zhengnanlee/lantern,dangwy/lantern,todaylover/lantern,wangdongming007/lantern,hhua/lantern,lozybean/lantern,ykelvis/lantern,zmcadam/lantern,webwlsong/lantern...
7d555b034c53c439c63b358e30188b9afa4102af
scoring/entry.go
scoring/entry.go
package scoring // An entry represents a path and a score. type Entry struct { Path string Score *Score } // Update the score for an entry. func (e *Entry) UpdateScore() { e.Score.Update() } // Calculates the score for an entry. func (e *Entry) CalculateScore() float64 { return e.Score.Calculate() } // Create ...
package scoring import "fmt" // An entry represents a path and a score. type Entry struct { Path string Score *Score } // Update the score for an entry. func (e *Entry) UpdateScore() { e.Score.Update() } // Calculates the score for an entry. func (e *Entry) CalculateScore() float64 { return e.Score.Calculate()...
Add a Entry.String method for debugging
Add a Entry.String method for debugging println ftw.
Go
mit
gsamokovarov/jump
49ceda1c9bfbb55a46ab1570d749622e1af09cc8
pacicli.go
pacicli.go
package main import ( "os" "github.com/codegangsta/cli" "github.com/tsukaeru/pacicli/command" ) func main() { app := cli.NewApp() app.Name = "pacicli" app.Version = Version app.Usage = "Command line interface for Parallels Cloud Infrastructure" app.Commands = command.Commands app.EnableBashCompletion = true...
package main import ( "os" "runtime" "github.com/codegangsta/cli" "github.com/tsukaeru/pacicli/command" ) var ( commitHash string buildDate string ) func main() { app := cli.NewApp() app.Name = "pacicli" app.Version = Version + "\nGo version: " + runtime.Version() if len(commitHash) > 0 { app.Version +...
Add values to be able to embed commit hash and build date in the command
Add values to be able to embed commit hash and build date in the command
Go
mit
tsukaeru/pacicli,tsukaeru/pacicli
5f7e1109e86393fb2ac702d0736c0f53d6e81428
aliveim_test.go
aliveim_test.go
package main import ( "bytes" "io" "testing" ) type nopCloser struct { io.Reader } func (nopCloser) Close() error { return nil } func TestParseAlivePost(t *testing.T) { var body io.ReadCloser = nopCloser{bytes.NewBufferString(`{"device_id": "abc123", "timeout": 300}`)} var ar AliveRequest = parseAlivePost(bod...
package main import ( "io" "strings" "testing" ) type nopCloser struct { io.Reader } func (nopCloser) Close() error { return nil } func TestParseAlivePost(t *testing.T) { var body io.ReadCloser = nopCloser{strings.NewReader(`{"device_id": "abc123", "timeout": 300}`)} var ar AliveRequest = parseAlivePost(body)...
Use a strings.NewReader instead of bytes.NewBufferString
Use a strings.NewReader instead of bytes.NewBufferString
Go
mit
aliveim/aliveim-service
c51725b04603d8fbfa6e3a702fbd526812b81b79
detector/task_test.go
detector/task_test.go
package detector import ( "testing" "time" "gopkg.in/mgo.v2/bson" "github.com/stretchr/testify/assert" ) func TestTask(t *testing.T) { assert := assert.New(t) StopCronNow() StartCron() err := TaskMgr.DeleteAll() assert.Nil(err) task := &Task{ ID: bson.NewObjectId(), Name: "TestTask"...
package detector import ( "testing" "time" "gopkg.in/mgo.v2/bson" "github.com/stretchr/testify/assert" ) func TestTask(t *testing.T) { assert := assert.New(t) StopCronNow() StartCron() err := TaskMgr.DeleteAll() assert.Nil(err) task := &Task{ ID: bson.NewObjectId(), Name: "TestTask"...
Update detector task unit test
Update detector task unit test
Go
mit
miclle/observer,miclle/observer,miclle/observer
af252ecb763388dc9ca4f45c8572cafe17fda9f1
lxc/file_unix.go
lxc/file_unix.go
// +build !windows package main import ( "os" "path/filepath" "syscall" ) func (c *fileCmd) getOwner(f *os.File) (os.FileMode, int, int, error) { fInfo, err := f.Stat() if err != nil { return os.FileMode(0), -1, -1, err } mode := fInfo.Mode() uid := int(fInfo.Sys().(*syscall.Stat_t).Uid) gid := int(fInfo...
// +build !windows package main import ( "os" "syscall" ) func (c *fileCmd) getOwner(f *os.File) (os.FileMode, int, int, error) { fInfo, err := f.Stat() if err != nil { return os.FileMode(0), -1, -1, err } mode := fInfo.Mode() uid := int(fInfo.Sys().(*syscall.Stat_t).Uid) gid := int(fInfo.Sys().(*syscall....
Fix imported and not used
Fix imported and not used Signed-off-by: anatoly techtonik <657222fa4408d5fb9c49497617f580f8c5974a3b@gmail.com>
Go
apache-2.0
atxwebs/lxd,atxwebs/lxd,chrisglass/lxd,erikmack/lxd,lxc/lxd,stgraber/lxd,georghopp/lxd,jsavikko/lxd,hallyn/lxd,chrisglass/lxd,techtonik/lxd,hallyn/lxd,lxc/lxd,pcdummy/lxd,georghopp/lxd,stgraber/lxd,lxc/lxd,jsavikko/lxd,Skarlso/lxd,akshaykarle/lxd,mjeanson/lxd,lxc/lxd,Skarlso/lxd,hallyn/lxd,akshaykarle/lxd,lxc/lxd,techt...
c84011efd6380a48d0b70dd5caa3db2632d69561
slacker.go
slacker.go
package slacker import ( "bytes" "encoding/json" "net/http" ) type Slacker struct { URL string Icon string Username string } type payload struct { text string `json:"text"` icon string `json:"icon_url"` username string `json:"username"` } func (s *Slacker) Send(text string) error { paylo...
package slacker import ( "bytes" "encoding/json" "errors" "net/http" ) type Slacker struct { URL string Icon string Username string } type payload struct { Text string `json:"text"` Icon string `json:"icon_url"` Username string `json:"username"` } func (s *Slacker) Send(text string) error...
Make payload contents public, so that they can be serialized
Make payload contents public, so that they can be serialized
Go
mit
stayradiated/slacker
df2e9c9b3cb816a0166e8d1c85271e3f6d40a291
install.go
install.go
package main import ( "archive/zip" "bytes" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/lambda" ) var runtimeFunction = ` exports.handler = function(event, context) { eval(event.source); }; ` func install(role string, region string) { svc := lambda.New(&aws.Config{Region: region}) par...
package main import ( "archive/zip" "bytes" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/lambda" ) var runtimeFunction = ` exports.handler = function(event, context) { eval(event.source); }; ` func install(role string, region string) { svc := lambda.New(&aws.Config{Region: region}) if ...
Check if function exists before adding
Check if function exists before adding
Go
mit
mthenw/weblambda
556cdaabd00d090e47ea3092b46fb8d41ef65478
util/log_util.go
util/log_util.go
// Copyright 2017 The casbin Authors. 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 a...
// Copyright 2017 The casbin Authors. 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 a...
Fix the missing ... in LogPrint().
Fix the missing ... in LogPrint().
Go
apache-2.0
faceless-saint/casbin,casbin/casbin,hsluoyz/casbin
c8ac58d9c63790c18ed4eae1a12c3982d006024c
ptypes/parity.go
ptypes/parity.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 import "math" // parityTable is a parity cache for all 16-bit non-negative integers. var parityTable = initParityTable() // initParityT...
// 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 // parityTable is a parity cache for all 16-bit non-negative integers. var parityTable = initParityTable() // initParityTable computes a...
Remove the dependency on math package in ptable.Parity
Remove the dependency on math package in ptable.Parity
Go
mit
mrekucci/epi,mrekucci/epi
9b75d611517bbfc21c47428bb032ee9b4ff5b098
pkg/asset/images.go
pkg/asset/images.go
package asset // DefaultImages are the defualt images bootkube components use. var DefaultImages = ImageVersions{ Etcd: "quay.io/coreos/etcd:v3.1.8", Flannel: "quay.io/coreos/flannel:v0.10.0-amd64", FlannelCNI: "quay.io/coreos/flannel-cni:v0.3.0", Calico: "quay.io/calico/node:v3.0....
package asset // DefaultImages are the defualt images bootkube components use. var DefaultImages = ImageVersions{ Etcd: "quay.io/coreos/etcd:v3.1.8", Flannel: "quay.io/coreos/flannel:v0.10.0-amd64", FlannelCNI: "quay.io/coreos/flannel-cni:v0.3.0", Calico: "quay.io/calico/node:v3.0....
Update pod-checkpointer image to try secureClient first
Update pod-checkpointer image to try secureClient first * https://github.com/kubernetes-incubator/bootkube/pull/1027
Go
apache-2.0
kubernetes-incubator/bootkube,kubernetes-incubator/bootkube,kubernetes-incubator/bootkube
646b91a408e95c73466ea946aed893987542b30e
timber_loggly_writer.go
timber_loggly_writer.go
package gop import ( "fmt" "os" "github.com/segmentio/go-loggly" ) // A timber.LogWriter for the loggly service. // LogglyWriter is a Timber writer to send logging to the loggly // service. See: https://loggly.com. type LogglyWriter struct { c *loggly.Client } // NewLogEntriesWriter creates a new writer for se...
package gop import ( "fmt" "os" "github.com/cocoonlife/go-loggly" ) // A timber.LogWriter for the loggly service. // LogglyWriter is a Timber writer to send logging to the loggly // service. See: https://loggly.com. type LogglyWriter struct { c *loggly.Client } // NewLogEntriesWriter creates a new writer for s...
Fix goroutine leak when replacing LogglyWriter instance
LogglyWriter: Fix goroutine leak when replacing LogglyWriter instance Each config update (after the first setting) of "gop"/"loggly_logging_token" was leaking a goro.
Go
bsd-3-clause
cocoonlife/gop
832ab4bf90134d6cdbba149055ad7441355f1c85
request.go
request.go
package main import ( "fmt" "net/http" "regexp" "strings" ) type Request struct { Filename string Content string Command string Image string Format string } var FilenameRegexp = regexp.MustCompile(`\A([a-z\d\-\_]+)\.[a-z]{1,6}\z`) func normalizeString(val string) string { return strings.ToLower(str...
package main import ( "fmt" "net/http" "regexp" "strings" ) type Request struct { Filename string Content string Command string Image string Format string } var FilenameRegexp = regexp.MustCompile(`\A([a-z\d\-\_]+)\.[a-z]{1,6}\z`) func normalizeString(val string) string { return strings.ToLower(str...
Add ability to override image
Add ability to override image
Go
mit
bitrun/api,sosedoff/bitrun-api
6149daf3f4d11335bd9aed9c7d9afd39765a0f51
probers/systime/register.go
probers/systime/register.go
package systime import ( "github.com/Symantec/tricorder/go/tricorder" "github.com/Symantec/tricorder/go/tricorder/units" ) func register(dir *tricorder.DirectorySpec) *prober { p := new(prober) p.dir = dir // TODO(rgooch): Consider dividing this by the number of CPUs before // exporting. //if err...
package systime import ( "github.com/Symantec/tricorder/go/tricorder" "github.com/Symantec/tricorder/go/tricorder/units" ) func register(dir *tricorder.DirectorySpec) *prober { p := new(prober) p.dir = dir // TODO(rgooch): Consider dividing this by the number of CPUs before // exporting. //if err...
Switch to unit None for time metric.
Switch to unit None for time metric.
Go
apache-2.0
rgooch/health-agent,Symantec/health-agent,rgooch/health-agent,Symantec/health-agent
e83eec9479533c5d32f6717f5e2074d5c5933323
testing/unit/subject.go
testing/unit/subject.go
package unit type Subject struct { assert *Assertion name string } func NewSubject(assert *Assertion) *Subject { return &Subject{ assert: assert, name: "", } } func (subject *Subject) FailWithMessage(message string) { subject.assert.t.Error(message) } func (subject *Subject) Named(name string) { subje...
package unit import ( "bytes" "fmt" "runtime" "strings" ) type Subject struct { assert *Assertion name string } func NewSubject(assert *Assertion) *Subject { return &Subject{ assert: assert, name: "", } } // decorate prefixes the string with the file and line of the call site // and inserts the fina...
Print out the correct point of error
Print out the correct point of error
Go
mit
evolsnow/v2ray-core,simpleman1984/v2ray-core,LiuWenJu/v2ray-core,evolsnow/v2ray-core,takeshineshiro/v2ray-core,faint32/v2ray-core,chuangWu/v2ray-core,ghmajx/v2ray-core,Amonhuz/v2ray-core,panzer13/v2ray-core,simpleman1984/v2ray-core,takeshineshiro/v2ray-core,Amonhuz/v2ray-core,jessxuan/v2ray-core,simpleman1984/v2ray-cor...
b021354d91e896398c119da671be12f5720338a1
services/profile_service.go
services/profile_service.go
package services import ( "database/sql" "encoding/json" "log" "cjdavis.me/elysium/db" "cjdavis.me/elysium/models" ) type IProfileService interface { GetProfile() *models.Profile } type ProfileService struct { } func NewProfileService() *ProfileService { return &ProfileService{} } func (s *ProfileService) ...
package services import ( "log" "cjdavis.me/elysium/models" "cjdavis.me/elysium/repositories" ) type IProfileService interface { GetProfile() *models.Profile } type ProfileService struct { } func NewProfileService() *ProfileService { return &ProfileService{} } func (s *ProfileService) GetProfile() *models.Pr...
Call the profile repository from the profile service
Call the profile repository from the profile service
Go
mit
Crevax/Elysium
6938b44bb96b0f0c057aafb1cc81c159fc8def48
frontend/main.go
frontend/main.go
package main import ( "github.com/grsakea/kappastat/backend" ) func main() { launchBackend() launchFrontend() } func launchBackend() *backend.Controller { c := backend.SetupController("twitch") go c.Loop() return c }
package main func main() { launchFrontend() }
Remove launch backend from frontend
Remove launch backend from frontend
Go
mit
grsakea/kappastat,grsakea/kappastat,grsakea/kappastat
ad2cb5bec94bb544332d9c4feae4a90749a31404
cairo/fontoptions_since_1_16.go
cairo/fontoptions_since_1_16.go
// +build !pango_1_10,!pango_1_12,!pango_1_14 package cairo // #include <stdlib.h> // #include <cairo.h> // #include <cairo-gobject.h> import "C" import ( "unsafe" ) // GetVariations is a wrapper around cairo_font_options_get_variations(). func (o *FontOptions) GetVariations() string { return C.GoString(C.cairo_fo...
// +build !cairo_1_10,!cairo_1_12,!cairo_1_14 package cairo // #include <stdlib.h> // #include <cairo.h> // #include <cairo-gobject.h> import "C" import ( "unsafe" ) // GetVariations is a wrapper around cairo_font_options_get_variations(). func (o *FontOptions) GetVariations() string { return C.GoString(C.cairo_fo...
Build constraints for cairo packages should be based on cairo-naming, not use pango-naming.
Build constraints for cairo packages should be based on cairo-naming, not use pango-naming.
Go
isc
gotk3/gotk3,gotk3/gotk3
27892f4de804fb5a49c08e20ebff8074d1b56281
slack/id.go
slack/id.go
package slack import ( "crypto/sha256" "encoding/hex" ) type UserID struct { UserID string TeamID string } type SecureID struct { HashSum string } /* Notice that user IDs are not guaranteed to be globally unique across all Slack users. The combination of user ID and team ID, on the other hand, is guaranteed to...
package slack import ( "crypto/sha256" "encoding/hex" ) type UserID struct { UserID string TeamID string } type SecureID struct { HashSum string } /* Notice that user IDs are not guaranteed to be globally unique across all Slack users. The combination of user ID and team ID, on the other hand, is guaranteed to...
Change method receiver to pointer
Change method receiver to pointer This is done to avoid an unnecessary copy for this read-only operation.
Go
mit
kayex/sirius
69269e6470f0bf9bcd78770fea6b6c99945fd32f
go/phone-number/phone_number.go
go/phone-number/phone_number.go
package phonenumber import ( "fmt" "strings" "unicode" ) func Number(phoneNumber string) (number string, e error) { for _, character := range phoneNumber { if unicode.IsDigit(character) { number += string(character) } } if len(number) == 11 && number[0] == '1' { // trim leading 1 number = number[1:] ...
package phonenumber import ( "fmt" "strings" "unicode" ) func Number(phoneNumber string) (number string, e error) { for _, character := range phoneNumber { if unicode.IsDigit(character) { number += string(character) } } if len(number) == 11 && number[0] == '1' { // trim leading 1 number = number[1:] ...
Throw error if exchange code starts with 0 or 1
Throw error if exchange code starts with 0 or 1
Go
mit
rootulp/exercism,rootulp/exercism,rootulp/exercism,rootulp/exercism,rootulp/exercism,rootulp/exercism,rootulp/exercism,rootulp/exercism
f27a30eaf599d08d681ddccab89e88ec8ad97a9d
challenge32.go
challenge32.go
// Challenge 31 - Implement and break HMAC-SHA1 with an artificial timing leak // http://cryptopals.com/sets/4/challenges/31 package cryptopals import ( "crypto/sha1" "net/http" "time" ) type challenge32 struct { } func (challenge32) ForgeHmacSHA1SignaturePrecise(addr, file string) []byte { sig := make([]byte, ...
// Challenge 32 - Break HMAC-SHA1 with a slightly less artificial timing leak // http://cryptopals.com/sets/4/challenges/32 package cryptopals import ( "crypto/sha1" "net/http" "time" ) type challenge32 struct { } func (challenge32) ForgeHmacSHA1SignaturePrecise(addr, file string) []byte { sig := make([]byte, s...
Update file header with proper challenge name and link
Update file header with proper challenge name and link
Go
mit
Metalnem/cryptopals-go,Metalnem/cryptopals-go,Metalnem/cryptopals-go
2d5303d4031281c215b115d7609fa087912833a8
arrays/strings.go
arrays/strings.go
package arrays // Strings allows us to limit our filter to just arrays of strings type Strings struct{} // Filter filters an array of strings. func (s Strings) Filter(in []string, keep func(item string) bool) []string { var out []string for _, item := range in { if keep(item) { out = append(out, item) } } ...
package arrays // Strings allows us to limit our filter to just arrays of strings type strings struct{} // Strings allows easy access to the functions that operate on a list of strings var Strings strings // Filter filters an array of strings. func (s strings) Filter(in []string, keep func(item string) bool) []strin...
Add Remove and refactor to allow for multiple types and easy access.
Add Remove and refactor to allow for multiple types and easy access.
Go
mit
materials-commons/gohandy,materials-commons/gohandy
c7a893b976b4b8a17f378bccff03473a31f79b33
static_files/main.go
static_files/main.go
package main import ( "github.com/kataras/go-template/html" "gopkg.in/kataras/iris.v6" ) type page struct { Title string } func main() { iris.UseTemplate(html.New()).Directory("./templates/web/default", ".html") iris.OnError(iris.StatusForbidden, func(ctx *iris.Context) { ctx.HTML(iris.StatusForbidden, "<h1> ...
package main import ( "gopkg.in/kataras/iris.v6" "gopkg.in/kataras/iris.v6/adaptors/httprouter" "gopkg.in/kataras/iris.v6/adaptors/view" ) type page struct { Title string } func main() { app := iris.New() app.Adapt( iris.DevLogger(), httprouter.New(), view.HTML("./templates", ".html"), ) app.OnError(...
Update static files example for v6
Update static files example for v6
Go
mit
iris-contrib/examples,iris-contrib/examples,iris-contrib/examples,iris-contrib/examples
457e2e76263206369c7c60dbcf3461e70b253f92
util/fullnames_windows_test.go
util/fullnames_windows_test.go
package util import ( "os/exec" "sort" "strings" "syscall" ) func ls(dir string) []string { cmd := exec.Command("cmd") cmd.SysProcAttr = &syscall.SysProcAttr{ CmdLine: "cmd /C dir /A /B " + dir, } output, err := cmd.Output() mustOK(err) names := strings.Split(strings.Trim(string(output), "\r\n"), "\r\n") ...
package util import ( "os/exec" "sort" "strings" "syscall" ) func ls(dir string) []string { cmd := exec.Command("cmd") cmd.SysProcAttr = &syscall.SysProcAttr{ CmdLine: "cmd /C dir /A /B " + dir, } output, err := cmd.Output() mustOK(err) names := strings.Split(strings.Trim(string(output), "\r\n"), "\r\n") ...
Make test pass on Windows.
util: Make test pass on Windows.
Go
bsd-2-clause
elves/elvish,elves/elvish,elves/elvish,elves/elvish,elves/elvish
a6ac84b7c8d5c2de2d5f2dc735503f07325ce9c1
cli/proxy.go
cli/proxy.go
package cli import ( "os" "os/signal" "syscall" "github.com/99designs/aws-vault/v6/server" "github.com/alecthomas/kingpin" ) func ConfigureProxyCommand(app *kingpin.Application, a *AwsVault) { stop := false cmd := app.Command("proxy", "Start a proxy for the ec2 instance role server locally"). Alias("server...
package cli import ( "os" "os/signal" "syscall" "github.com/99designs/aws-vault/v6/server" "github.com/alecthomas/kingpin" ) func ConfigureProxyCommand(app *kingpin.Application, a *AwsVault) { stop := false cmd := app.Command("proxy", "Start a proxy for the ec2 instance role server locally"). Alias("server...
Use buffered channel for signals to fix go vet
Use buffered channel for signals to fix go vet
Go
mit
99designs/aws-vault,99designs/aws-vault
18fae267b278520a502e1abcf8c6607ddb5a7f88
go/libkb/secret_store_win_linux.go
go/libkb/secret_store_win_linux.go
// Copyright 2015 Keybase, Inc. All rights reserved. Use of // this source code is governed by the included BSD license. // +build !darwin,!android package libkb func NewSecretStoreAll(g *GlobalContext) SecretStoreAll { return NewSecretStoreFile(g.Env.GetDataDir()) }
// Copyright 2015 Keybase, Inc. All rights reserved. Use of // this source code is governed by the included BSD license. // +build !darwin,!android package libkb import "os" func NewSecretStoreAll(g *GlobalContext) SecretStoreAll { // In order to not break production build releases, only // use the SecretStoreFil...
Add env flag to enable SecretStoreFile
Add env flag to enable SecretStoreFile
Go
bsd-3-clause
keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client
c71c0e10844ee5ea90099ff70c3fea88b3f3e56b
checkers/point.go
checkers/point.go
package checkers import ( "fmt" "math" ) type Point struct { X, Y int } func (p Point) Add(q Point) Point { return Point{p.X + q.X, p.Y + q.Y} } func (p Point) Sub(q Point) Point { return Point{p.X - q.X, p.Y - q.Y} } func (p Point) Equal(q Point) bool { if p.X == q.X && p.Y == q.Y { return true } return...
package checkers import ( "fmt" "math" ) type Point struct { X, Y int } func (p Point) Add(q Point) Point { return Point{p.X + q.X, p.Y + q.Y} } func (p Point) Sub(q Point) Point { return Point{p.X - q.X, p.Y - q.Y} } func (p Point) Equal(q Point) bool { return p.X == q.X && p.Y == q.Y } func (p Point) Less...
Refactor equality function and add less function
Refactor equality function and add less function
Go
apache-2.0
cl0ne/go-checkers
da55c7425a73afbf60bb5d6bb7592d7f14a35332
sigctx/sigctx.go
sigctx/sigctx.go
package sigctx import ( "context" "os" "os/signal" "sync" "syscall" "github.com/SentimensRG/ctx" ) var ( c ctx.C once sync.Once ) // New signal-bound ctx.C that terminates when either SIGINT or SIGTERM // is caught. func New() ctx.C { once.Do(func() { dc := make(chan struct{}) c = dc ch := make(c...
package sigctx import ( "os" "os/signal" "sync" "syscall" "github.com/SentimensRG/ctx" ) var ( c ctx.C once sync.Once ) // New signal-bound ctx.C that terminates when either SIGINT or SIGTERM // is caught. func New() ctx.C { once.Do(func() { dc := make(chan struct{}) c = dc ch := make(chan os.Sign...
Remove functions that work on context.Context. Users should use ctx.AsContext
Remove functions that work on context.Context. Users should use ctx.AsContext
Go
mit
SentimensRG/ctx
dd8265b042b9a9194eb792bdb1611f0096c05b62
docker/client.go
docker/client.go
package docker import ( "time" dockerClient "github.com/fsouza/go-dockerclient" "github.com/rancherio/os/config" ) const ( MAX_WAIT = 30000 INTERVAL = 100 ) func NewClient(cfg *config.Config) (*dockerClient.Client, error) { client, err := dockerClient.NewClient(cfg.DockerEndpoint) if err != nil { return ni...
package docker import ( "time" dockerClient "github.com/fsouza/go-dockerclient" "github.com/rancherio/os/config" ) const ( MAX_WAIT = 30000 INTERVAL = 100 ) func NewClient(cfg *config.Config) (*dockerClient.Client, error) { endpoint := "unix:///var/run/docker.sock" if cfg != nil { endpoint = cfg.DockerEndp...
Support nil cfg for NewClient
Support nil cfg for NewClient
Go
apache-2.0
juliengk/os,datawolf/os,OnePaaS/os,datawolf/os,rancherio/os,hairyhenderson/rancheros,OnePaaS/os,gizmotronic/os,SvenDowideit/os,cloudnautique/os,cloudnautique/os,hairyhenderson/rancheros,SvenDowideit/os,gizmotronic/os,arnononline/os,hairyhenderson/rancheros,arnononline/os,duguhaotian/os,rancherio/os,luxas/os,duguhaotian...
49d34b6bf391b6879cf17ad2a6c7ef057a3f60b8
svnwatch/command.go
svnwatch/command.go
package svnwatch import ( "encoding/xml" "fmt" "os" "os/exec" shellwords "github.com/mattn/go-shellwords" "github.com/pkg/errors" ) type Command struct { XMLName xml.Name `xml:"command"` Command string `xml:",chardata"` } func (c Command) Execute(repo Repository) error { pieces, err := shellwords.Parse(c...
package svnwatch import ( "encoding/xml" "fmt" "os" "os/exec" "strconv" shellwords "github.com/mattn/go-shellwords" "github.com/pkg/errors" ) type Command struct { XMLName xml.Name `xml:"command"` ArgumentType *string `xml:"pass-type,attr,omitempty"` Command string `xml:",chardata"` } func (c...
Allow repository information to be passed as arguments
Allow repository information to be passed as arguments
Go
agpl-3.0
jackwilsdon/svnwatch
e0b2031760b8420e0b9b912870891981fa3e31a0
heartbeat.go
heartbeat.go
package main import ( log "github.com/sirupsen/logrus" "github.com/urfave/cli" "time" ) func RunPeriodically(c *cli.Context) error { log.SetFormatter(_makeFormatter(c.String("format"))) log.WithFields(log.Fields{ "appName": c.App.Name, }).Info("Running periodically") period := time.Duration(c.Int("period"...
package main import ( log "github.com/sirupsen/logrus" "github.com/urfave/cli" "time" ) func RunPeriodically(c *cli.Context) error { log.SetFormatter(_makeFormatter(c.String("format"))) log.WithFields(log.Fields{ "appName": c.App.Name, }).Info("Running periodically") period := time.Duration(c.Int("period"...
Remove unreachable code per `go vet`
Remove unreachable code per `go vet`
Go
apache-2.0
qualimente/heartbeat
3e0bf925f86b00256549597a85216ff6c9faba18
cmd/influxd/run/command_test.go
cmd/influxd/run/command_test.go
package run_test import ( "io/ioutil" "os" "path/filepath" "testing" "time" "github.com/influxdata/influxdb/cmd/influxd/run" ) func TestCommand_PIDFile(t *testing.T) { tmpdir, err := ioutil.TempDir(os.TempDir(), "influxd-test") if err != nil { t.Fatal(err) } defer os.RemoveAll(tmpdir) pidFile := filepa...
package run_test import ( "io/ioutil" "os" "path/filepath" "testing" "time" "github.com/influxdata/influxdb/cmd/influxd/run" ) func TestCommand_PIDFile(t *testing.T) { tmpdir, err := ioutil.TempDir(os.TempDir(), "influxd-test") if err != nil { t.Fatal(err) } defer os.RemoveAll(tmpdir) pidFile := filepa...
Use random port in PID file test
Use random port in PID file test
Go
mit
vladlopes/influxdb,li-ang/influxdb,benbjohnson/influxdb,influxdb/influxdb,linearb/influxdb,influxdb/influxdb,influxdata/influxdb,influxdata/influxdb,nooproblem/influxdb,mark-rushakoff/influxdb,nooproblem/influxdb,influxdb/influxdb,mark-rushakoff/influxdb,benbjohnson/influxdb,benbjohnson/influxdb,mark-rushakoff/influxdb...
4a9e5b8400456fdb397ec1e737c47ca3d861d804
streaming/main.go
streaming/main.go
package main import ( "fmt" "github.com/ant0ine/go-json-rest/rest" "log" "net/http" "time" ) func main() { router, err := rest.MakeRouter( &rest.Route{"GET", "/stream", StreamThings}, ) if err != nil { log.Fatal(err) } api := rest.NewApi(router) api.Use(&rest.AccessLogApacheMiddleware{}) api.Use(&re...
package main import ( "fmt" "github.com/ant0ine/go-json-rest/rest" "log" "net/http" "time" ) func main() { router, err := rest.MakeRouter( &rest.Route{"GET", "/stream", StreamThings}, ) if err != nil { log.Fatal(err) } api := rest.NewApi(router) api.Use(&rest.AccessLogApacheMiddleware{}) api.Use(rest...
Make use of the common stack
Make use of the common stack
Go
mit
jacobxk/go-json-rest-examples,ant0ine/go-json-rest-examples,snowsnail/go-json-rest-examples
cae5a121a9f49ecda04fea1797a48a5774380e5e
types/types.go
types/types.go
package types // ContainerCreateResponse contains the information returned to a client on the // creation of a new container. type ContainerCreateResponse struct { // ID is the ID of the created container. ID string `json:"Id"` // Warnings are any warnings encountered during the creation of the container. Warning...
package types // ContainerCreateResponse contains the information returned to a client on the // creation of a new container. type ContainerCreateResponse struct { // ID is the ID of the created container. ID string `json:"Id"` // Warnings are any warnings encountered during the creation of the container. Warning...
Use ContainerCommitResponse struct for Commit cmd
Use ContainerCommitResponse struct for Commit cmd Signed-off-by: Jamie Hannaford <c9546c123e0c53bfdcf5b9c232ec97637bb6aa8f@rackspace.com>
Go
apache-2.0
jwhonce/engine-api,mikedougherty/engine-api,msabansal/engine-api,rhatdan/engine-api,vdemeester/engine-api,thaJeztah/engine-api,docker/engine-api
ce830bb82e53fac191204c9027159a8179cea253
response_test.go
response_test.go
package search import "testing" func TestSubset(t *testing.T) { var ( a = &Asset{ VideoID: "video-id-123", Type: "movie", } s = &Series{ BrandID: "brand-id-345", Type: "series", } ) t.Run("Asset", func(t *testing.T) { sub := Hit(a).Subset() if got, want := sub.ID, a.VideoID; got !=...
package search import "testing" func TestSubset(t *testing.T) { t.Run("Asset", func(t *testing.T) { a := &Asset{ VideoID: "video-id-123", Type: "movie", } sub := Hit(a).Subset() if got, want := sub.ID, a.VideoID; got != want { t.Fatalf("sub.ID = %q, want %q", got, want) } if got, want := s...
Move test data into the scope where it is used
Move test data into the scope where it is used
Go
mit
TV4/search-go
7bc14ca50665ba407c83c9ee7552ce58efc5b411
metastore/metastore.go
metastore/metastore.go
package metastore import "github.com/deejross/dep-registry/models" // MetaStore represents a metadata store. type MetaStore interface { // AddUpdateImport adds or updates an Import. AddUpdateImport(m *models.Import) error // AddVersion adds a Version to an import. AddVersion(v *models.Version) error // GetImpo...
package metastore import "github.com/deejross/dep-registry/models" // MetaStore represents a metadata store. type MetaStore interface { // AddUpdateImport adds an Import if it doesn't exist. AddImportIfNotExists(m *models.Import) error // UpdateImport updates an import. UpdateImport(m *models.Import) error // ...
Split Add and Update in Import interface
Split Add and Update in Import interface
Go
apache-2.0
deejross/dep-registry
1dcf7b931c04a4eb0eb885abb4972d37769b1cef
internal/config/apparmor/apparmor_test.go
internal/config/apparmor/apparmor_test.go
package apparmor_test import ( "github.com/cri-o/cri-o/internal/config/apparmor" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) // The actual test suite var _ = t.Describe("Config", func() { var sut *apparmor.Config BeforeEach(func() { sut = apparmor.New() Expect(sut).NotTo(BeNil()) if !sut.IsEn...
package apparmor_test import ( "github.com/cri-o/cri-o/internal/config/apparmor" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) // The actual test suite var _ = t.Describe("Config", func() { var sut *apparmor.Config BeforeEach(func() { sut = apparmor.New() Expect(sut).NotTo(BeNil()) if !sut.IsEn...
Fix typo in apparmor tests
Fix typo in apparmor tests Signed-off-by: Ralf Haferkamp <6972bdd7dec75710593d62d13eab0eaf0ce26d83@suse.com>
Go
apache-2.0
kubernetes-incubator/cri-o,mikebrow/cri-o,kubernetes-incubator/cri-o,kubernetes-incubator/ocid,mikebrow/cri-o,kubernetes-incubator/cri-o,mikebrow/cri-o,nalind/cri-o,kubernetes-incubator/ocid,kubernetes-incubator/cri-o,mikebrow/cri-o,nalind/cri-o,kubernetes-incubator/ocid,nalind/cri-o
aa1a35bbb0473dd3c966773485b7e744434d7d16
loginlink.go
loginlink.go
package stripe import "encoding/json" // LoginLinkParams is the set of parameters that can be used when creating a login_link. // For more details see https://stripe.com/docs/api#create_login_link. type LoginLinkParams struct { Params Account string } // LoginLink is the resource representing a login link for Expr...
package stripe import "encoding/json" // LoginLinkParams is the set of parameters that can be used when creating a login_link. // For more details see https://stripe.com/docs/api#create_login_link. type LoginLinkParams struct { Params Account string } // LoginLink is the resource representing a login link for Expr...
Call go fmt to fix the build
Call go fmt to fix the build
Go
mit
ChannelMeter/stripe-go,froatsnook/stripe-go,stripe/stripe-go,ChannelMeter/stripe-go,froatsnook/stripe-go,stripe/stripe-go
1934353e8b5b987ef23c9de2c918d88da8fbe9cc
util.go
util.go
package main // Copyright (c) 2016, crasm <crasm@vczf.io> // This code is open source under the ISC license. See LICENSE for details. import "os" const DefaultPerm = 0644 // True if at most one is true. All can be false. func isMutuallyExclusive(bools ...bool) bool { found := 0 for _, b := range bools { if b { ...
package main // Copyright (c) 2016, crasm <crasm@vczf.io> // This code is open source under the ISC license. See LICENSE for details. import "os" const DefaultPerm = 0644 // True if at most one is true. All can be false. func isMutuallyExclusive(bools ...bool) bool { found := 0 for _, b := range bools { if b { ...
Fix comment to reflect not depending on opt.Force
Fix comment to reflect not depending on opt.Force
Go
isc
crasm/shield
d59db52f0690cb725a0a53da0cba8de50c665293
helper/resource/wait.go
helper/resource/wait.go
package resource import ( "time" ) // RetryFunc is the function retried until it succeeds. type RetryFunc func() error // Retry is a basic wrapper around StateChangeConf that will just retry // a function until it no longer returns an error. func Retry(timeout time.Duration, f RetryFunc) error { var err error c :...
package resource import ( "time" ) // RetryFunc is the function retried until it succeeds. type RetryFunc func() error // Retry is a basic wrapper around StateChangeConf that will just retry // a function until it no longer returns an error. func Retry(timeout time.Duration, f RetryFunc) error { c := &StateChangeC...
Fix data race in resource.Retry
helper/resource: Fix data race in resource.Retry The implementation was attempting to capture the error using a scoped variable reference, but the error value is already exposed via the return value of `WaitForState()`. Using that instead fixes the data race. Fixes the following data race: ``` ================== WAR...
Go
mpl-2.0
Boran/terraform,fromonesrc/terraform,jamtur01/terraform,dabdine-r7/terraform,iansheridan/terraform,turkenh/terraform,nlamirault/terraform,dtan4/terraform,superseb/terraform,luis-silva/terraform,heimweh/terraform,cakoose/terraform,vincer/terraform,donaldguy/terraform,ryansroberts/terraform,mrwacky42/terraform-1,kjmkznr/...
6c94975cd3f560e1a2dbd8ee1d0b4180964852f9
test/utils/test_db.go
test/utils/test_db.go
package utils import ( "fmt" "os" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" _ "github.com/lib/pq" ) func TestDB() *gorm.DB { dbuser, dbpwd, dbname := "qor", "qor", "qor_test" if os.Getenv("TEST_ENV") == "CI" { dbuser, dbpwd = os.Getenv("DB_USER"), os.Getenv("DB_PWD") } var db gorm.DB ...
package utils import ( "fmt" "os" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" _ "github.com/lib/pq" ) func TestDB() *gorm.DB { dbuser, dbpwd, dbname := "qor", "qor", "qor_test" if os.Getenv("TEST_ENV") == "CI" { dbuser, dbpwd = os.Getenv("DB_USER"), os.Getenv("DB_PWD") } var db gorm.DB ...
Add guide for how to create test db for mysql
Add guide for how to create test db for mysql
Go
mit
qor/qor,qor/qor,qor/qor
eec2501b4cbe725c9088df5a5304e6e0806c7f3b
claat/nodes/header.go
claat/nodes/header.go
package nodes // NewHeaderNode creates a new HeaderNode with optional content nodes n. func NewHeaderNode(level int, n ...Node) *HeaderNode { return &HeaderNode{ node: node{typ: NodeHeader}, Level: level, Content: NewListNode(n...), } } // HeaderNode is any regular header, a checklist header, or an FAQ h...
package nodes // NewHeaderNode creates a new HeaderNode with optional content nodes n. func NewHeaderNode(level int, n ...Node) *HeaderNode { return &HeaderNode{ node: node{typ: NodeHeader}, Level: level, Content: NewListNode(n...), } } // HeaderNode is any regular header, a checklist header, or an FAQ h...
Add comment to HeaderNode's MutateType.
Add comment to HeaderNode's MutateType.
Go
apache-2.0
googlecodelabs/tools,googlecodelabs/tools,googlecodelabs/tools,googlecodelabs/tools
73665c55265666ab4c6a0483697663b002df0ac4
http_request_logger.go
http_request_logger.go
package main import ( "fmt" "io/ioutil" "log" "net/http" "os" "sort" ) func init() { log.SetOutput(os.Stdout) } func handler(w http.ResponseWriter, r *http.Request) { log.Println("Got", r.Method, "to:", r.URL) var keys []string for k := range r.Header { keys = append(keys, k) } sort.Strings(keys) lo...
package main import ( "fmt" "io/ioutil" "log" "net/http" "os" "sort" ) func init() { log.SetOutput(os.Stdout) } func handler(w http.ResponseWriter, r *http.Request) { log.Println("Got", r.Method, "to:", r.URL) var keys []string for k := range r.Header { keys = append(keys, k) } sort.Strings(keys) lo...
Use port from environment variable if specified
Use port from environment variable if specified
Go
mit
chris/http_request_logger
47fcc9b235c7205b30f163f295e682e91093fcb0
cmd/subd/tls.go
cmd/subd/tls.go
package main import ( "crypto/tls" "crypto/x509" "fmt" "github.com/Symantec/Dominator/lib/srpc" "io/ioutil" "os" ) func setupTls() { if *caFile == "" || *certFile == "" || *keyFile == "" { return } caData, err := ioutil.ReadFile(*caFile) if err != nil { fmt.Fprintf(os.Stderr, "Unable to load CA file\t%s...
package main import ( "crypto/tls" "crypto/x509" "fmt" "github.com/Symantec/Dominator/lib/srpc" "io/ioutil" "os" ) func setupTls() { if *caFile == "" || *certFile == "" || *keyFile == "" { return } caData, err := ioutil.ReadFile(*caFile) if err != nil { fmt.Fprintf(os.Stderr, "Unable to load CA file\t%s...
Change subd to require TLS v1.2 or greater.
Change subd to require TLS v1.2 or greater.
Go
apache-2.0
rgooch/Dominator,rgooch/Dominator,Symantec/Dominator,keep94/Dominator,Symantec/Dominator,keep94/Dominator,rgooch/Dominator,keep94/Dominator,Symantec/Dominator
c469d4a8372a12c6c9c1198c52a5c381e0d9637b
cmd/torrent-metainfo-pprint/main.go
cmd/torrent-metainfo-pprint/main.go
package main import ( "encoding/json" "flag" "fmt" "log" "os" "github.com/anacrolix/torrent/metainfo" ) func main() { name := flag.Bool("name", false, "print name") flag.Parse() for _, filename := range flag.Args() { metainfo, err := metainfo.LoadFromFile(filename) if err != nil { log.Print(err) c...
package main import ( "encoding/hex" "encoding/json" "fmt" "log" "os" "github.com/anacrolix/tagflag" "github.com/bradfitz/iter" "github.com/anacrolix/torrent/metainfo" ) var flags struct { JustName bool PieceHashes bool tagflag.StartPos TorrentFiles []string } func main() { tagflag.Parse(&flags) f...
Switch to tagflag for argument parsing
cmd/torrent-metainfo-pprint: Switch to tagflag for argument parsing
Go
mpl-2.0
anacrolix/torrent,anacrolix/torrent
1bc31ba8bdc52281d7945a34f579ec7fd53640f5
editor/normal_test.go
editor/normal_test.go
package editor import ( "context" "strings" "testing" ) func BenchmarkNormal(b *testing.B) { for i := 0; i < b.N; i++ { command := "hjkl" ed := normal{ streamSet: streamSet{in: NewReaderContext(context.TODO(), strings.NewReader(command))}, editor: newEditor(), } for range command { _, _, err :...
package editor import ( "context" "strings" "testing" ) func BenchmarkNormal(b *testing.B) { for i := 0; i < b.N; i++ { command := strings.Repeat("hjkl", 100) ed := normal{ streamSet: streamSet{in: NewReaderContext(context.TODO(), strings.NewReader(command))}, editor: newEditor(), } for range com...
Use a longer command to measure performance properly
Use a longer command to measure performance properly
Go
mit
elpinal/coco3
05a8de46853f8b3534ca6d0cb03121ae214e8a34
pkg/term/tc_linux_cgo.go
pkg/term/tc_linux_cgo.go
// +build linux,cgo package term import ( "syscall" "unsafe" ) // #include <termios.h> import "C" type Termios syscall.Termios // MakeRaw put the terminal connected to the given file descriptor into raw // mode and returns the previous state of the terminal so that it can be // restored. func MakeRaw(fd uintptr)...
// +build linux,cgo package term import ( "syscall" "unsafe" ) // #include <termios.h> import "C" type Termios syscall.Termios // MakeRaw put the terminal connected to the given file descriptor into raw // mode and returns the previous state of the terminal so that it can be // restored. func MakeRaw(fd uintptr)...
Fix weird terminal output format
Fix weird terminal output format Signed-off-by: Lei Jitang <9ac444d2b5df3db1f31aa1c6462ac8e9e2bde241@huawei.com>
Go
apache-2.0
keerthanabs1/docker,lixiaobing10051267/docker,manchoz/docker,mpatlasov/docker,jagdeesh109/docker,yp-engineering/docker,mixja/docker,wzzrd/docker,dccurtis/docker,kirankbs/docker,jc-m/docker,kdomanski/docker,wulonghui/docker,ankushagarwal/docker,zoomis/docker,bonczj/moby-json-file-logger,pecameron/docker,SFDMumbaiDockerH...
467a19e7e27ed9db000660f38a66c8719a2e06e5
aroc.go
aroc.go
package main import ( "fmt" "github.com/sdegutis/go.fsevents" "log" "os" "os/exec" ) func main() { if len(os.Args) < 3 { fmt.Fprintln(os.Stderr, "Usage: aroc DIRECTORY|FILE COMMAND [ARGS…]") os.Exit(1) } ch := fsevents.WatchPaths([]string{os.Args[1]}) var cmd *exec.Cmd go func() { for _ = range ch ...
package main import ( "fmt" "github.com/sdegutis/go.fsevents" "log" "os" "os/exec" "time" ) func main() { if len(os.Args) < 3 { fmt.Fprintln(os.Stderr, "Usage: aroc DIRECTORY|FILE COMMAND [ARGS…]") os.Exit(1) } ch := fsevents.WatchPaths([]string{os.Args[1]}) var cmd *exec.Cmd go func() { for _ = r...
Add wait of 1 second waiting for further events
Add wait of 1 second waiting for further events
Go
mit
mxey/aroc
42d12c834deedf68eb52614eec751311376279e2
model/tag_test.go
model/tag_test.go
package model import ( "testing" "github.com/stretchr/testify/assert" ) func TestFindOrCreateTagByNameShouldCreateTag(t *testing.T) { tag, _, err := FindOrCreateTagByName(db, "my-tag") assert.Nil(t, err) assert.NotNil(t, tag) assert.Equal(t, "my-tag", tag.Name) var check Tag db.Where("name = ?", "my-tag").F...
package model import ( "testing" "github.com/stretchr/testify/assert" ) func TestFindOrCreateTagByNameShouldCreateTag(t *testing.T) { tag, created, err := FindOrCreateTagByName(db, "my-tag") assert.Nil(t, err) assert.NotNil(t, tag) assert.True(t, created) assert.Equal(t, "my-tag", tag.Name) var check Tag d...
Add test for no duplicate tags
Add test for no duplicate tags
Go
mit
hoop33/limo
c9a64fedd7c65111b1438e762c98304b746d1033
execext/exec.go
execext/exec.go
package execext import ( "context" "errors" "io" "strings" "github.com/mvdan/sh/interp" "github.com/mvdan/sh/syntax" ) // RunCommandOptions is the options for the RunCommand func type RunCommandOptions struct { Context context.Context Command string Dir string Env []string Stdin io.Reader Stdou...
package execext import ( "context" "errors" "io" "strings" "github.com/mvdan/sh/interp" "github.com/mvdan/sh/syntax" ) // RunCommandOptions is the options for the RunCommand func type RunCommandOptions struct { Context context.Context Command string Dir string Env []string Stdin io.Reader Stdou...
Fix build after update of dependency
Fix build after update of dependency
Go
mit
go-task/task,go-task/task
5eef64a47062d4fc0cd8fa913984278a5ebb6900
matchers/assignable_to_matcher.go
matchers/assignable_to_matcher.go
package matchers import ( "fmt" "reflect" ) type AssignableToMatcher struct { Expected interface{} } func (matcher *AssignableToMatcher) Match(actual interface{}) (success bool, message string, err error) { if actual == nil || matcher.Expected == nil { return false, "", fmt.Errorf("Refusing to compare <nil> to...
package matchers import ( "fmt" "reflect" ) type AssignableToMatcher struct { Expected interface{} } func (matcher *AssignableToMatcher) Match(actual interface{}) (success bool, message string, err error) { if actual == nil || matcher.Expected == nil { return false, "", fmt.Errorf("Refusing to compare <nil> to...
Update error messages to reflect semantics
Update error messages to reflect semantics
Go
mit
jim-slattery-rs/gomega,james-lawrence/gomega,pivotal-cf-experimental/gomega,raphael/gomega,onsi/gomega,cf-guardian/gomega,ebabani/gomega
12e97361f951973205e3df80d4c7cb3b870d6df2
reporters/diff_reporter.go
reporters/diff_reporter.go
package reporters import ( "os/exec" "github.com/approvals/go-approval-tests/utils" ) // NewFrontLoadedReporter creates the default front loaded reporter. func NewFrontLoadedReporter() *Reporter { tmp := NewFirstWorkingReporter( NewContinuousIntegrationReporter(), ) return &tmp } // NewDiffReporter creates ...
package reporters import ( "os/exec" "github.com/approvals/go-approval-tests/utils" ) // NewFrontLoadedReporter creates the default front loaded reporter. func NewFrontLoadedReporter() *Reporter { tmp := NewFirstWorkingReporter( NewContinuousIntegrationReporter(), ) return &tmp } // NewDiffReporter creates ...
Move Gogland report higher up list because it couldn’t be used.
Move Gogland report higher up list because it couldn’t be used.
Go
apache-2.0
approvals/go-approval-tests
a6241c6a08821b872d81e505e130314463109495
pkg/jobs/workers_list.go
pkg/jobs/workers_list.go
package jobs import ( "fmt" "time" ) // WorkersList is a map associating a worker type with its acutal // configuration. type WorkersList map[string]*WorkerConfig // WorkersList is the list of available workers with their associated Do // function. var workersList WorkersList func init() { workersList = WorkersL...
package jobs import ( "fmt" "time" ) // WorkersList is a map associating a worker type with its acutal // configuration. type WorkersList map[string]*WorkerConfig // WorkersList is the list of available workers with their associated Do // function. var workersList WorkersList func init() { workersList = WorkersL...
Increase timeout for timeout job
Increase timeout for timeout job
Go
agpl-3.0
nono/cozy-stack,nono/cozy-stack,sebn/cozy-stack,nono/cozy-stack,nono/cozy-stack,nono/cozy-stack,sebn/cozy-stack,sebn/cozy-stack,sebn/cozy-stack
83256ccf0f5776e48499a2d4587dba8fff1c6ba0
cf/api/resources/space_quotas.go
cf/api/resources/space_quotas.go
package resources import "github.com/cloudfoundry/cli/cf/models" type PaginatedSpaceQuotaResources struct { Resources []SpaceQuotaResource } type SpaceQuotaResource struct { Resource Entity models.SpaceQuota } func (resource SpaceQuotaResource) ToModel() models.SpaceQuota { entity := resource.Entity return mo...
package resources import "github.com/cloudfoundry/cli/cf/models" type PaginatedSpaceQuotaResources struct { Resources []SpaceQuotaResource } type SpaceQuotaResource struct { Resource Entity models.SpaceQuota } func (resource SpaceQuotaResource) ToModel() models.SpaceQuota { entity := resource.Entity return mo...
Fix instance memory output for space-quota(s).
Fix instance memory output for space-quota(s).
Go
apache-2.0
TomG713/cli,SrinivasChilveri/cli,SrinivasChilveri/cli,carnell69/cli,saurabhguptasg/cli,TomG713/cli,simonleung8/cli,zhang-hua/cli,srikanth88infy/cli,kavoj/cli,cgvarela/cli,zhang-hua/cli,ReachingOut/cli,carnell69/cli,saravana76/cli,rastasheep/trash-can,SrinivasChilveri/cli,Zouuup/cli,fujitsu-cf/cli,mcowger/cli,Zouuup/cli...
c4407ea562bc6f470826988cc30b76c315b07a90
lib/go/thrift/binary_protocol_test.go
lib/go/thrift/binary_protocol_test.go
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ma...
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you ma...
Add a ReadString Benchmark for the binary protocol
lib/go/thrift: Add a ReadString Benchmark for the binary protocol
Go
apache-2.0
upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift,upfluence/thrift