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 |
|---|---|---|---|---|---|---|---|---|---|
ad8616bf2c88d174c110a14caa62d586c0222f9f | orchestrators/orchestrator.go | orchestrators/orchestrator.go | package orchestrators
import (
log "github.com/Sirupsen/logrus"
"github.com/camptocamp/conplicity/handler"
"github.com/camptocamp/conplicity/volume"
)
// Orchestrator implements a container Orchestrator interface
type Orchestrator interface {
GetHandler() *handler.Conplicity
GetVolumes() ([]*volume.Volume, error... | package orchestrators
import (
log "github.com/Sirupsen/logrus"
"github.com/camptocamp/conplicity/handler"
"github.com/camptocamp/conplicity/volume"
)
// Orchestrator implements a container Orchestrator interface
type Orchestrator interface {
GetHandler() *handler.Conplicity
GetVolumes() ([]*volume.Volume, error... | Update volumes variable name for LaunchContainer | Update volumes variable name for LaunchContainer
| Go | apache-2.0 | camptocamp/conplicity,camptocamp/conplicity |
4a25da23b978d2eacb145d710a9682cc12b74f88 | shared/log15/term/terminal_notwindows.go | shared/log15/term/terminal_notwindows.go | // Based on ssh/terminal:
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build linux,!appengine darwin freebsd openbsd
package term
import (
"unsafe"
"golang.org/x/sys/unix"
)
// IsTty returns true... | // Based on ssh/terminal:
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build linux,!appengine darwin freebsd openbsd
package term
import (
"golang.org/x/sys/unix"
)
// IsTty returns true if the giv... | Fix due to recent unix change | shared/log15: Fix due to recent unix change
Signed-off-by: Stéphane Graber <089afc6d81f66f1168a9849e15660feae286e024@ubuntu.com>
| Go | apache-2.0 | stgraber/lxd,stgraber/lxd,hallyn/lxd,hallyn/lxd,hallyn/lxd,stgraber/lxd,hallyn/lxd,lxc/lxd,lxc/lxd,hallyn/lxd,atxwebs/lxd,atxwebs/lxd,atxwebs/lxd,stgraber/lxd,hallyn/lxd,lxc/lxd,lxc/lxd,stgraber/lxd,lxc/lxd,stgraber/lxd,lxc/lxd,stgraber/lxd,atxwebs/lxd,lxc/lxd |
882d2f8f88d80d42d9d79fc115e90ac2cbcaf7b3 | engines/qemu/fetcher.go | engines/qemu/fetcher.go | package qemuengine
import (
"fmt"
"os"
"github.com/taskcluster/taskcluster-worker/engines/qemu/image"
"github.com/taskcluster/taskcluster-worker/runtime"
"github.com/taskcluster/taskcluster-worker/runtime/fetcher"
)
// A fetcher for downloading images.
var imageFetcher = fetcher.Combine(
// Allow fetching imag... | package qemuengine
import (
"fmt"
"os"
"github.com/taskcluster/taskcluster-worker/engines/qemu/image"
"github.com/taskcluster/taskcluster-worker/runtime"
"github.com/taskcluster/taskcluster-worker/runtime/fetcher"
)
// A fetcher for downloading images.
var imageFetcher = fetcher.Combine(
// Allow fetching imag... | Transform broken reference to malformed-payload error | Transform broken reference to malformed-payload error
| Go | mpl-2.0 | walac/taskcluster-worker,walac/taskcluster-worker |
2d00a8c4ba276ecd23cedac76754789bdccdd8d3 | values/smap_utils.go | values/smap_utils.go | package values
// Keys returns all the keys.
func (m SMap) Keys() []string {
r := make([]string, 0)
for k := range m {
r = append(r, k)
}
return r
}
// Values returns all the values.
func (m SMap) Values() []interface{} {
r := make([]interface{}, 0)
for _, v := range m {
r = append(r, v)
}
return r
}
| package values
// Keys returns all the keys.
func (m SMap) Keys() []string {
r := make([]string, 0)
for k := range m {
r = append(r, k)
}
return r
}
// Values returns all the values.
func (m SMap) Values() []interface{} {
r := make([]interface{}, 0)
for _, v := range m {
r = append(r, v)
}
return r
}
// ... | Add the method In for SMap. | Add the method In for SMap.
| Go | apache-2.0 | xgfone/go-tools |
86dad31139dac86af1c47c72d1a248741ed632c5 | termios/pty_linux.go | termios/pty_linux.go | package termios
import (
"fmt"
"unsafe"
"golang.org/x/sys/unix"
)
func open_pty_master() (uintptr, error) {
return open_device("/dev/ptmx")
}
func Ptsname(fd uintptr) (string, error) {
var n uintptr
err := ioctl(fd, unix.TIOCGPTN, uintptr(unsafe.Pointer(&n)))
if err != nil {
return "", err
}
return fmt.S... | package termios
import (
"fmt"
"unsafe"
"golang.org/x/sys/unix"
)
func open_pty_master() (uintptr, error) {
return open_device("/dev/ptmx")
}
func Ptsname(fd uintptr) (string, error) {
var n uint32
err := ioctl(fd, unix.TIOCGPTN, uintptr(unsafe.Pointer(&n)))
if err != nil {
return "", err
}
return fmt.Sp... | Fix ptsname() for big-endian architectures | Fix ptsname() for big-endian architectures
| Go | bsd-2-clause | pkg/term |
bd1ae3761b68c5629c7d693a775ae4f359a79dde | go/vt/wrangler/events/reparent.go | go/vt/wrangler/events/reparent.go | // Package events defines the structures used for events dispatched from the
// wrangler package.
package events
import (
"github.com/youtube/vitess/go/event"
"github.com/youtube/vitess/go/vt/topo"
)
// Reparent is an event that describes a single step in the reparent process.
type Reparent struct {
ShardInfo topo... | // Package events defines the structures used for events dispatched from the
// wrangler package.
package events
import (
"time"
"github.com/youtube/vitess/go/event"
"github.com/youtube/vitess/go/vt/topo"
)
// Reparent is an event that describes a single step in the reparent process.
type Reparent struct {
Shard... | Add eventID to Reparent event for grouping. | Add eventID to Reparent event for grouping.
| Go | apache-2.0 | guokeno0/vitess,fengshao0907/vitess,SDHM/vitess,applift/vitess,anusornc/vitess,SDHM/vitess,anusornc/vitess,erzel/vitess,skyportsystems/vitess,tinyspeck/vitess,mattharden/vitess,dcadevil/vitess,cgvarela/vitess,SDHM/vitess,michael-berlin/vitess,kuipertan/vitess,cloudbearings/vitess,tjyang/vitess,nurblieh/vitess,alainjoba... |
3cf19149ca2655b235f941f012f74a422eafed4c | lib/url/urlutil/open.go | lib/url/urlutil/open.go | package urlutil
import (
"errors"
"io"
"net/http"
"net/url"
"os"
)
func open(rawurl string) (io.ReadCloser, error) {
u, err := url.Parse(rawurl)
if err != nil {
return nil, err
}
if u.Scheme == "file" {
return os.Open(u.Path)
}
if u.Scheme == "http" || u.Scheme == "https" {
resp, err := http.Get(rawu... | package urlutil
import (
"errors"
"io"
"net/http"
"net/url"
"os"
)
func open(rawurl string) (io.ReadCloser, error) {
u, err := url.Parse(rawurl)
if err != nil {
return nil, err
}
if u.Scheme == "file" {
return os.Open(u.Path)
}
if u.Scheme == "http" || u.Scheme == "https" {
resp, err := http.Get(rawu... | Improve error messages in lib/url/urlutil.Open(). | Improve error messages in lib/url/urlutil.Open().
| Go | apache-2.0 | rgooch/Dominator,Symantec/Dominator,rgooch/Dominator,Symantec/Dominator,rgooch/Dominator,Symantec/Dominator |
aadbcce486df149a8b09cdbe753e624a8fddd8ba | fs/mimetype.go | fs/mimetype.go | package fs
import (
"mime"
"path"
"strings"
)
// MimeTypeFromName returns a guess at the mime type from the name
func MimeTypeFromName(remote string) (mimeType string) {
mimeType = mime.TypeByExtension(path.Ext(remote))
if !strings.ContainsRune(mimeType, '/') {
mimeType = "application/octet-stream"
}
return ... | package fs
import (
"mime"
"path"
"strings"
)
// MimeTypeFromName returns a guess at the mime type from the name
func MimeTypeFromName(remote string) (mimeType string) {
mimeType = mime.TypeByExtension(path.Ext(remote))
if !strings.ContainsRune(mimeType, '/') {
mimeType = "application/octet-stream"
}
return ... | Add MimeTypeDirEntry to return the MimeType of a DirEntry | fs: Add MimeTypeDirEntry to return the MimeType of a DirEntry
| Go | mit | B4dM4n/rclone,olihey/rclone,olihey/rclone,B4dM4n/rclone,B4dM4n/rclone,ncw/rclone,olihey/rclone,B4dM4n/rclone,ncw/rclone,yonjah/rclone,yonjah/rclone,ncw/rclone,yonjah/rclone,yonjah/rclone,olihey/rclone,ncw/rclone |
404e15219b69ae60f3e3e735636f39c0e3773b5f | cmd/vm-control/findHypervisor.go | cmd/vm-control/findHypervisor.go | package main
import (
"fmt"
"net"
"github.com/Symantec/Dominator/lib/errors"
)
func findHypervisor(vmIpAddr net.IP) (string, error) {
if *hypervisorHostname != "" {
return fmt.Sprintf("%s:%d", *hypervisorHostname, *hypervisorPortNum),
nil
} else {
return "", errors.New("no Hypervisor specified")
}
}
| package main
import (
"fmt"
"net"
"github.com/Symantec/Dominator/lib/errors"
"github.com/Symantec/Dominator/lib/srpc"
proto "github.com/Symantec/Dominator/proto/fleetmanager"
)
func findHypervisor(vmIpAddr net.IP) (string, error) {
if *fleetManagerHostname != "" {
cm := fmt.Sprintf("%s:%d", *fleetManagerHost... | Support fleet manager in vm-control command. | Support fleet manager in vm-control command.
| Go | apache-2.0 | rgooch/Dominator,Symantec/Dominator,rgooch/Dominator,Symantec/Dominator,Symantec/Dominator,rgooch/Dominator |
3fe9f694567f7d67cb0846b0ad5d758dbe233f79 | pkg/api/helpers.go | pkg/api/helpers.go | /*
Copyright 2014 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in ... | /*
Copyright 2014 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in ... | Change the default Pull policy to PullIfNotPresent. | Change the default Pull policy to PullIfNotPresent.
Kubernetes-commit: 81107c3e986956601869c687a17ba690bb551fa9
| Go | apache-2.0 | kubernetes/api |
9293d227b5e89dfa2714974ef01f0505b9443652 | cmd/parseMovieName/main.go | cmd/parseMovieName/main.go | package main
import (
"flag"
"fmt"
"os"
"github.com/labstack/gommon/log"
"github.com/scritch007/go-moviename"
)
var debug bool
func init() {
flag.BoolVar(&debug, "v", false, "Enable debug logs")
}
func main() {
flag.Parse()
logger := log.New("cmdLine")
if debug {
logger.SetLevel(log.DEBUG)
}
mp := mov... | package main
import (
"flag"
"fmt"
"os"
"github.com/labstack/gommon/log"
"github.com/scritch007/go-medianame"
)
var debug bool
func init() {
flag.BoolVar(&debug, "v", false, "Enable debug logs")
}
func main() {
flag.Parse()
logger := log.New("cmdLine")
if debug {
logger.SetLevel(log.DEBUG)
}
mp := mov... | Rename to new repo name | Rename to new repo name
| Go | mit | scritch007/go-medianame |
ebe808f6f0fed968fc1949da25b4c869ec98abf5 | planeteer_test.go | planeteer_test.go | package main
import "testing"
func TestEncodeDecode(t *testing.T) {
dims := []int{3, 2, 4, 17, 26, 15, 1, 2, 1}
for i := 0; i < 318240; i++ { // Product of dims
addr := DecodeIndex(dims, i)
for j := 0; j < len(dims); j++ {
if addr[j] >= dims[j] {
t.Fail()
}
}
if EncodeIndex(dims, addr) != i {
... | package main
import "testing"
func TestEncodeDecode(t *testing.T) {
dims := []int{3, 2, 4, 17, 26, 15, 2, 1, 2, 1}
var i int32
for i = 0; i < 636480; i++ { // Product of dims
addr := DecodeIndex(dims, i)
for j := 0; j < len(dims); j++ {
if addr[j] >= dims[j] {
t.Fail()
}
}
if EncodeIndex(dims, ad... | Fix test: Add trading dimension. | Fix test: Add trading dimension.
| Go | agpl-3.0 | chkno/planeteer,chkno/planeteer |
f8cbbbb498421a7b43db739243681adf296e6d85 | nptl/writer.go | nptl/writer.go | package nptl
import (
"fmt"
"io"
"github.com/krasin/g3"
"github.com/krasin/voxel/raster"
"github.com/krasin/voxel/volume"
)
func Write(w io.Writer, vol volume.Space16, grid raster.Grid) (err error) {
stepX := (grid.P1[0] - grid.P0[0]) / float64(vol.N())
stepY := (grid.P1[1] - grid.P0[1]) / float64(vol.N())
s... | package nptl
import (
"fmt"
"io"
"github.com/krasin/g3"
"github.com/krasin/voxel/volume"
)
func Write(w io.Writer, vol volume.Space16, grid g3.Grid) (err error) {
vol.MapBoundary(func(node g3.Node) {
nv := volume.Normal(vol, node)
cur := grid.At(node)
if _, err = fmt.Fprintf(w, "%f %f %f %f %f %f\n",
c... | Convert ntpl.Write to use g3.Grid | Convert ntpl.Write to use g3.Grid
| Go | mit | krasin/voxel |
807fd97a47a32f9819674341082aea609e9691b0 | src/pkg/os/signal/signal_test.go | src/pkg/os/signal/signal_test.go | // Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package signal
import (
"syscall"
"testing"
)
func TestSignal(t *testing.T) {
// Send this process a SIGHUP.
syscall.Syscall(syscall.SYS_KILL, uintptr(sys... | // Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package signal
import (
"syscall"
"testing"
)
func TestSignal(t *testing.T) {
// Send this process a SIGHUP.
syscall.Syscall(syscall.SYS_KILL, uintptr(sys... | Use t.Errorf for formatted error output. | Use t.Errorf for formatted error output.
R=dsymonds1
CC=golang-dev
http://codereview.appspot.com/183049
| Go | bsd-3-clause | bryanxu/go-zh,bryanxu/go-zh,rflanagan/reginaldflanagan-project1,d0f/go-zh,rflanagan/reginaldflanagan-project1,npe9/noahevans-go9,bryanxu/go-zh,npe9/noahevans-go9,Triskite/willstone-goclone,d0f/go-zh,scirelli/scirelli-go,bryanxu/go-zh,Triskite/willstone-goclone,glycerine/jeaten-go-arrayof-structof,scirelli/scirelli-go,g... |
e5bc99a99d55d43985c9d51e114bae665b176de7 | types/types.go | types/types.go | package types
//type Config map[string][]map[string]string
type ConfigRecord map[string]string
type Config map[string]ConfigRecord
type BaseRecord struct {
Title string
Link string
}
type RecordList []BaseRecord | // Package types provides types for the custom JSON configuration and the
// custom JSON read, watch and book JSON file.
package types
import (
"os"
"fmt"
"encoding/json"
)
// A single record of the configuration file.
type ConfigRecord map[string]string
// A whole configuration file.
type Config map[string]Confi... | Add RecordList Read, Write and documentation | Add RecordList Read, Write and documentation
| Go | mit | danielkocher/link-select |
9fcc3c99dacf63aef455ac8be895b45eab110a47 | main.go | main.go | package main
import (
"github.com/albertyw/reaction-pics/server"
"github.com/albertyw/reaction-pics/tumblr"
_ "github.com/joho/godotenv/autoload"
"os"
"strings"
)
const readPostsFromTumblrEnv = "READ_POSTS_FROM_TUMBLR"
func getReadPostsFromTumblr() bool {
readPostsEnv := os.Getenv(readPostsFromTumblrEnv)
if s... | package main
import (
"github.com/albertyw/reaction-pics/server"
"github.com/albertyw/reaction-pics/tumblr"
_ "github.com/joho/godotenv/autoload"
"os"
"strings"
)
const readPostsFromTumblrEnv = "READ_POSTS_FROM_TUMBLR"
func getReadPostsFromTumblr() bool {
readPostsEnv := os.Getenv(readPostsFromTumblrEnv)
if s... | Make WritePostsToCSV run in a goroutine | Make WritePostsToCSV run in a goroutine
| Go | mit | albertyw/reaction-pics,albertyw/reaction-pics,albertyw/devops-reactions-index,albertyw/devops-reactions-index,albertyw/reaction-pics,albertyw/reaction-pics,albertyw/devops-reactions-index,albertyw/devops-reactions-index |
35246bbbee0d65e0b83977d785b0f6be886e572e | main.go | main.go | // Copyright 2015 Reed O'Brien <reed@reedobrien.com>.
// All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package main
import (
"fmt"
)
func main() {
fmt.Print("code appears here")
}
| // Copyright 2015 Reed O'Brien <reed@reedobrien.com>.
// All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"time"
)
var (
err error
secret string // The hex or base32 secret
// otp string // If a valu... | Add initial whack at flags. | Add initial whack at flags.
| Go | bsd-3-clause | yubo/oath |
a5c5f5dad4cfca91c53d043bfc26b0b248a7b28f | main.go | main.go | package main
import (
"fmt"
"github.com/nitishparkar/muffliato/crawler"
"io/ioutil"
"strings"
)
const sitesFile string = "sites.txt"
func main() {
data, err := ioutil.ReadFile(sitesFile)
if err != nil {
panic(err)
}
sites := strings.Split(string(data), "\n")
done := make(chan bool)
for _, site := ran... | package main
import (
"fmt"
"github.com/nitishparkar/muffliato/crawler"
"io/ioutil"
"strings"
)
const sitesFile string = "sites.txt"
func main() {
data, err := ioutil.ReadFile(sitesFile)
if err != nil {
panic(err)
}
sites := strings.Split(string(data), "\n")
validSites := make([]string, 0)
for _, sit... | Handle empty strings in sites file | Handle empty strings in sites file
| Go | mit | nitishparkar/muffliato |
0431f75e27d08749ab94e7487201d36491ae7aff | main.go | main.go | package main
import (
"flag"
"log"
"net/http"
"strconv"
"github.com/rtwire/mock/service"
)
var (
port = flag.Int("port", 8085, "service port number")
)
func main() {
flag.Parse()
addr := ":" + strconv.Itoa(*port)
log.Printf("Mock RTWire service running on port %d.", *port)
log.Fatal(http.ListenAndServe(... | package main
import (
"flag"
"fmt"
"log"
"net/http"
"strconv"
"github.com/rtwire/mock/service"
)
var (
port = flag.Int("port", 8085, "service port number")
)
func main() {
flag.Parse()
url := fmt.Sprintf("http://localhost:%d/v1/mainnet/", *port)
log.Printf("RTWire service running at %s.", url)
addr := ... | Improve start up logging message. | Improve start up logging message.
| Go | apache-2.0 | rtwire/mock,rtwire/mock |
064d5b673d539d884b1dfb53012bf49e56b49832 | web/public/public.go | web/public/public.go | // Package public adds some public routes that can be used to give information
// to anonymous users, or to the not yet authentified cozy owner on its login
// page.
package public
import (
"net/http"
"time"
"github.com/cozy/cozy-stack/pkg/statik/fs"
"github.com/cozy/cozy-stack/web/middlewares"
"github.com/cozy/... | // Package public adds some public routes that can be used to give information
// to anonymous users, or to the not yet authentified cozy owner on its login
// page.
package public
import (
"net/http"
"time"
"github.com/cozy/cozy-stack/pkg/statik/fs"
"github.com/cozy/cozy-stack/web/middlewares"
"github.com/cozy/... | Allow to customize the default avatar by context | Allow to customize the default avatar by context
| Go | agpl-3.0 | nono/cozy-stack,nono/cozy-stack,nono/cozy-stack,nono/cozy-stack,nono/cozy-stack |
a79cee721980a5c4ae084fd1684c51330dc27ef7 | zoom.go | zoom.go | // Copyright 2015 Alex Browne. All rights reserved.
// Use of this source code is governed by the MIT
// license, which can be found in the LICENSE file.
// Package zoom A blazing-fast datastore and querying engine for
// Go built on Redis. It supports models of any arbitrary struct
// type and provides basic queryin... | // Copyright 2015 Alex Browne. All rights reserved.
// Use of this source code is governed by the MIT
// license, which can be found in the LICENSE file.
// Package zoom is a blazing-fast datastore and querying engine for
// Go built on Redis. It supports models of any arbitrary struct
// type and provides basic quer... | Fix typo in doc comment | Fix typo in doc comment
| Go | mit | albrow/zoom |
12eed13535bbf4679d29b845f6bcb4eef4a49bba | fuzz.go | fuzz.go | /* Copyright 2019 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
dis... | /* Copyright 2019 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
dis... | Add comment for exported function. | Add comment for exported function.
| Go | apache-2.0 | google/gonids |
c5c0507ffa2894e4c56756ca0750cfe648b3a80c | hsts.go | hsts.go | package main
import "net/http"
// Middleware to add HSTS header
func hstsHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Strict-Transport-Security", "max-age=31536000; preload")
h.ServeHTTP(w, r)
})
} | package main
import "net/http"
// Middleware to add HSTS header
func hstsHandler(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
h.ServeHTTP(w, r)
})
}
| Add sub domain HTTPS enhancement | Add sub domain HTTPS enhancement
| Go | mit | mooxmirror/blog,mooxmirror/go-blog,mooxmirror/go-blog,mooxmirror/blog |
1301e1f57c0fc3935cdf707112eb75a77025f8d3 | refactored_components/packet.go | refactored_components/packet.go | // Copyright © 2015 The Things Network
// Use of this source code is governed by the MIT license that can be found in the LICENSE file.
package components
import (
"github.com/thethingsnetwork/core"
//"github.com/thethingsnetwork/core/lorawan"
"fmt"
"github.com/thethingsnetwork/core/semtech"
)
var ErrImpossibleC... | // Copyright © 2015 The Things Network
// Use of this source code is governed by the MIT license that can be found in the LICENSE file.
package components
import (
"github.com/thethingsnetwork/core"
//"github.com/thethingsnetwork/core/lorawan"
"fmt"
"github.com/thethingsnetwork/core/semtech"
)
var ErrImpossibleC... | Change signature of convert method | [broker] Change signature of convert method
| Go | mit | TheThingsNetwork/ttn,mgranberry/ttn,LoRaWanSoFa/ttn,mgranberry/ttn,TheThingsNetwork/ttn,jvanmalder/ttn,LoRaWanSoFa/ttn,jvanmalder/ttn,mgranberry/ttn,TheThingsNetwork/ttn,jvanmalder/ttn |
f2ab00ce73744c95a986100784ec4af92cd83c33 | client/auth.go | client/auth.go | package client
import (
"net/http"
"golang.org/x/oauth2"
)
type authCodeFn func(string) func() string
func NewOauthClient(clientId, clientSecret, tokenFile string, authFn authCodeFn) (*http.Client, error) {
conf := &oauth2.Config{
ClientID: clientId,
ClientSecret: clientSecret,
... | package client
import (
"net/http"
"golang.org/x/oauth2"
)
type authCodeFn func(string) func() string
func NewOauthClient(clientId, clientSecret, tokenFile string, authFn authCodeFn) (*http.Client, error) {
conf := &oauth2.Config{
ClientID: clientId,
ClientSecret: clientSecret,
... | Check for missing refresh token | Check for missing refresh token
| Go | mit | prasmussen/gdrive,prasmussen/gdrive |
6fe65e139763923bc15772e4a9edf111fe5ca0ad | appui/listen.go | appui/listen.go | package appui
import (
"context"
"github.com/docker/docker/api/types/events"
"github.com/moncho/dry/docker"
"github.com/moncho/dry/ui/termui"
)
//RegisterWidget registers the given widget for updates from the given source
func RegisterWidget(source docker.SourceType, w termui.Widget) {
docker.GlobalRegistry.Reg... | package appui
import (
"context"
"time"
"github.com/docker/docker/api/types/events"
"github.com/moncho/dry/docker"
"github.com/moncho/dry/ui/termui"
)
var timeBetweenRefresh = 500 * time.Millisecond
//RegisterWidget registers the given widget for updates from the given source
func RegisterWidget(source docker.... | Refresh only if a certain time has passed since the previous event | Refresh only if a certain time has passed since the previous event
| Go | mit | moncho/dry,moncho/dry |
bd770a882a8b911787eaaad8e382f83a9cd8f496 | template/template.go | template/template.go | package template
import (
"errors"
"io/ioutil"
"text/template"
)
const defaultTemplate = `{{ range . }}
{{ . }}
{{ end }}
`
// -------------------------------------------------------
// Parser.
// -------------------------------------------------------
// Parse a template (and select the appropriate engine based... | package template
import (
"errors"
"io/ioutil"
"text/template"
)
const defaultTemplate = "{{ range . }}{{ . }}\n\n{{ end }}"
// -------------------------------------------------------
// Parser.
// -------------------------------------------------------
// Parse a template (and select the appropriate engine base... | Use normal string to encapsulate the default tpl | Use normal string to encapsulate the default tpl
| Go | mit | solarsailer/makeinvoice |
2e943e24b794d899aae3397a6a8a34ea2ee4271d | task_8/Golang/main.go | task_8/Golang/main.go | package main
import "fmt"
import "io/ioutil"
import "os"
func main() {
fmt.Println("Advent of code: Golang\nTask 8")
PrintCurrentDir()
file, err := ioutil.ReadFile("../input.txt")
if err != nil {
fmt.Println(err)
return
}
content := string(file)
fmt.Println(content)
}
func PrintCurrentDir() {
pwd, err... | package main
import "fmt"
import "io/ioutil"
import "os"
func main() {
fmt.Println("Advent of code: Golang\nTask 8")
PrintCurrentDir()
file, err := ioutil.ReadFile("../input.txt")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
content := string(file)
fmt.Println(content)
}
func PrintCurrentDir() {
pwd,... | Exit in more cruel form | Exit in more cruel form
| Go | apache-2.0 | EvilKhaosKat/advent_of_code,EvilKhaosKat/advent_of_code,EvilKhaosKat/advent_of_code,EvilKhaosKat/advent_of_code |
424bc782bc1d5b5125a0e17aa319bd75132b6309 | gotools.go | gotools.go | package main
import (
"os"
"path/filepath"
)
// goGenerate executes the command "go generate"
func goGenerate() {
cmd("go", "generate").Run()
}
// goBuild executes the command "go build" for the desired
// target OS and architecture, and writes the generated
// executable to the 'outDir' directory.
func goBuild(n... | package main
import (
"os"
"path/filepath"
)
// goGenerate executes the command "go generate"
func goGenerate() {
cmd("go", "generate").Run()
}
// goBuild executes the command "go build" for the desired
// target OS and architecture, and writes the generated
// executable to the 'outDir' directory.
func goBuild(n... | Fix getting and setting Go env vars during build | Fix getting and setting Go env vars during build
| Go | mit | samherrmann/gowrap |
2d05579085563a744b5be9a5823e4190f748f8fa | mesos_test_provider.go | mesos_test_provider.go | package main
import (
"fmt"
"math/rand"
"strings"
"time"
)
func mesosTestProvider(taskId string) (RunningTask, error) {
parts := strings.Split(taskId, ".")
if len(parts) == 2 && parts[0] != "" {
return RunningTask{
Id: taskId,
Name: parts[0],
StartTime: time.Now(),
}, nil
} else {
return Running... | package main
import (
"fmt"
"math/rand"
"strings"
"time"
)
func mesosTestProvider(taskId string) (RunningTask, error) {
parts := strings.Split(taskId, ".")
if len(parts) == 2 && parts[1] != "" {
return RunningTask{
Id: taskId,
Name: parts[0],
StartTime: time.Now(),
}, nil
} else {
re... | Fix test provider, go fmt | Fix test provider, go fmt
| Go | mit | ChannelMeter/vault-gatekeeper-mesos,ChannelMeter/vault-gatekeeper-mesos |
128d16ff4ef45fd94b97b8d3ff6c00abcbdc9c40 | hw.go | hw.go | //Command to run test version:
//goapp serve app.yaml
//Command to deploy/update application:
//goapp deploy -application golangnode0 -version 0
package main
import (
"fmt"
"net/http"
)
func helloWorld(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World!")
}
func startPage(w http.ResponseWriter... | //Command to run test version:
//goapp serve app.yaml
//Command to deploy/update application:
//goapp deploy -application golangnode0 -version 0
package main
import (
"fmt"
"net/http"
)
func helloWorld(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World!")
}
func startPage(w http.ResponseWriter... | Correct version for deploy to GAE | Correct version for deploy to GAE
| Go | mit | GreyLabsDev/GoTests,GreyLabsDev/GoTests |
d5e92175cf887cb71183bdf4fab51debb485f29e | integration_tests/user_test.go | integration_tests/user_test.go | package wl_integration_test
import (
"github.com/nu7hatch/gouuid"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/robdimsdale/wl"
)
var _ = Describe("basic user functionality", func() {
It("can update the user's name", func() {
By("Creating a new random user name")
uuid1, err := uuid.NewV4(... | package wl_integration_test
import (
"github.com/nu7hatch/gouuid"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/robdimsdale/wl"
)
var _ = Describe("basic user functionality", func() {
It("can update the user's name", func() {
By("Creating a new random user name")
uuid1, err := uuid.NewV4(... | Make user integration test more resilient to 409 errors. | Make user integration test more resilient to 409 errors.
| Go | mit | robdimsdale/wundergo,robdimsdale/wl,robdimsdale/wundergo,robdimsdale/wl |
038b5645f8d1eef2bd0d43fe1fbd87858102edae | message.go | message.go | //
// Copyright (c) 2017 Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package export
// Message - Encapsulating / wrapper message object that contains Event
// to be exported and the client export registration details
type Message struct {
Registration Registration
Evt Event
}
// Event - packet o... | //
// Copyright (c) 2017 Mainflux
//
// SPDX-License-Identifier: Apache-2.0
//
package export
// Message - Encapsulating / wrapper message object that contains Event
// to be exported and the client export registration details
type Message struct {
Registration Registration
Evt Event
}
// Event - packet o... | Add missing id fields in readings and events | Add missing id fields in readings and events
Signed-off-by: Federico Claramonte <9aaaa8bfe6a7a51765b462c528e1446dcf049286@caviumnetworks.com>
| Go | apache-2.0 | feclare/edgex-export |
09980b8e6b94a854cded0147f3a904fa93b03484 | metrics.go | metrics.go | package main
import (
"time"
"github.com/prometheus/client_golang/prometheus"
)
var (
gaugeTotal = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "total",
Namespace: "scan",
Subsystem: "ips",
Help: "Total IPs found",
})
gaugeLatest = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "la... | package main
import (
"time"
"github.com/prometheus/client_golang/prometheus"
)
var (
gaugeTotal = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "total",
Namespace: "scan",
Subsystem: "ips",
Help: "Total IPs found",
})
gaugeLatest = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "la... | Add a metric for jobs | Add a metric for jobs
This adds a new gauge for job data, with each job as a separate
timeseries using labels. Each metric includes the submitted and received
times as Unix time in case consumers want to work out the time taken for
each job.
| Go | mit | jamesog/scan,jamesog/scan,jamesog/scan |
43812e383db83df5c56a400c4cedd48c62d49a9c | sanntid.go | sanntid.go | package sanntid
type Line struct {
Name string
Destination string
}
type Arrival struct {
Line Line
ExpectedArrivalTime string
Platform string
}
func GetArrivals(locationId int) ([]Arrival, error) {
var arrivals []Arrival
data, err := requestArrivalData(locationId)
if err =... | package sanntid
type Line struct {
Name string
Destination string
}
type Arrival struct {
Line Line
ExpectedArrivalTime string
Platform string
}
func GetArrivals(locationId int) ([]Arrival, error) {
var arrivals []Arrival
data, err := requestArrivalData(locationId)
if err =... | Remove unused variable from data processing loop | Remove unused variable from data processing loop
| Go | mit | michaelenger/sanntid |
914de9e43b018d0582babdad9adf82fb31ae0770 | cookie_set_handler.go | cookie_set_handler.go | package auth
import (
"net/http"
)
const CookieName = "ATC-Authorization"
type CookieSetHandler struct {
Handler http.Handler
}
func (handler CookieSetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
cookie, err := r.Cookie(CookieName)
if err == nil && r.Header.Get("Authorization") == "" {
r.Heade... | package auth
import (
"net/http"
)
const CookieName = "ATC-Authorization"
type CookieSetHandler struct {
Handler http.Handler
}
func (handler CookieSetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
cookie, err := r.Cookie(CookieName)
if err == nil && r.Header.Get("Authorization") == "" {
r.Heade... | Add X- headers for security | Add X- headers for security
X-XSS, X-Content-Type-Options, X-Download-Options have sane defaults,
but X-Frame-Options would break existing functionality of including
concourse on iframes if we added this header by default.
Instead, we expose what to put in this header in the ATC flags,
defaulting it to no header.
[#... | Go | apache-2.0 | concourse/concourse,concourse/concourse,concourse/concourse,concourse/concourse,concourse/concourse |
d5047421dd8cd333814f97643bccfdda4f270c9a | length_test.go | length_test.go | package gstrings
import (
"github.com/wallclockbuilder/testify/assert"
"testing"
)
func TestLength(t *testing.T) {
assert := assert.New(t)
assert.Equal(5, Length("hello"))
}
| package gstrings
import (
"fmt"
"github.com/wallclockbuilder/testify/assert"
"testing"
)
func ExampleLength(){
fmt.Println(Length("hello"))
// Output: 5
}
func TestLength(t *testing.T) {
assert := assert.New(t)
assert.Equal(5, Length("hello"))
}
| Add example to docs for Length | Add example to docs for Length
| Go | bsd-2-clause | wallclockbuilder/gstrings,wallclockbuilder/stringutil |
f0932b8c5186d9a53905036a5df0a2dfdddd5b56 | ch1/fetchall/main.go | ch1/fetchall/main.go | package main
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"strings"
"time"
)
func main() {
start := time.Now()
ch := make(chan string)
for _, url := range os.Args[1:] {
if !strings.HasPrefix(url, "http://") {
url = "http://" + url
}
go fetch(url, ch)
}
for range os.Args[1:] {
fmt.Println(<-c... | package main
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"strings"
"time"
)
func main() {
start := time.Now()
ch := make(chan string)
for _, url := range os.Args[1:] {
if !strings.HasPrefix(url, "http://") {
url = "http://" + url
}
go fetch(url, ch)
}
for range os.Args[1:] {
fmt.Println(<-c... | Send start message to channel. | Send start message to channel.
| Go | mit | jimlawton/gopl |
df987c84de144506e92740077423a40049aff0c1 | daemon/start_linux.go | daemon/start_linux.go | package daemon
import (
"fmt"
"github.com/docker/docker/container"
"github.com/docker/docker/libcontainerd"
)
func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Container) (*[]libcontainerd.CreateOption, error) {
createOptions := []libcontainerd.CreateOption{}
rt := daemon.configStore.Get... | package daemon
import (
"fmt"
"github.com/docker/docker/container"
"github.com/docker/docker/libcontainerd"
"github.com/docker/engine-api/types"
)
func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Container) (*[]libcontainerd.CreateOption, error) {
createOptions := []libcontainerd.CreateO... | Fix missing container runtime on upgrade | Fix missing container runtime on upgrade
Signed-off-by: Kenfe-Mickael Laventure <10e26728841e39109c2809b6029d4b0763bd81d3@gmail.com>
(cherry picked from commit d7ceda4e375250e6868854cca96c49a369503745)
| Go | apache-2.0 | stainboy/docker,joaofnfernandes/docker.github.io,medallia/docker,thaJeztah/docker.github.io,shubheksha/docker.github.io,joeuo/docker.github.io,menglingwei/denverdino.github.io,BSWANG/denverdino.github.io,thaJeztah/docker.github.io,jzwlqx/denverdino.github.io,denverdino/docker.github.io,medallia/docker,LuisBosquez/docke... |
0f5237af19a4e27adc2f0c84d236db45ba5e2446 | lxd/main_shutdown.go | lxd/main_shutdown.go | package main
import (
"fmt"
"strings"
"time"
"github.com/lxc/lxd/client"
)
func cmdShutdown(args *Args) error {
connArgs := &lxd.ConnectionArgs{
SkipGetServer: true,
}
c, err := lxd.ConnectLXDUnix("", connArgs)
if err != nil {
return err
}
_, _, err = c.RawQuery("PUT", "/internal/shutdown", nil, "")
... | package main
import (
"fmt"
"strings"
"time"
"github.com/lxc/lxd/client"
)
func cmdShutdown(args *Args) error {
connArgs := &lxd.ConnectionArgs{
SkipGetServer: true,
}
c, err := lxd.ConnectLXDUnix("", connArgs)
if err != nil {
return err
}
_, _, err = c.RawQuery("PUT", "/internal/shutdown", nil, "")
... | Fix typo in error handling | lxd/shutdown: Fix typo in error handling
Signed-off-by: Stéphane Graber <089afc6d81f66f1168a9849e15660feae286e024@ubuntu.com>
| Go | apache-2.0 | lxc/lxd,hallyn/lxd,stgraber/lxd,hallyn/lxd,Skarlso/lxd,mjeanson/lxd,jsavikko/lxd,hallyn/lxd,jsavikko/lxd,hallyn/lxd,atxwebs/lxd,Skarlso/lxd,lxc/lxd,mjeanson/lxd,Skarlso/lxd,stgraber/lxd,stgraber/lxd,atxwebs/lxd,stgraber/lxd,Skarlso/lxd,atxwebs/lxd,lxc/lxd,erikmack/lxd,stgraber/lxd,erikmack/lxd,lxc/lxd,lxc/lxd,mjeanson/... |
4109d70086fafaf259a97f325815c4092e5e05a4 | util/util_windows.go | util/util_windows.go | // +build windows
package util
import (
"fmt"
"os"
"os/exec"
"strings"
"github.com/jcelliott/lumber"
"github.com/nanobox-io/nanobox-golang-stylish"
)
// PrivilegeExec runs a command, but assumes your already running as adminsitrator
func PrivilegeExec(command, msg string) {
fmt.Printf(stylish.Bullet(msg))
... | // +build windows
package util
import (
"fmt"
"os"
"os/exec"
"strings"
)
// PrivilegeExec will run the requested command
func PrivilegeExec(command string) error {
// Windows is tricky. Unfortunately we can't just prefix the command with sudo
// Instead, we have to use powershell to create a profile, and then... | Add privilege exec for windows. Needs tested | Add privilege exec for windows. Needs tested
| Go | unknown | pagodabox/nanobox-cli,nanobox-io/nanobox-cli,nanobox-io/nanobox,nanobox-io/nanobox-cli,nanobox-io/nanobox,nanobox-io/nanobox-cli,pagodabox/nanobox-cli |
74a7c5b732080e8827a22a19e42e0c2cfc778231 | example_test.go | example_test.go | // Copyright 2015 Alex Browne and Soroush Pour.
// Allrights reserved. Use of this source code is
// governed by the MIT license, which can be found
// in the LICENSE file.
package router_test
import (
"fmt"
"github.com/go-humble/router"
)
func ExampleRoutes() {
// Create a new Router object
r := router.New()
/... | // Copyright 2015 Alex Browne and Soroush Pour.
// Allrights reserved. Use of this source code is
// governed by the MIT license, which can be found
// in the LICENSE file.
package router_test
import (
"fmt"
"github.com/go-humble/router"
)
func ExampleRouter_HandleFunc() {
// Create a new Router object
r := rout... | Update example to be compatible with godoc | Update example to be compatible with godoc
| Go | mit | go-humble/router,go-humble/router,go-humble/router |
e22c1dac159f40149c5f36c75aa1068097cbf342 | dynatest/executor.go | dynatest/executor.go | package dynatest
import (
"github.com/underarmour/dynago"
"github.com/underarmour/dynago/schema"
)
// A Mock executor
type Executor struct {
}
func (e *Executor) GetItem(*dynago.GetItem) (*dynago.GetItemResult, error) {
return nil, nil
}
func (e *Executor) PutItem(*dynago.PutItem) (*dynago.PutItemResult, error) ... | package dynatest
import (
"github.com/underarmour/dynago"
"github.com/underarmour/dynago/schema"
)
// A Mock executor
type Executor struct {
}
func (e *Executor) BatchWriteItem(*dynago.BatchWrite) (*dynago.BatchWriteResult, error) {
return nil, nil
}
func (e *Executor) GetItem(*dynago.GetItem) (*dynago.GetItemRe... | Make sure we still satisfy Executor | Make sure we still satisfy Executor
| Go | mit | ralph-tice/dynago,underarmour/dynago,crast/dynago |
251ea57f0508249a3117f20adcf971d102acc308 | trustmanager/yubikey/pkcs11_linux.go | trustmanager/yubikey/pkcs11_linux.go | // +build pkcs11,linux
package yubikey
var possiblePkcs11Libs = []string{
"/usr/lib/libykcs11.so",
"/usr/lib64/libykcs11.so",
"/usr/lib/x86_64-linux-gnu/libykcs11.so",
"/usr/local/lib/libykcs11.so",
}
| // +build pkcs11,linux
package yubikey
var possiblePkcs11Libs = []string{
"/usr/lib/libykcs11.so",
"/usr/lib/libykcs11.so.1", // yubico-piv-tool on Fedora installs here
"/usr/lib64/libykcs11.so",
"/usr/lib64/libykcs11.so.1", // yubico-piv-tool on Fedora installs here
"/usr/lib/x86_64-linux-gnu/libykcs11.so",... | Add some filepaths on Fedora where libykcs11 may be found. | Add some filepaths on Fedora where libykcs11 may be found.
Signed-off-by: Trishank K Kuppusamy <ffb584f9ddcd71111a00c49dd75b44f4e2d58746@datadoghq.com>
| Go | apache-2.0 | HuKeping/notary,jfrazelle/notary,endophage/notary,HuKeping/notary,HuKeping/notary,endophage/notary,johnsandiford/notary,johnsandiford/notary,docker/notary,jfrazelle/notary,jfrazelle/notary,docker/notary,johnsandiford/notary,docker/notary,endophage/notary |
a3590026f85d194f6547d537dffc3afe870dadb9 | commands/v2/delete_space_command.go | commands/v2/delete_space_command.go | package v2
import (
"os"
"code.cloudfoundry.org/cli/cf/cmd"
"code.cloudfoundry.org/cli/commands"
"code.cloudfoundry.org/cli/commands/flags"
)
type DeleteSpaceCommand struct {
RequiredArgs flags.Space `positional-args:"yes"`
Force bool `short:"f" description:"Force deletion without confirmation"`
... | package v2
import (
"os"
"code.cloudfoundry.org/cli/cf/cmd"
"code.cloudfoundry.org/cli/commands"
"code.cloudfoundry.org/cli/commands/flags"
)
type DeleteSpaceCommand struct {
RequiredArgs flags.Space `positional-args:"yes"`
Force bool `short:"f" description:"Force deletion without confirmation"`
... | Add delete-space -o flag to V2 command list | Add delete-space -o flag to V2 command list
| Go | apache-2.0 | cloudfoundry/cli,cloudfoundry/cli,cloudfoundry/cli |
9afb59d6299eae6a19c9375e0b378c603e34bcf1 | html.go | html.go | package main
/*
This could probably be smarter, but it'll do for now.
*/
const HTML_STOPPED = `
<html>
<body>
<p>The instances for this service are currently powered down.</p>
<p><a href="%s">Click here</a> to start.</p>
</body>
</html>`
const HTML_STARTING = `
<html>
<body>
<p>Your service is star... | package main
/*
This could probably be smarter, but it'll do for now.
*/
const HTML_STOPPED = `
<html>
<body>
<p>The instances for this service are currently powered down.</p>
<p><a href="%s">Click here</a> to start.</p>
</body>
</html>`
const HTML_STARTING = `
<html>
<script>
setTimeout(function()... | Add auto page refresh when starting/stopping | Add auto page refresh when starting/stopping
| Go | apache-2.0 | fairfaxmedia/flywheel,fairfaxmedia/flywheel |
388f827315841cd9014cedb0350be5d34b15a2f1 | main.go | main.go | package main
import "fmt"
import "os"
import "bufio"
import "strings"
import "time"
import "strconv"
import "flag"
func main() {
dur := flag.Duration("d", time.Second, "duration unit")
flag.Parse()
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line := scanner.Text()
// fmt.Println(line) // Prin... | package main
import "fmt"
import "os"
import "bufio"
import "strings"
import "time"
import "strconv"
import "flag"
func main() {
dur := flag.Duration("d", time.Second, "duration unit")
flag.Parse()
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
line := scanner.Text()
// fmt.Println(line) // Prin... | Support floating point ns/op lines | Support floating point ns/op lines
| Go | apache-2.0 | advincze/benchfmt |
ad1d220703b598324e1fab175188a7c7bea69c45 | main.go | main.go | package main
import (
"./mega"
"./task"
"os"
"fmt"
"log"
"io/ioutil"
)
const MaxWorker = 10
func main() {
if len(os.Args) == 0 {
log.Fatal("Please offer json file.")
}
pool, err := task.CreatePool()
if err != nil {
log.Fatal(err)
}
pool.Registry(task.MegaType, mega.MegaRoot{})
fil... | package main
import (
"./mega"
"./task"
"os"
"fmt"
"log"
"runtime"
"io/ioutil"
)
var MaxWorker int
func init() {
MaxWorker = runtime.NumCPU() << 1
}
func main() {
if len(os.Args) == 0 {
log.Fatal("Please offer json file.")
}
pool, err := task.CreatePool()
if err != nil {
log.Fatal(er... | Create workers base on cpu number. | Create workers base on cpu number.
| Go | mit | lyanchih/FatCat |
d0e5eded1d1207c9123fb9fd6bcbdb8a95975ecd | main.go | main.go | package main
import (
"fmt"
"github.com/zero-boilerplate/go-api-helpers/service"
"path/filepath"
service2 "github.com/ayufan/golang-kardianos-service"
)
type app struct {
logger service2.Logger
watcherDoneChannel chan bool
}
func (a *app) OnStop() {
defer recover()
close(a.watcherDoneChannel)
}
... | package main
import (
"fmt"
"github.com/zero-boilerplate/go-api-helpers/service"
"path/filepath"
service2 "github.com/ayufan/golang-kardianos-service"
)
type app struct {
logger service2.Logger
watcherDoneChannel chan bool
}
func (a *app) OnStop() {
defer recover()
if a.watcherDoneChannel != nil... | Check NIL channel. This will happen if it did not yet get to starting to watch the directory. | Check NIL channel.
This will happen if it did not yet get to starting to watch the directory.
| Go | mit | golang-devops/script-watcher-service |
a8e6a862695e21e290452f3edd6eea69035c93e0 | main.go | main.go | package main
import (
"os"
"github.com/albertyw/reaction-pics/server"
"github.com/joho/godotenv"
newrelic "github.com/newrelic/go-agent"
"github.com/rollbar/rollbar-go"
)
func setupEnv() {
err := godotenv.Load()
if err != nil {
panic(err)
}
}
func getNewRelicApp() newrelic.Application {
newrelicKey := os... | package main
import (
"os"
"github.com/albertyw/reaction-pics/server"
"github.com/joho/godotenv"
newrelic "github.com/newrelic/go-agent"
"github.com/rollbar/rollbar-go"
)
func setupEnv() {
err := godotenv.Load()
if err != nil {
panic(err)
}
}
func getNewRelicApp() newrelic.Application {
newrelicKey := os... | Make sure rollbar is setup correctly | Make sure rollbar is setup correctly
| Go | mit | albertyw/devops-reactions-index,albertyw/reaction-pics,albertyw/reaction-pics,albertyw/reaction-pics,albertyw/devops-reactions-index,albertyw/reaction-pics,albertyw/devops-reactions-index,albertyw/devops-reactions-index |
90fe73895f36227c0b2fa6c3425d881cfc4dd118 | main.go | main.go | package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/context"
)
func main() {
app := iris.New()
app.Handle("GET", "/", func(ctx context.Context) {
ctx.Writef("hello world\n")
})
app.Run(iris.Addr(":8080"))
}
| package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/context"
"github.com/kataras/iris/view"
)
func main() {
app := iris.New()
// load the ./templates/**.html
templates := view.HTML("./templates", ".html"))
app.AttachView(templates)
app.Handle("GET", "/", func(ctx context.Context) {
... | Update and make use of the existing templates folder | Update and make use of the existing templates folder | Go | mpl-2.0 | nanobox-quickstarts/nanobox-iris,nanobox-quickstarts/nanobox-iris |
e57f074c58412931ede1d6bc7dab7289b28c5189 | harm.go | harm.go | package main
import "time"
// Standards for the result by launching a Missile
type Harm struct {
code int `json:"code"`
timestamp time.Time `json:"timestamp"`
latency time.Duration `json:"latency"`
bytesOut uint64 `json:"bytes_out"`
bytesIn uint64 `json:"bytes_in... | package main
import "time"
// Standards for the result by launching a Missile
type Harm struct {
startTime time.Time `json:"start_time"`
endTime time.Time `json:"end_time"`
statusCode int `json:"status_code"`
timestamp time.Time `json:"timestamp"` // When a tick occur
latency tim... | Add startTime,endTime and change some variables name | Add startTime,endTime and change some variables name
| Go | apache-2.0 | proliming/boom |
9795383dfcc060cde178ea887a80f921f99adac8 | main.go | main.go | // Webserver
package main
import (
"fmt"
"gopkg.in/gcfg.v1"
"log"
"net/http"
"os"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome, %s!", r.URL.Path[1:])
}
type config struct {
Main struct {
Port string
}
}
func getConfig() config {
cfg := new(config)
err := gcfg.ReadFil... | // Webserver
package main
import (
"flag"
"fmt"
"gopkg.in/gcfg.v1"
"log"
"net/http"
)
var configFile = flag.String("config", "/etc/bobbi.conf", "INI file for bobbi")
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Welcome, %s!", r.URL.Path[1:])
}
type config struct {
Main struct {
Po... | Read from a specified config file. | Read from a specified config file.
| Go | mit | davedash/bobbi |
7abb09ef80595f68a840166dc336483aebdbdd66 | main.go | main.go | package main
import (
"github.com/hashicorp/terraform/plugin"
"github.com/jayhding/terraform-provider-pingdom/pingdom"
)
func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: pingdom.Provider,
})
}
| package main
import (
"github.com/hashicorp/terraform/plugin"
"github.com/russellcardullo/terraform-provider-pingdom/pingdom"
)
func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: pingdom.Provider,
})
}
| Change upstream repo back for pull request | Change upstream repo back for pull request
| Go | mit | russellcardullo/terraform-provider-pingdom,russellcardullo/terraform-provider-pingdom |
5633dd800380d4f62fde64b5f527a1826628e31f | maps.go | maps.go | package flagx
import (
"fmt"
"reflect"
"strings"
)
func Map(m interface{}, parseValue func(string) (interface{}, error)) Value {
v := reflect.ValueOf(m)
if v.IsNil() || v.Kind() != reflect.Map {
panic("non-nil pointer to a map expected")
}
// check that keys are strings
if v.Type().Key().Kind() != reflect.S... | package flagx
import (
"fmt"
"reflect"
"strings"
)
func Map(m interface{}, parseValue func(string) (interface{}, error)) Value {
v := reflect.ValueOf(m)
if v.IsNil() || v.Kind() != reflect.Map {
panic("non-nil pointer to a map expected")
}
// check that keys are strings
if v.Type().Key().Kind() != reflect.S... | Fix typo in Map error handling | Fix typo in Map error handling
| Go | apache-2.0 | dolmen-go/flagx |
e2a18a2283a462746b649c25bdcc349b8ac51aab | app/service_events.go | app/service_events.go | package app
import termbox "github.com/nsf/termbox-go"
type servicesScreenEventHandler struct {
baseEventHandler
}
func (h *servicesScreenEventHandler) handle(event termbox.Event) {
handled := false
switch event.Key {
case termbox.KeyEnter:
showServices := func(serviceID string) error {
h.dry.ShowServiceTa... | package app
import termbox "github.com/nsf/termbox-go"
type servicesScreenEventHandler struct {
baseEventHandler
}
func (h *servicesScreenEventHandler) handle(event termbox.Event) {
handled := false
switch event.Key {
case termbox.KeyEnter:
showServices := func(serviceID string) error {
h.dry.ShowServiceTa... | Add event handler for service tasks screen | Add event handler for service tasks screen
| Go | mit | moncho/dry,moncho/dry |
e9676ee86243fe29fb650d211978d1b3ce50ed73 | main.go | main.go | /*
http://www.apache.org/licenses/LICENSE-2.0.txt
Copyright 2015 Intel Coporation
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 b... | /*
http://www.apache.org/licenses/LICENSE-2.0.txt
Copyright 2015 Intel Coporation
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 b... | Update import path for influx package | Update import path for influx package
| Go | apache-2.0 | intelsdi-x/snap-plugin-publisher-influxdb,intelsdi-x/snap-plugin-publisher-influxdb,intelsdi-x/snap-plugin-publisher-influxdb |
ee12a031a901bd04ee0b1db7743e3b128cd48630 | main.go | main.go | package main
import (
"context"
"flag"
"log"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/terraform-providers/terraform-provider-null/internal/provider"
)
// Run "go generate" to format example terraform files and generate the docs for the registry/website
// If you do not have... | package main
import (
"context"
"flag"
"log"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/terraform-providers/terraform-provider-null/internal/provider"
)
// Run "go generate" to format example terraform files and generate the docs for the registry/website
// If you do not have... | Correct the registry address for the provider server | Correct the registry address for the provider server
| Go | mpl-2.0 | hashicorp/terraform-provider-null,hashicorp/terraform-provider-null,terraform-providers/terraform-provider-null,terraform-providers/terraform-provider-null |
57097f0da80f64b893640411f87d77d1c381bc2d | helpers/app_helpers/app_helpers.go | helpers/app_helpers/app_helpers.go | package app_helpers
import (
"strings"
"time"
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
func guidForAppName(appName string) string {
cfApp := cf.Cf("app", appName, "--guid")
... | package app_helpers
import (
"strings"
"time"
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
)
func guidForAppName(appName string) string {
cfApp := cf.Cf("app", appName, "--guid")
... | Replace UseDiego config with Backend. | Replace UseDiego config with Backend.
[#106033010]
Signed-off-by: Natalie J. Bennett <e5fc036b158c983344048075b2b1e5c6083fede5@pivotal.io>
| Go | apache-2.0 | matt-royal/cf-acceptance-tests,matt-royal/cf-acceptance-tests,matt-royal/cf-acceptance-tests,matt-royal/cf-acceptance-tests,matt-royal/cf-acceptance-tests,matt-royal/cf-acceptance-tests,matt-royal/cf-acceptance-tests,matt-royal/cf-acceptance-tests |
46978136e3c8e3f19603e13f3a939fa666405a39 | main.go | main.go | package main
import (
"flag"
"fmt"
"os"
log "github.com/cihub/seelog"
)
var (
flagSet = flag.NewFlagSet("kraken", flag.ExitOnError)
target = flagSet.String("target", "", "target URL to crawl")
)
func main() {
// Process flags
flagSet.Parse(os.Args[1:])
// Flush logs before exit
defer log.Flush()
// Do... | package main
import (
"flag"
"fmt"
"os"
log "github.com/cihub/seelog"
)
var (
flagSet = flag.NewFlagSet("kraken", flag.ExitOnError)
target = flagSet.String("target", "", "target URL to crawl")
)
func main() {
// Process flags
flagSet.Parse(os.Args[1:])
// Flush logs before exit
defer log.Flush()
// Do... | Fix debug log of target url | Fix debug log of target url
| Go | mit | mattheath/kraken |
acb8df5c0053dceb9f37b235ad38c231e2736576 | main.go | main.go | // Copyright 2017 Auburn University and others. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// The godoctor command refactors Go code.
package main
import (
"fmt"
"os"
"github.com/godoctor/godoctor/engine/cli"
)
// Name of the refac... | // Copyright 2017-2018 Auburn University and others. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// The godoctor command refactors Go code.
package main
import (
"fmt"
"os"
"github.com/godoctor/godoctor/engine/cli"
)
// Name of the ... | Update version number to 0.6 | Update version number to 0.6
| Go | bsd-3-clause | godoctor/godoctor |
2fdb6907e6b959e6257e086604f84a905d9c6ac7 | main.go | main.go | package main
import (
flags "github.com/jessevdk/go-flags"
"github.com/monochromegane/the_platinum_searcher/search"
"github.com/monochromegane/the_platinum_searcher/search/option"
"os"
"runtime"
)
var opts option.Option
func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
}
func main() {
args, _ := flags.Pars... | package main
import (
"code.google.com/p/go.crypto/ssh/terminal"
flags "github.com/jessevdk/go-flags"
"github.com/monochromegane/the_platinum_searcher/search"
"github.com/monochromegane/the_platinum_searcher/search/option"
"os"
"runtime"
)
var opts option.Option
func init() {
runtime.GOMAXPROCS(runtime.NumCPU... | Print results with no color and no group if stdout isn't tty. | Print results with no color and no group if stdout isn't tty.
| Go | mit | cmars/tools,syohex/the_platinum_searcher,tw4452852/the_platinum_searcher,cmars/tools,cmars/tools,cmars/tools,aeruder/the_platinum_searcher,thomasf/the_platinum_searcher,yuya-takeyama/the_platinum_searcher,drmohundro/the_platinum_searcher,DaSea/the_platinum_searcher,monochromegane/the_platinum_searcher |
d4374fa7036a78487c7dc79c55b77ffcd4d3ee5b | file.go | file.go | package scipipe
import (
"os"
"time"
)
type FileTarget struct {
path string
}
func NewFileTarget(path string) *FileTarget {
ft := new(FileTarget)
ft.path = path
return ft
}
func (ft *FileTarget) GetPath() string {
return ft.path
}
func (ft *FileTarget) GetTempPath() string {
return ft.path + ".tmp"
}
func... | package scipipe
import (
"os"
"time"
)
type FileTarget struct {
path string
}
func NewFileTarget(path string) *FileTarget {
ft := new(FileTarget)
ft.path = path
return ft
}
func (ft *FileTarget) GetPath() string {
return ft.path
}
func (ft *FileTarget) GetTempPath() string {
return ft.path + ".tmp"
}
func... | Implement Exists() method on FileTarget | Implement Exists() method on FileTarget
| Go | mit | scipipe/scipipe,scipipe/scipipe,samuell/scipipe |
55ddd24e0357d733b321872fda8b183025f6a2c4 | main.go | main.go | package main
import (
"fmt"
"github.com/rancher/convoy/api"
"github.com/rancher/convoy/client"
"os"
)
const (
// version of Convoy
VERSION = "0.4.3"
)
func cleanup() {
if r := recover(); r != nil {
api.ResponseLogAndError(r)
os.Exit(1)
}
}
func main() {
defer cleanup()
cli := client.NewCli(VERSION)
... | package main
import (
"fmt"
"github.com/rancher/convoy/api"
"github.com/rancher/convoy/client"
"os"
)
const (
// version of Convoy
VERSION = "0.4.4-dev"
)
func cleanup() {
if r := recover(); r != nil {
api.ResponseLogAndError(r)
os.Exit(1)
}
}
func main() {
defer cleanup()
cli := client.NewCli(VERSIO... | Update Convoy version to 0.4.4-dev | Update Convoy version to 0.4.4-dev
| Go | apache-2.0 | rancher/rancher-volume,rancher/convoy,medallia/convoy,rancherio/volmgr,rancher/convoy,rancherio/volmgr,medallia/convoy,jinuxstyle/convoy,rancherio/rancher-volume,rancher/rancher-volume,nickvanw/convoy,nickvanw/convoy,jinuxstyle/convoy,rancherio/volmgr,nickvanw/convoy,rancher/rancher-volume,rancherio/rancher-volume,ranc... |
3783a0fcb697a882f65e32e6da0af788dc9a9033 | main.go | main.go | package main
import "net/http"
func main() {
http.HandleFunc("/hostname", hostnameHandler)
http.HandleFunc("/time", timeHandler)
http.HandleFunc("/issue", issueHandler)
http.ListenAndServe(":3000", nil)
}
func hostnameHandler(w http.ResponseWriter, r *http.Request) {
hostname, err := hostname()
if err != nil {... | package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/hostname", hostnameHandler)
http.HandleFunc("/time", timeHandler)
http.HandleFunc("/issue", issueHandler)
fmt.Println("Serving on port 3000...")
http.ListenAndServe(":3000", nil)
}
func hostnameHandler(w http.ResponseWriter, r *http.Requ... | Add print statement to indicate server is running | Add print statement to indicate server is running
| Go | mit | adelq/go-dash |
c73e397fc5c6b75ae69dbc78719a944187a15724 | cmd/starbound/main.go | cmd/starbound/main.go | package main
import (
"fmt"
"os"
"github.com/blixt/go-starbound/starbound"
"golang.org/x/exp/mmap"
)
func main() {
file, err := mmap.Open("../../test.world")
if err != nil {
fmt.Printf("failed to open world: %v\n", err)
os.Exit(1)
}
db, err := starbound.NewBTreeDB5(file)
if err != nil {
fmt.Printf("fa... | package main
import (
"fmt"
"os"
"github.com/blixt/go-starbound/starbound"
"golang.org/x/exp/mmap"
)
func main() {
file, err := mmap.Open("../../test.world")
if err != nil {
fmt.Printf("failed to open world: %v\n", err)
os.Exit(1)
}
w, err := starbound.NewWorld(file)
if err != nil {
fmt.Printf("failed... | Use GetRegion in dummy command line tool | Use GetRegion in dummy command line tool
| Go | mit | blixt/go-starbound |
9c58f02a986e0a263cb184459fd8a98e308018aa | redis/client.go | redis/client.go | package redis
import (
"log"
"time"
redis "github.com/go-redis/redis"
try "github.com/matryer/try"
)
// ConnectToClient Connects to a Redis server
func ConnectToClient(ip string, port string, config Config) *redis.Client {
client := redis.NewClient(&redis.Options{
Addr: ip + ":" + port,
})
return client
}
... | package redis
import (
"log"
"time"
redis "github.com/go-redis/redis"
try "github.com/matryer/try"
)
// ConnectToClient Connects to a Redis server
func ConnectToClient(ip string, port string, config Config) *redis.Client {
client := redis.NewClient(&redis.Options{
Addr: ip + ":" + port,
})
return client
}
... | Fix logic around what constitutes a connection failure | Fix logic around what constitutes a connection failure
| Go | mit | cooperaj/sentinel-broker,cooperaj/sentinel-broker |
5ce24b06479a4818d826a77e32f2c6ff970d84e8 | main.go | main.go | package main
import (
"fmt"
"github.com/localghost/packer-pp/parser"
"os"
"encoding/json"
)
func main() {
templatePath := os.Args[1]
result, err := parser.ParseFile(templatePath)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %s\n", err.Error())
}
json.NewEncoder(os.Stdout).Encode(result)
}
| package main
import (
"fmt"
"github.com/localghost/ppp/parser"
"os"
"encoding/json"
)
func main() {
templatePath := os.Args[1]
result, err := parser.ParseFile(templatePath)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: %s\n", err.Error())
}
json.NewEncoder(os.Stdout).Encode(result)
}
| Fix path to parser package. | Fix path to parser package.
| Go | apache-2.0 | localghost/ppp |
e2c734b8518275eeb74661de28966a00b9b6c212 | walk.go | walk.go | package hdfs
import (
"os"
"path/filepath"
"sort"
)
// Walk walks the file tree rooted at root, calling walkFn for each file or
// directory in the tree, including root. All errors that arise visiting files
// and directories are filtered by walkFn. The files are walked in lexical
// order, which makes the output ... | package hdfs
import (
"os"
"path/filepath"
"sort"
)
// Walk walks the file tree rooted at root, calling walkFn for each file or
// directory in the tree, including root. All errors that arise visiting files
// and directories are filtered by walkFn. The files are walked in lexical
// order, which makes the output ... | Join using regular separators on the client, not OS-specific ones | Join using regular separators on the client, not OS-specific ones
| Go | mit | colinmarc/hdfs,ashishgandhi/hdfs,ashishgandhi/hdfs,colinmarc/hdfs |
06a6e5bf89d5cfac5330a538395de230489e2d43 | sack/helpers.go | sack/helpers.go | package sack
import (
"fmt"
"io/ioutil"
"path"
"strings"
)
func checkState() {}
func splitLine(s string) []string {
arr := strings.SplitN(s, ":", 3)
return arr
}
func check(e error) {
if e != nil {
fmt.Printf("\n----\nError: %#v\n----\n", e)
panic(e)
}
}
func content() []string {
filePath := path.Join... | package sack
import (
"fmt"
"io/ioutil"
"path"
"strings"
)
func checkState() {}
func splitLine(s string) []string {
arr := strings.SplitN(s, ":", 3)
return arr
}
func check(e error) {
if e != nil {
fmt.Printf("\n----\nError: %#v\n----\n", e)
panic(e)
}
}
func content() []string {
filePath := path.Join... | Improve error message for no shortcut file | Improve error message for no shortcut file
| Go | mit | zph/go-sack,zph/go-sack |
2a03acf57b089739bfa89e9bf7941c1d8691be5b | src/interfaces/storage_engine.go | src/interfaces/storage_engine.go | package interfaces
import (
"time"
)
type WriteRequest struct {
Timeseries []*Timeseries
}
type Operation int
const (
EqualOperation Operation = iota
NotEqualOperation
GreaterThanOperation
GreaterThanOrEqualOperation
LessThanOperation
LessThanOrEqualOperation
)
type Condition interface {
IsCondition()
}
... | package interfaces
import (
"protocol"
"time"
)
type WriteRequest struct {
Timeseries []*protocol.Series
}
type Operation int
const (
EqualOperation Operation = iota
NotEqualOperation
GreaterThanOperation
GreaterThanOrEqualOperation
LessThanOperation
LessThanOrEqualOperation
)
type Condition interface {
... | Fix the storage engine interface to build with things in protocol | Fix the storage engine interface to build with things in protocol
| Go | mit | n1tr0g/influxdb,runner-mei/influxdb,arussellsaw/influxdb,ASAPPinc/influxdb,brunoqc/influxdb,121watts/influxdb,bluebreezecf/influxdb,rabdureh/influx-attempt,slachiewicz/influxdb,mcanthony/influxdb,cnelissen/influxdb,mnuessler/influxdb,jgeiger/influxdb,hyperworks/influxdb,pkittenis/influxdb,radcheb/influxdb,ninjasphere/i... |
e5f6adcc395b857049c6e59f8fc43fdcac25b54c | config/config_test.go | config/config_test.go | package config
import (
"github.com/ghthor/gospec"
. "github.com/ghthor/gospec"
"testing"
)
func TestUnitSpecs(t *testing.T) {
r := gospec.NewRunner()
r.AddSpec(DescribeConfigLoading)
gospec.MainGoTest(r, t)
}
func DescribeConfigLoading(c gospec.Context) {
c.Specify("Config can be parsed from json file", fu... | package config
import (
"github.com/ghthor/gospec"
. "github.com/ghthor/gospec"
"testing"
)
func TestSpecs(t *testing.T) {
r := gospec.NewRunner()
r.AddSpec(DescribeConfigLoading)
gospec.MainGoTest(r, t)
}
func DescribeConfigLoading(c gospec.Context) {
c.Specify("Config can be parsed from json file", func()... | Change the name the test's are closer to integration | But they are both unit+integration cause the package is so simple | Change the name the test's are closer to integration
| But they are both unit+integration cause the package is so simple
| Go | mit | ghthor/journal |
f547e0213673ade08198e5d7217d558e4c6ca502 | chain.go | chain.go | // Copyright (c) 2016, Janoš Guljaš <janos@resenje.org>
// All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package httputils // import "resenje.org/httputils"
import "net/http"
// ChainHandlers executes each function from the arguments with... | // Copyright (c) 2016, Janoš Guljaš <janos@resenje.org>
// All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package httputils // import "resenje.org/httputils"
import "net/http"
// ChainHandlers executes each function from the arguments with... | Remove unused variable from FinalHandler and FinalHandlerFunc | Remove unused variable from FinalHandler and FinalHandlerFunc
| Go | bsd-3-clause | janos/web,janos/httputils |
c2ac2510d61a7e5d6c8faa4d8b8c80da3df3240b | util.go | util.go | package kala
import (
"math/big"
"net"
)
func MacAddressToWorkerId(mac string) (int64, error) {
hw, err := net.ParseMAC(mac)
if err != nil {
return 0, err
}
workerId := new(big.Int).SetBytes([]byte(hw)).Int64()
return workerId, nil
}
| package kala
import (
"math/big"
"net"
)
func MacAddressToWorkerId(mac string) (uint64, error) {
hw, err := net.ParseMAC(mac)
if err != nil {
return 0, err
}
workerId := new(big.Int).SetBytes([]byte(hw)).Uint64()
return workerId, nil
}
| Return worker id as uint when converting from mac address | Return worker id as uint when converting from mac address
| Go | mit | mattheath/kala |
af3e52eb0c2eec8c43865530e4b55c88a095b54a | sync.go | sync.go | package main
import (
"net/http"
"github.com/Felamande/filesync/syncer"
)
func main() {
syncer.New().Run()
http.ListenAndServe(":8070", nil)
} | package main
import (
"net/http"
"github.com/Felamande/filesync/log"
"github.com/go-martini/martini"
"github.com/Felamande/filesync/syncer"
)
func main() {
s := syncer.New()
m := martini.Classic()
l := log.NewFileLogger("./.log/http.log")
m.Map(s)
m.Map(l)
m.Post("/new", NewPair)
m.Get("/new", HelloNewPa... | Test http server powered by martini | Test http server powered by martini
| Go | mit | Felamande/filesync,Felamande/filesync |
dc42c25aa7bf9fc2136277b740848b29891a625c | util.go | util.go | package main
import (
"reflect"
)
func walkStruct(s interface{}, f func(string, reflect.Value) error) error {
var inner func(v reflect.Value, p string) error
inner = func(v reflect.Value, p string) error {
t := v.Type()
for i := 0; i < v.NumField(); i++ {
name := t.Field(i).Name
if (name[0] < 'A') || (na... | package main
import (
"reflect"
)
// walkStruct walks through a struct and all sub-structs recustively,
// calling f on all 'leaf' fields. The first argument to f is the name
// of the field in the form parent.field, and the second argument is
// the field itself. If any call to f returns non-nil error,
// walkStruc... | Add godoc comment to walkStruct(). | Add godoc comment to walkStruct().
| Go | mit | DeedleFake/ps2avglogin |
6b83eba8f5148f97f6fb7a31b25bfd24b2d7fa98 | berlingo/ai1.go | berlingo/ai1.go | package main
import (
"fmt"
"github.com/minaguib/berlingo"
"math/rand"
)
/*
This example mimicks the functionality in the berlin-ai demo ruby gem at:
https://github.com/thirdside/berlin-ai/
*/
type AI1 struct{}
func (ai *AI1) GameStart(game *berlingo.Game) {
}
func (ai *AI1) Turn(game *berlingo.Game) {
for _, ... | package main
import (
"fmt"
"github.com/minaguib/berlingo"
"math/rand"
)
/*
This example mimicks the functionality in the berlin-ai demo ruby gem at:
https://github.com/thirdside/berlin-ai/
*/
type AI1 struct{}
func (ai *AI1) GameStart(game *berlingo.Game) {
}
func (ai *AI1) Turn(game *berlingo.Game) {
for _, ... | Fix occasional crash due to calling rand.Intn(0) | Fix occasional crash due to calling rand.Intn(0)
| Go | mit | minaguib/berlingo |
9aabba009b7acb2d6782f3ddf33928b9239e7185 | internal/storage/storage.go | internal/storage/storage.go | package storage
import (
"github.com/rafaeljusto/toglacier/internal/archive"
"github.com/rafaeljusto/toglacier/internal/cloud"
)
// Backup stores the cloud location of the backup and some extra information
// about the files of the backup.
type Backup struct {
Backup cloud.Backup
Info archive.Info
}
// Backups... | package storage
import (
"github.com/rafaeljusto/toglacier/internal/archive"
"github.com/rafaeljusto/toglacier/internal/cloud"
)
// Backup stores the cloud location of the backup and some extra information
// about the files of the backup.
type Backup struct {
Backup cloud.Backup // TODO: rename this attribute?
I... | Add reminder to improve the code | Add reminder to improve the code
See #12
| Go | mit | rafaeljusto/toglacier,rafaeljusto/toglacier,rafaeljusto/toglacier |
4d16daa8c0b30c1c85e3eeaf9e181f88d0b0092f | utils.go | utils.go | package funk
import "reflect"
func equal(expected, actual interface{}) bool {
if expected == nil || actual == nil {
return expected == actual
}
return reflect.DeepEqual(expected, actual)
}
func sliceElem(rtype reflect.Type) reflect.Type {
if rtype.Kind() == reflect.Slice || rtype.Kind() == reflect.Array {
... | package funk
import "reflect"
func equal(expected, actual interface{}) bool {
if expected == nil || actual == nil {
return expected == actual
}
return reflect.DeepEqual(expected, actual)
}
func sliceElem(rtype reflect.Type) reflect.Type {
for {
if rtype.Kind() != reflect.Slice && rtype.Kind() != reflect.Ar... | Fix redirectValue for circular type | Fix redirectValue for circular type
| Go | mit | thoas/go-funk,thoas/go-fn |
012cadf304c98bb0658c67f6a71187ab47ad6e3e | main.go | main.go | package feeds
import (
"net/http"
"github.com/gorilla/mux"
"github.com/rs/cors"
"google.golang.org/appengine"
)
func Run() {
dao := datastoreFeedsDao{}
router := mux.NewRouter()
router.Handle("/feeds", cors.Default().Handler(getFeedsHandler{dao})).
Methods(http.MethodGet)
getHandler := cors.Default().Han... | package feeds
import (
"net/http"
"github.com/gorilla/mux"
"github.com/rs/cors"
"google.golang.org/appengine"
)
func Run() {
dao := datastoreFeedsDao{}
router := mux.NewRouter()
corsHandler := cors.New(cors.Options{
AllowedHeaders:{"Location"},
})
router.Handle("/feeds", corsHandler(getFeedsHandler{dao})... | Add CORS handler for Location header | Add CORS handler for Location header
| Go | mit | mhaligowski/paperboy-feeds |
cd64363ec9a115a3bb216366966e1dd3c167b157 | app/df_events.go | app/df_events.go | package app
import termbox "github.com/nsf/termbox-go"
type dfScreenEventHandler struct {
baseEventHandler
}
func (h *dfScreenEventHandler) handle(event termbox.Event) {
h.setFocus(true)
}
| package app
import (
"github.com/moncho/dry/appui"
termbox "github.com/nsf/termbox-go"
)
const (
confirmation = `WARNING! This will remove all unused data. Are you sure you want to continue? [y/N]`
)
type diskUsageScreenEventHandler struct {
baseEventHandler
}
func (h *diskUsageScreenEventHandler) handle(event ... | Add event handler for df screen | Add event handler for df screen
| Go | mit | moncho/dry,moncho/dry |
3125d02cf6b842700239ca67ef5b7f96951d28b7 | src/xmpp/dns.go | src/xmpp/dns.go | package xmpp
import (
"fmt"
"net"
)
const (
// Standard port for XMPP clients to connect to.
XMPP_CLIENT_PORT = 5222
)
// Perform a DNS SRV lookup and return an ordered list of "host:port" TCP
// addresses for the JID's home server. If no SRV records are found then assume
// the JID's domain is also the home ser... | package xmpp
import (
"fmt"
"net"
"strings"
)
const (
// Standard port for XMPP clients to connect to.
XMPP_CLIENT_PORT = 5222
)
// Perform a DNS SRV lookup and return an ordered list of "host:port" TCP
// addresses for the JID's home server. If no SRV records are found then assume
// the JID's domain is also t... | Remove useless function that already exist in strings pakage. | Remove useless function that already exist in strings pakage.
| Go | mit | emgee/go-xmpp |
9f19c43865ba14a5c6ddf72c31aa6162b5f45802 | auth/bitbucket/user_verifier.go | auth/bitbucket/user_verifier.go | package bitbucket
import (
"code.cloudfoundry.org/lager"
api "github.com/SHyx0rmZ/go-bitbucket/bitbucket"
"github.com/concourse/atc/auth/verifier"
"net/http"
)
type UserVerifier struct {
users []string
client api.Client
}
func NewUserVerifier(client api.Client, users []string) verifier.Verifier {
return User... | package bitbucket
import (
"code.cloudfoundry.org/lager"
api "github.com/SHyx0rmZ/go-bitbucket/bitbucket"
"github.com/concourse/atc/auth/verifier"
"net/http"
)
type UserVerifier struct {
users []string
client api.Client
}
func NewUserVerifier(client api.Client, users []string) verifier.Verifier {
return User... | Set HTTP client in UserVerifier | Set HTTP client in UserVerifier
| Go | apache-2.0 | concourse/concourse,concourse/concourse,concourse/concourse,concourse/concourse,concourse/concourse |
d8bc0b730b4d0f260ccd639411f735f0d84827cb | util/randomword/generator_test.go | util/randomword/generator_test.go | package randomword_test
import (
"time"
. "code.cloudfoundry.org/cli/util/randomword"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Generator", func() {
var gen Generator
BeforeEach(func() {
gen = Generator{}
})
Describe("RandomAdjective", func() {
It("generates a random ad... | package randomword_test
import (
"time"
. "code.cloudfoundry.org/cli/util/randomword"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Generator", func() {
var gen Generator
BeforeEach(func() {
gen = Generator{}
})
Describe("RandomAdjective", func() {
It("generates a random ad... | Fix flakiness from random seed generator | Fix flakiness from random seed generator
Signed-off-by: Sebastian Vidrio <68ba84219e4e2d7d15fed3ed668bd2821314e420@pivotal.io>
| Go | apache-2.0 | cloudfoundry/cli,cloudfoundry/cli,cloudfoundry/cli |
533a3487dcecc0c2df2dfd1bf0310bebc1286ef5 | services/slack_api.go | services/slack_api.go | package services
import (
"os"
"fmt"
"net/http"
"encoding/json"
"github.com/jmoiron/jsonq"
"strconv"
)
const (
slackUserListURL = "https://slack.com/api/users.list"
)
func SlackUserList() (map[string]string, error){
token := os.Getenv("SLACK_API_TOKEN")
if token == "" {
return nil, fmt.Errorf("You need to... | package services
import (
"os"
"fmt"
"net/http"
"encoding/json"
"strconv"
"github.com/jmoiron/jsonq"
)
const (
slackUserListURL = "https://slack.com/api/users.list"
)
func SlackUserList() (map[string]string, error){
token := os.Getenv("SLACK_API_TOKEN")
if token == "" {
return nil, fmt.Errorf("You need t... | Reorder import in slack service | Reorder import in slack service
| Go | mit | wantedly/developers-account-mapper |
1c29c8448f0a6b9f1b94bd2c76c0bfe34ad018e5 | src/chunkymonkey/command/command.go | src/chunkymonkey/command/command.go | package command
// A CommandCallback takes the name of the player invoking the command, any
// text supplied after the trigger for the command, and an interface via which
// game-wide 'actions' can be taken.
type CommandCallback func(string, string, ICommandHandler)
type Command struct {
Trigger string ... | package command
// A CommandCallback takes the name of the player invoking the command, any
// text supplied after the trigger for the command, and an interface via which
// game-wide 'actions' can be taken.
type CommandCallback func(playerName string, args string, handler ICommandHandler)
type Command struct {
Trig... | Add parameter names to CommandCallback | Add parameter names to CommandCallback
| Go | mit | huin/chunkymonkey,huin/chunkymonkey |
d7d429e4ad4063ee3afde696ef363ce49941b434 | resources/cloudwatchevents-rules.go | resources/cloudwatchevents-rules.go | package resources
import (
"fmt"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cloudwatchevents"
)
func init() {
register("CloudWatchEventsRule", ListCloudWatchEventsRules)
}
func ListCloudWatchEventsRules(sess *session.Session) ([]Resource, error) {
svc := cloudwatchevents.New(ses... | package resources
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/cloudwatchevents"
)
func init() {
register("CloudWatchEventsRule", ListCloudWatchEventsRules)
}
func ListCloudWatchEventsRules(sess *session.Session) ([]Resource, error) {... | Add Force flag to CW events rule deletion | Add Force flag to CW events rule deletion
Use aws.Bool
Adding ec2-launch-templates resource file
Add --quiet flag to remove filtered resources from output
Without this change, output showing what is (or will be) removed can
easily be lost on the output showing filtered resources. It's useful
to be able to just see... | Go | mit | rebuy-de/aws-nuke,rebuy-de/aws-nuke |
97070aceb9df2dfc4a987290d1d9340df3fe31bf | turnservicecli/data.go | turnservicecli/data.go | package turnservicecli
// CredentialsResponse defines a REST response containing TURN data.
type CredentialsResponse struct {
Success bool `json:"success"`
Nonce string `json:"nonce"`
Turn *CredentialsData `json:"turn"`
Session string `json:"session,omitempty"`
}
// Credential... | package turnservicecli
import (
"time"
)
// CredentialsResponse defines a REST response containing TURN data.
type CredentialsResponse struct {
Success bool `json:"success"`
Nonce string `json:"nonce"`
Expires *time.Time `json:"expires,omitempty"`
Turn *CredentialsData `json:"tur... | Return optional field when access token / client id will expire. | Return optional field when access token / client id will expire.
| Go | agpl-3.0 | strukturag/spreed-turnservicecli |
71fba5cf9d831f08fb10ba70cc5056e5b73be852 | oauth.go | oauth.go | package slack
import (
"errors"
"net/url"
)
type oAuthResponseFull struct {
AccessToken string `json:"access_token"`
Scope string `json:"scope"`
SlackResponse
}
// GetOAuthToken retrieves an AccessToken
func GetOAuthToken(clientID, clientSecret, code, redirectURI string, debug bool) (accessToken string, s... | package slack
import (
"errors"
"net/url"
)
type OAuthResponseIncomingWebhook struct {
URL string `json:"url"`
Channel string `json:"channel"`
ConfigurationURL string `json:"configuration_url"`
}
type OAuthResponseBot struct {
BotUserID string `json:"bot_user_id"`
BotAccessToken str... | Support full OAauth response (for adding hooks and bot users via OAuth) | Support full OAauth response (for adding hooks and bot users via OAuth)
| Go | bsd-2-clause | nlopes/slack,178inaba/slack,james-lawrence/slack |
e90c725c93b67140d8ae6f2acc0355790d405bae | commands/out.go | commands/out.go | package commands
import (
"fmt"
"github.com/spf13/cobra"
)
var outCmd = &cobra.Command{
Use: "out",
Short: "Write a file based on key data.",
Long: `out is for writing a file based on a Consul key.`,
Run: outRun,
}
func outRun(cmd *cobra.Command, args []string) {
checkFlags()
}
func checkFlags() {
if K... | package commands
import (
"fmt"
"github.com/spf13/cobra"
"os"
)
var outCmd = &cobra.Command{
Use: "out",
Short: "Write a file based on key data.",
Long: `out is for writing a file based on a Consul key.`,
Run: outRun,
}
func outRun(cmd *cobra.Command, args []string) {
checkFlags()
}
func checkFlags() {... | Exit the command if it doesn't have the right flags. | Exit the command if it doesn't have the right flags.
| Go | apache-2.0 | DataDog/kvexpress,DataDog/kvexpress,DataDog/kvexpress |
5471b65cb50373a11f95e1c24b9ea705a906bce9 | const.go | const.go | package scipipe
const (
// BUFSIZE is the standard buffer size used for channels connecting processes
BUFSIZE = 16
// Version is the SciPipe version in string format
Version = "0.8"
)
| package scipipe
const (
// BUFSIZE is the standard buffer size used for channels connecting processes
BUFSIZE = 16
// Version is the SciPipe version in string format
Version = "0.8.1"
)
| Update version string (need better approach for releasing versions) | Update version string (need better approach for releasing versions)
| Go | mit | scipipe/scipipe,scipipe/scipipe,samuell/scipipe |
994e900c0b4eb6e91236067a6ce97520251fb764 | cmdln.go | cmdln.go | package main
import (
"flag"
"log"
)
type AppConfig struct {
verbose bool
newRelicKey string
database string
interval int
user string
host string
}
func HandleUserOptions() AppConfig {
var config AppConfig
flag.BoolVar(&config.verbose, "verbose", false, "Verbose mode")
flag.Strin... | package main
import (
"flag"
"fmt"
"log"
"os"
)
// build number set on during linking
var minversion string
type AppConfig struct {
verbose bool
newRelicKey string
database string
interval int
user string
host string
version bool
}
func HandleUserOptions() AppConfig {
var co... | Add version option for printing build number | Add version option for printing build number
| Go | apache-2.0 | maciejmrowiec/pgmonitor |
11320dc0577bdc8dcb8a90ae2c468ee34b50110c | spawn.go | spawn.go | package main
import (
"fmt"
"time"
"github.com/miquella/ask"
"github.com/miquella/vaulted/lib"
)
type Spawn struct {
SessionOptions
Command []string
DisplayStatus bool
}
func (s *Spawn) Run(store vaulted.Store) error {
session, err := GetSessionWithOptions(store, &s.SessionOptions)
if err != nil {
... | package main
import (
"fmt"
"time"
"github.com/miquella/ask"
"github.com/miquella/vaulted/lib"
)
type Spawn struct {
SessionOptions
Command []string
DisplayStatus bool
}
func (s *Spawn) Run(store vaulted.Store) error {
session, err := GetSessionWithOptions(store, &s.SessionOptions)
if err != nil {
... | Replace non-breaking space with regular space | Replace non-breaking space with regular space
| Go | mit | miquella/vaulted |
6449899e67646ca113f8dcb20bdf5060ceef86e3 | ptrhost.go | ptrhost.go | package main
import (
"fmt"
"net"
"os"
flags "github.com/jessevdk/go-flags"
)
const version = "1.0.0"
var opts struct {
Version bool `short:"v" long:"version" description:"Show version"`
}
func main() {
parser := flags.NewParser(&opts, flags.Default)
parser.Usage = "HOSTNAME [OPTIONS]"
args, _ := parser.Pa... | package main
import (
"fmt"
"net"
"os"
flags "github.com/jessevdk/go-flags"
)
const version = "1.0.0"
var opts struct {
Version bool `short:"v" long:"version" description:"Show version"`
}
func main() {
parser := flags.NewParser(&opts, flags.Default)
parser.Usage = "HOSTNAME [OPTIONS]"
args, _ := parser.Pa... | Fix crash when none resolved hostname | Fix crash when none resolved hostname
| Go | mit | itochan/ptrhost |
ba59eb1c8064c992a561d85aaae746ab86efa16c | thaum.go | thaum.go | package main
import (
"os"
"fmt"
"github.com/urfave/cli"
)
// Called when thaum is actually run.
func onRun(c *cli.Context) error {
template := c.Args().Get(0)
name := c.Args().Get(1)
if len(c.Args()) == 0 {
cli.ShowAppHelp(c)
return nil
}
if name == "" {
ErrorLog(fmt.Sprintf("Thaum requires a name f... | package main
import (
"os"
"fmt"
"github.com/urfave/cli"
)
// Called when thaum is actually run.
func onRun(c *cli.Context) error {
template := c.Args().Get(0)
name := c.Args().Get(1)
if len(c.Args()) == 0 {
cli.ShowAppHelp(c)
return nil
}
if name == "" {
ErrorLog(fmt.Sprintf("Thaum requires a name f... | Edit "name for template" error message to include example | Edit "name for template" error message to include example
| Go | mit | Flaque/thaum |
23d22525604adb3d5504cb8894cabcd4add15ea2 | utils.go | utils.go | package main
import (
"fmt"
"net/url"
)
func validateAndGetURLHost(urlSample string) (string, error) {
parsed, err := url.ParseRequestURI(urlSample)
if err != nil {
fmt.Printf("Unable to parse URL '%s' to get the host\n", urlSample)
return "", err
}
// return parsed.Scheme + "://" + parsed.Host
return p... | package main
import (
"fmt"
"net/url"
"strings"
)
func validateAndGetURLHost(urlSample string) (string, error) {
// cheat a little by checking if we have :// in the string.
// if we dont, its probably a hostname already
if !strings.Contains("://", urlSample) {
s := strings.TrimSpace(urlSample)
return s, n... | Allow hostnames to be submitted along with urls | Allow hostnames to be submitted along with urls
| Go | mit | leonjza/go-observe,leonjza/go-observe |
ba9c164966eb19d32144b81b815958e83720377c | example/large/main.go | example/large/main.go | package main
import (
"github.com/sean-duffy/xlsx"
"strconv"
)
func main() {
c := []xlsx.Column{
xlsx.Column{Name: "Col1", Width: 10},
xlsx.Column{Name: "Col2", Width: 10},
}
sh := xlsx.NewSheetWithColumns(c)
sh.Title = "MySheet"
for i := 0; i < 10; i++ {
r := sh.NewRow()
r.Cells[0] = xlsx.Cell{
... | package main
import (
"bufio"
"github.com/sean-duffy/xlsx"
"os"
"strconv"
)
func main() {
outputfile, err := os.Create("test.xlsx")
w := bufio.NewWriter(outputfile)
ww := xlsx.NewWorkbookWriter(w)
c := []xlsx.Column{
xlsx.Column{Name: "Col1", Width: 10},
xlsx.Column{Name: "Col2", Width: 10},
}
sh :=... | Change large example to use streaming | Change large example to use streaming
| Go | mit | scraperwiki/xlsx,psmithuk/xlsx |
788e4aa7eb2047650013367297d44e4a8863a087 | formatters/default.go | formatters/default.go | package formatters
import (
"io"
"os"
"strconv"
"github.com/mrtazz/checkmake/rules"
"github.com/olekukonko/tablewriter"
)
// DefaultFormatter is the formatter used by default for CLI output
type DefaultFormatter struct {
out io.Writer
}
// NewDefaultFormatter returns a DefaultFormatter struct
func NewDefaultF... | package formatters
import (
"io"
"os"
"strconv"
"github.com/mrtazz/checkmake/rules"
"github.com/olekukonko/tablewriter"
)
// DefaultFormatter is the formatter used by default for CLI output
type DefaultFormatter struct {
out io.Writer
}
// NewDefaultFormatter returns a DefaultFormatter struct
func NewDefaultF... | Disable borders to remove start/end newlines | Disable borders to remove start/end newlines
| Go | mit | mrtazz/checkmake |
7532d897dce8c56705de1b7ad0f5959c8ef71520 | example_main.go | example_main.go | package main
import (
"github.com/henrylee2cn/pholcus/exec"
_ "github.com/pholcus/spider_lib" // 此为公开维护的spider规则库
_ "github.com/pholcus/spider_lib_pte" // 同样你也可以自由添加自己的规则库
)
func main() {
// 设置运行时默认操作界面,并开始运行
// 运行软件前,可设置 -a_ui 参数为"web"、"gui"或"cmd",指定本次运行的操作界面
// 其中"gui"仅支持Windows系统
exec.Defaul... | package main
import (
"github.com/henrylee2cn/pholcus/exec"
_ "github.com/pholcus/spider_lib" // 此为公开维护的spider规则库
// _ "github.com/pholcus/spider_lib_pte" // 同样你也可以自由添加自己的规则库
)
func main() {
// 设置运行时默认操作界面,并开始运行
// 运行软件前,可设置 -a_ui 参数为"web"、"gui"或"cmd",指定本次运行的操作界面
// 其中"gui"仅支持Windows系统
exec.Default... | Comment out the private library connection | Comment out the private library connection
| Go | apache-2.0 | glutwins/pholcus,henrylee2cn/pholcus,lln7777/pholcus,lln7777/pholcus,lln7777/pholcus,glutwins/pholcus,henrylee2cn/pholcus,glutwins/pholcus,lln7777/pholcus |
bb6b4cda0ff74856f32ecfc7272064880fa0caea | contents/bogo_sort/code/go/main.go | contents/bogo_sort/code/go/main.go | // Submitted by Christopher Milan (christopherm99)
package main
import (
"fmt"
"math/rand"
"time"
)
func shuffle(a []int) []int {
rand.Seed(time.Now().UnixNano())
for i := len(a) - 1; i > 0; i-- {
j := rand.Intn(i + 1)
a[i], a[j] = a[j], a[i]
}
return a
}
func is_sorted(a []int) bool {
for i := 0; i < l... | // Submitted by Christopher Milan (christopherm99)
package main
import (
"fmt"
"math/rand"
"time"
)
func shuffle(a *[]int) {
for i := len(*a) - 1; i > 0; i-- {
j := rand.Intn(i + 1)
(*a)[i], (*a)[j] = (*a)[j], (*a)[i]
}
}
func isSorted(a []int) bool {
for i := 0; i < len(a)-1; i... | Resolve Liikt's PR review comments. | Resolve Liikt's PR review comments.
| Go | mit | Gathros/algorithm-archive,leios/algorithm-archive,leios/algorithm-archive,leios/algorithm-archive,leios/algorithm-archive,Gathros/algorithm-archive,Gathros/algorithm-archive,Gathros/algorithm-archive,leios/algorithm-archive,Gathros/algorithm-archive,Gathros/algorithm-archive,leios/algorithm-archive,Gathros/algorithm-ar... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.