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 |
|---|---|---|---|---|---|---|---|---|---|
adf52d8d41bc87ea694d5873c8cd5724959e807d | api/api.go | api/api.go | package api
type AuthScope int
type AuthScopes map[AuthScope]string
type ServiceMethod int
type EventKey string
type ObjectFactory func() interface{}
type HttpMethod string
type QueryDefault interface{}
type UrlQueries map[string]QueryDefault
type HttpHeaders map[string]string
var (
GET HttpMethod = HttpMet... | package api
import (
"net/http"
)
type AuthScope int
type AuthScopes map[AuthScope]string
type ServiceMethod int
type EventKey string
type ObjectFactory func(*http.Request) interface{}
type HttpMethod string
type QueryDefault interface{}
type UrlQueries map[string]QueryDefault
type HttpHeaders map[string]string
... | Change in API RequestBody/ ObjectFactory signature to allow different prototype objects based on http request (content-type) | Change in API RequestBody/ ObjectFactory signature to allow different prototype objects based on http request (content-type)
| Go | apache-2.0 | qorio/omni,qorio/omni,qorio/omni,qorio/omni |
c09b3132053225dd3ea720112a0bf8dcfde4a4d6 | cmd/sqlite-squish/main.go | cmd/sqlite-squish/main.go | package main
import (
"bufio"
"fmt"
"log"
"os"
"github.com/griffithsh/sql-squish/database"
)
func main() {
scanner := bufio.NewScanner(os.Stdin)
var concatted string
for scanner.Scan() {
concatted = concatted + scanner.Text()
}
d, err := database.FromString(concatted)
if err != nil {
log.Fatal(err)
... | package main
import (
"log"
"github.com/griffithsh/sql-squish/database"
)
func main() {
concatted, err := inputStdin()
if err != nil {
log.Fatal(err)
}
d, err := database.FromString(concatted)
if err != nil {
log.Fatal(err)
}
outputStdout(d)
}
| Use input and output functions in sqlite-squish | Use input and output functions in sqlite-squish
Now that I have a structure of input and output, I can leverage those in
the main cli file to keep control flow clear.
| Go | mit | griffithsh/sqlite-squish |
726c5ae6ebedd85c330efb3a263d252f6a30b9a9 | stun/channel-data.go | stun/channel-data.go | package stun
import (
"encoding/binary"
"github.com/pkg/errors"
)
type ChannelData struct {
ChannelNumber uint16
Data []byte
}
func NewChannelData(packet []byte) (*ChannelData, error) {
cn, err := getChannelNumber(packet)
if err != nil {
return nil, err
}
return &ChannelData{
ChannelNumber: cn... | package stun
import (
"encoding/binary"
"github.com/pkg/errors"
)
type ChannelData struct {
ChannelNumber uint16
Length uint16
Data []byte
}
func NewChannelData(packet []byte) (*ChannelData, error) {
cn, err := getChannelNumber(packet)
if err != nil {
return nil, err
}
return &ChannelDat... | Add ChannelData length to struct | Add ChannelData length to struct
| Go | mit | pion/stun,pion/stun |
527518bc0b99a861b8f544dd0f77673aafc49c3a | event.go | event.go | package filu
import "time"
// An Event is an immutable fact that happened at a single moment in time.
type Event interface {
HappenedAt() time.Time
}
// A Time is a single moment in time. It is used by Implementors
// of the Event interface to avoid reimplementation of the HappenedAt()
// method.
type Time struct {... | package filu
import "time"
// An Event is an immutable fact that happened at a single moment in time.
type Event interface {
HappenedAt() time.Time
}
// A Time is a single moment in time. It is used by Implementors
// of the Event interface to avoid reimplementation of the HappenedAt()
// method.
type Time struct {... | Add function to produce time.Now() as filu.Time | [filu] Add function to produce time.Now() as filu.Time
| Go | mit | ghthor/filu |
92506424bd2a53d3140129ee7eba1cda2b74220d | testhelpers/pipes.go | testhelpers/pipes.go | package testhelpers
import(
. "github.com/onsi/gomega"
"bytes"
"io"
"os"
"strings"
"wall_street"
)
func SimulatePipes(reader *wall_street.ReadlineReader, input string, block func()) []string {
in, out, err := os.Pipe()
Expect(err).NotTo(HaveOccurred())
reader.SetReadPipe(in)
go func() {
defer out.Clos... | package testhelpers
import(
. "github.com/onsi/gomega"
"bytes"
"io"
"os"
"strings"
"wall_street"
)
func SimulatePipes(reader *wall_street.ReadlineReader, input string, block func()) []string {
in, out, err := os.Pipe()
Expect(err).NotTo(HaveOccurred())
reader.SetReadPipe(in)
go func() {
defer out.Clos... | Add convenient newline to test helpers | Add convenient newline to test helpers
readline reads stdin until it receives a newline character (or some other
hard to understand condition is met), so this should help with some of
the test failures.
| Go | mit | tjarratt/wall_street |
baa65642f317ce9a3cd2ade68e24958131d79720 | graph.go | graph.go | // gogl provides a framework for representing and working with graphs.
package gogl
// Constants defining graph capabilities and behaviors.
const (
E_DIRECTED, EM_DIRECTED = 1 << iota, 1<<iota - 1
E_UNDIRECTED, EM_UNDIRECTED
E_WEIGHTED, EM_WEIGHTED
E_TYPED, EM_TYPED
E_SIGNED, EM_SIGNED
E_LOOPS, EM_LOOPS
E_MULTI... | // gogl provides a framework for representing and working with graphs.
package gogl
// Constants defining graph capabilities and behaviors.
const (
E_DIRECTED, EM_DIRECTED = 1 << iota, 1<<iota - 1
E_UNDIRECTED, EM_UNDIRECTED
E_WEIGHTED, EM_WEIGHTED
E_TYPED, EM_TYPED
E_SIGNED, EM_SIGNED
E_LOOPS, EM_LOOPS
E_MULTI... | Fix interfaces so they actually work. | Fix interfaces so they actually work.
Really weird that Go can't figure out that indirectly composing the
same interface twice shouldn't cause method naming conflicts...
| Go | mit | sdboyer/gogl,sdboyer/gogl |
fb4898e962b28e395098cc28d5d1fb988711b6d6 | jiffy.go | jiffy.go | package jiffy
const (
cancelTTL = iota
extendTTL
)
var (
registry *Registry
)
func GetTopic(name string) *Topic {
return registry.GetTopic(name)
}
func init() {
registry = CreateRegistry()
}
| package jiffy
const (
cancelTTL = iota
extendTTL
)
var (
registry *Registry
)
// Returns a topic from the global registry.
func GetTopic(name string) *Topic {
return registry.GetTopic(name)
}
func init() {
registry = CreateRegistry()
}
| Comment for main exported fuctions | Comment for main exported fuctions
| Go | mit | DavidHuie/jiffy |
4f5e64d79213ab2fe417915d8be361bcca3f8bc5 | operation/manifest.go | operation/manifest.go | package operation
type Manifest struct {
Applications []AppManifest `yaml:"applications"`
}
type AppManifest struct {
Name string `yaml:"name"`
Buildpacks []string `yaml:"buildpacks,omitempty"`
Command string `yaml:"command,omite... | package operation
type Manifest struct {
Applications []*AppManifest `yaml:"applications"`
}
type AppManifest struct {
Name string `yaml:"name"`
Buildpacks []string `yaml:"buildpacks,omitempty"`
Command string `yaml:"command,omit... | Add pointer type ot apps array | Add pointer type ot apps array
| Go | mit | cloudfoundry-community/go-cfclient |
82bc6ebfec08d065bdf97beb59b632720504ac05 | gae/impl/cloud/context.go | gae/impl/cloud/context.go | // Copyright 2016 The LUCI Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
package cloud
import (
"google.golang.org/cloud/datastore"
"golang.org/x/net/context"
)
// Use installs the cloud services implementation ... | // Copyright 2016 The LUCI Authors. All rights reserved.
// Use of this source code is governed under the Apache License, Version 2.0
// that can be found in the LICENSE file.
package cloud
import (
"google.golang.org/cloud/datastore"
"golang.org/x/net/context"
)
// Use installs the cloud services implementation ... | Add an option to install just Cloud Datastore. | Add an option to install just Cloud Datastore.
TBR=iannucci@chromium.org
BUG=None
TEST=None
Review-Url: https://codereview.chromium.org/2179843004
| Go | apache-2.0 | luci/luci-go,luci/luci-go,luci/luci-go,luci/luci-go,luci/luci-go,luci/luci-go |
388655e8d22c17b3cc7ada6c91967d8813cea253 | sub/scanner/walk.go | sub/scanner/walk.go | package scanner
import (
"github.com/Symantec/Dominator/lib/filesystem/scanner"
"github.com/Symantec/Dominator/lib/objectcache"
)
func scanFileSystem(rootDirectoryName string, cacheDirectoryName string,
configuration *Configuration, oldFS *FileSystem) (*FileSystem, error) {
var fileSystem FileSystem
fileSystem.c... | package scanner
import (
"github.com/Symantec/Dominator/lib/filesystem/scanner"
"github.com/Symantec/Dominator/lib/objectcache"
)
func scanFileSystem(rootDirectoryName string, cacheDirectoryName string,
configuration *Configuration, oldFS *FileSystem) (*FileSystem, error) {
var fileSystem FileSystem
fileSystem.c... | Improve handling of scanning of shrinking files in subd: return zero hash. | Improve handling of scanning of shrinking files in subd: return zero hash.
| Go | apache-2.0 | keep94/Dominator,rgooch/Dominator,Symantec/Dominator,keep94/Dominator,rgooch/Dominator,Symantec/Dominator,keep94/Dominator,rgooch/Dominator,Symantec/Dominator |
00d2c99d36b1cf0e1d317df0eeb2f659a51ae0f5 | golog.go | golog.go | package golog
var Global *LevelLogger = &LevelLogger{
&loggerImpl{&defaultLogOuters, flag_minloglevel},
}
func Info(vals ...interface{}) {
Global.Info(vals...)
}
func Infof(f string, args ...interface{}) {
Global.Infof(f, args...)
}
func Infoc(closure func() string) {
Global.Warningc(closure)
}
func Warning(va... | package golog
var Global *LevelLogger = &LevelLogger{
&loggerImpl{&defaultLogOuters, flag_minloglevel},
}
func Info(vals ...interface{}) {
Global.Info(vals...)
}
func Infof(f string, args ...interface{}) {
Global.Infof(f, args...)
}
func Infoc(closure func() string) {
Global.Warningc(closure)
}
func Warning(va... | Add capability to start test logging | Add capability to start test logging
| Go | bsd-2-clause | awreece/golog |
57baa20575aefd6bae043b325d1d4134d3df07e1 | rtcicetransport.go | rtcicetransport.go | package webrtc
// RTCIceTransport allows an application access to information about the ICE
// transport over which packets are sent and received.
type RTCIceTransport struct {
}
| package webrtc
// RTCIceTransport allows an application access to information about the ICE
// transport over which packets are sent and received.
type RTCIceTransport struct {
// Role RTCIceRole
// Component RTCIceComponent
// State RTCIceTransportState
// gatheringState RTCIceGathererState
}
// func (t *RTCIceT... | Add RTCIceTransport commented out public API | Add RTCIceTransport commented out public API
| Go | mit | pion/webrtc,pion/webrtc,pion/webrtc,pion/webrtc |
47ae5d63b6f4c3e548d41cccabed2c619aae195a | imagestore/memorystore.go | imagestore/memorystore.go | package imagestore
import (
"errors"
"io"
"io/ioutil"
"strings"
)
type InMemoryImageStore struct {
files map[string]string // name -> contents
}
func NewInMemoryImageStore() *InMemoryImageStore {
return &InMemoryImageStore{
files: make(map[string]string),
}
}
func (this *InMemoryImageStore) Exists(obj *Sto... | package imagestore
import (
"errors"
"io"
"io/ioutil"
"strings"
"sync"
)
type InMemoryImageStore struct {
files map[string]string // name -> contents
rw sync.Mutex
}
func NewInMemoryImageStore() *InMemoryImageStore {
return &InMemoryImageStore{
files: make(map[string]string),
rw: sync.Mutex{},
}
}... | Fix race with in-memory store | Fix race with in-memory store
| Go | mit | Klaasvaak/mandible,briankassouf/mandible,henrylee2cn/mandible,Imgur/mandible,josephyzhou/mandible,briankassouf/mandible,Imgur/mandible,josephyzhou/mandible,henrylee2cn/mandible,Klaasvaak/mandible |
8aeed91e8ac690eb24e74b3cca5b714b69a3a85d | utils/websockettracker.go | utils/websockettracker.go | package utils
import (
"github.com/gorilla/websocket"
)
type WebSocketManager interface {
Register(ws *websocket.Conn)
Write(msg []byte) (n int, e error)
}
type wsManager struct {
sockets []websocket.Conn
}
func CreateWSManager() WebSocketManager {
return &wsManager{sockets: make([]websocket.Conn, 0)}
}
func... | package utils
import (
"github.com/gorilla/websocket"
)
type WebSocketManager interface {
Register(ws *websocket.Conn)
Write(msg []byte) (n int, e error)
}
type wsManager struct {
sockets []websocket.Conn
}
func CreateWSManager() WebSocketManager {
return &wsManager{sockets: make([]websocket.Conn, 0)}
}
func... | Fix bug when only one websocket was connected | Fix bug when only one websocket was connected
| Go | apache-2.0 | PufferPanel/pufferd |
fee5fd857d523feecb657dcf93153708fac48ea6 | main/bsearch.go | main/bsearch.go | package main
import (
"bsearch/index"
"bsearch/ops"
"fmt"
"os"
"flag"
)
func usage() {
fmt.Fprintf(os.Stderr, "usage: bsearch <path to index blob>\n")
flag.PrintDefaults()
os.Exit(1)
}
func main() {
flag.Parse()
if flag.NArg() != 1 {
usage()
}
dbname := flag.Arg(0)
in, err := index.Open(dbname)
if er... | package main
import (
"bsearch/index"
"bsearch/ops"
"fmt"
"os"
"flag"
)
func usage() {
fmt.Fprintf(os.Stderr, "usage: bsearch <path to index blob>\n")
flag.PrintDefaults()
os.Exit(1)
}
func main() {
flag.Parse()
if flag.NArg() != 1 {
usage()
}
dbname := flag.Arg(0)
in, err := index.Open(dbname)
if er... | Print the header at the right place. | Print the header at the right place.
| Go | isc | art4711/bsearch |
2867515fac88917f8987e0c14e23ac6b68bc6821 | src/enemy/enemy.go | src/enemy/enemy.go | package enemy
import (
"board"
"color"
)
type Enemy struct {
board.Board
color.Color
first [8][8]bool
}
func NewEnemy(b board.Board, c color.Color, first [8][8]bool) *Enemy {
enemy := new(Enemy)
enemy.Board = b
enemy.Color = c
enemy.first = first
return enemy
}
| package enemy
import (
"board"
"color"
"matrix"
)
type Enemy struct {
matrix.Matrix
color.Color
first [8][8]bool
}
func NewEnemy(b *board.Board, c color.Color) *Enemy {
enemy := new(Enemy)
enemy.Matrix = b.Matrix
enemy.Color = c
for i := 0; i < matrix.SIDE; i++ {
for j := 0; j < matrix.SIDE; j++ {
ene... | Change Enemy's members and how to get them | Change Enemy's members and how to get them
| Go | mit | Roadagain/Chess |
8676d52b4dcb792b16c4ecea17277cd4d6dd0c1e | solutions/go/trinary/trinary.go | solutions/go/trinary/trinary.go | // Package trinary implements a function for converting a trinary number to a decimal number.
package trinary
import (
"fmt"
"math"
"strconv"
)
const testVersion = 1
// ParseTrinary converts a trinary number to a decimal number.
// If the input contains invalid characters or overflows int64 an error is returned.
... | // Package trinary implements a function for converting a trinary number to a decimal number.
package trinary
import "fmt"
const testVersion = 1
// ParseTrinary converts a trinary number to a decimal number.
// If the input contains invalid characters or overflows int64 an error is returned.
func ParseTrinary(input ... | Add solutions for go problems | Add solutions for go problems
| Go | mit | DanShu93/exercism |
5538acec3cb941d4dfeeded8b75dc851d82cb241 | net/doc.go | net/doc.go | // Copyright 2015-2016, Cyrill @ Schumacher.fm and the CoreStore contributors
//
// 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
//
// Un... | // Copyright 2015-2016, Cyrill @ Schumacher.fm and the CoreStore contributors
//
// 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
//
// Un... | Add todo to implement kerberos | net: Add todo to implement kerberos
| Go | apache-2.0 | corestoreio/csfw,corestoreio/csfw |
a68c6f52c93b7451dcf1d302fde1fb8bd4ccc7b4 | src/apps/pblcached/pblcached.go | src/apps/pblcached/pblcached.go | //
// Copyright (c) 2014 The pblcache Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or a... | //
// Copyright (c) 2014 The pblcache Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or a... | Remove call to cache while we work on it | Remove call to cache while we work on it
Signed-off-by: Luis Pabón <e0c09d35b5ba288a4d2f5dad87cf314a1461423f@redhat.com>
| Go | apache-2.0 | pblcache/pblcache,lpabon/pblcache,pblcache/pblcache,lpabon/pblcache,lpabon/pblcache,pblcache/pblcache |
19ab1e9984763ad5590837c5dcd1f68a83ab89db | apps/staging_log_test.go | apps/staging_log_test.go | package apps
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/vito/cmdtest/matchers"
. "github.com/pivotal-cf-experimental/cf-acceptance-tests/helpers"
)
var _ = Describe("An application being staged", func() {
BeforeEach(func() {
AppName = RandomName()
})
AfterEach(func() {
E... | package apps
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/vito/cmdtest/matchers"
. "github.com/pivotal-cf-experimental/cf-acceptance-tests/helpers"
)
var _ = Describe("An application being staged", func() {
BeforeEach(func() {
AppName = RandomName()
})
AfterEach(func() {
E... | Disable check that fails due to known race condition | Disable check that fails due to known race condition
This should be enabled as part of [#64088856]
Signed-off-by: Eric Malm <f38766f3ef0e8328064f8aa2a19c8805448432f2@pivotallabs.com>
| 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 |
98e5cb3182490c8947c41fb7a50fb9d850f05474 | wsmaterials/jsonp.go | wsmaterials/jsonp.go | package wsmaterials
import (
"fmt"
"github.com/emicklei/go-restful"
"net/http"
)
type JsonpResponseWriter struct {
writer http.ResponseWriter
callback string
}
func (j *JsonpResponseWriter) Header() http.Header {
return j.writer.Header()
}
func (j *JsonpResponseWriter) WriteHeader(status int) {
j.writer.Wr... | package wsmaterials
import (
"fmt"
"github.com/emicklei/go-restful"
"net/http"
)
type jsonpResponseWriter struct {
writer http.ResponseWriter
callback string
}
func (j *jsonpResponseWriter) Header() http.Header {
return j.writer.Header()
}
func (j *jsonpResponseWriter) WriteHeader(status int) {
j.writer.Wr... | Remove some definitions and methods from the public space (lowercase their name) | Remove some definitions and methods from the public space (lowercase
their name)
| Go | mit | materials-commons/materials,materials-commons/materials |
213c80bc286672657ced52e03374b528f20a965e | imagio.go | imagio.go | package main
import (
"log"
"net/http"
)
func main() {
router := NewRouter()
err := http.ListenAndServe(":8080", router)
if err != nil {
log.Fatal("ListenAndServe Error: ", err)
}
}
| package main
import (
"log"
"net/http"
)
func main() {
router := NewRouter()
err := http.ListenAndServe(":" + os.Getenv("PORT"), router)
if err != nil {
log.Fatal("ListenAndServe Error: ", err)
}
}
| Make http port into env var | Make http port into env var
| Go | mit | eddturtle/imagio,eddturtle/imagio |
466fd1c9b2bd34350b3372fc136c872e6b023913 | x/compliance/types/types.go | x/compliance/types/types.go | package types
const (
ZigbeeCertificationType string = "zigbee"
MatterCertificationType string = "matter"
FullCertificationType string = "Full"
CbSCertificationType string = "CbS" // CbS - Certification by Similarity
CTPCertificationType string = "CTP" // CTP - Certification Transfer Program
PFCCertifica... | package types
const (
ZigbeeCertificationType string = "zigbee"
MatterCertificationType string = "matter"
)
// List of Certification Types
type CertificationTypes []string
var CertificationTypesList = CertificationTypes{ZigbeeCertificationType, MatterCertificationType}
func IsValidCertificationType(certificationT... | Remove incorrect CertificationType default values | Remove incorrect CertificationType default values
| Go | apache-2.0 | zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger |
83d4843f1a004f96a6011e77a9c53244ef9d10c7 | gerror/examples_test.go | gerror/examples_test.go | /*
Copyright 2014 GoPivotal (UK) Limited.
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, soft... | /*
Copyright 2014 GoPivotal (UK) Limited.
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, soft... | Remove duplicate declarations from examples | Remove duplicate declarations from examples
| Go | apache-2.0 | cf-guardian/guardian,cf-guardian/guardian |
4d920ebf664c40e9756bc7a7738699c1041fb26f | rjson.go | rjson.go | package http
var (
debugMode = false
)
func setDebug(debug bool) {
debugMode = debug
}
type Error struct {
Error string `json:"error,omitempty"`
StatusCode int `json:"statusCode,omitempty"`
HttpCode int `json:"httpCode,omitempty"`
}
func NewError(err error, statusCode, httpCode int) *Error {
retu... | package http
var (
debugMode = false
)
func SetDebug(debug bool) {
debugMode = debug
}
type Error struct {
Error string `json:"error,omitempty"`
StatusCode int `json:"statusCode,omitempty"`
HttpCode int `json:"httpCode,omitempty"`
}
func NewError(err error, statusCode, httpCode int) *Error {
retu... | Put the SetDebug function on public | Put the SetDebug function on public
| Go | mit | pikanezi/http |
24e7b86a87e618202a2983c716f43dd9e9eeb552 | factory.go | factory.go | package libcontainer
type Factory interface {
// Creates a new container in the given path. A unique ID is generated for the container and
// starts the initial process inside the container.
//
// Returns the new container with a running process.
//
// Errors:
// Path already exists
// Config or initialConfig ... | package libcontainer
type Factory interface {
// Creates a new container with the given id and starts the initial process inside it.
// id must be a string containing only letters, digits and underscores and must contain
// between 1 and 1024 characters, inclusive.
//
// The id must not already be in use by an e... | Remove erroneous reference to `path` in description and error list; add format description for `id` string; add "invalid format" error for `id` string; remove initial capitals on references to parameter names; remove reference to `initialConfig`; add description of id checking. | Remove erroneous reference to `path` in description and error list;
add format description for `id` string;
add "invalid format" error for `id` string;
remove initial capitals on references to parameter names;
remove reference to `initialConfig`;
add description of id checking.
Signed-off-by: Steve Powell <03c892efa7d... | Go | apache-2.0 | estesp/runc,ddnbgroup/runc,subuser-security/runc,mrunalp/libcontainer,avagin/libcontainer,BrickXu/libcontainer,thaJeztah/libcontainer,justincormack/runc,boucher/libcontainer,chenchun/runc,hqhq/runc,ZJU-SEL/runc,wking/runc,mrunalp/runc,ZJU-SEL/libcontainer,rsampaio/runc,mikebrow/runc,dieface/runc,balajibr/runc,jhowardms... |
11126a81a179dd0d40b081da8cd02d696cdc6c92 | minmax.go | minmax.go | package missinggo
import "reflect"
func Max(_less interface{}, vals ...interface{}) interface{} {
ret := reflect.ValueOf(vals[0])
less := reflect.ValueOf(_less)
for _, _v := range vals[1:] {
v := reflect.ValueOf(_v)
out := less.Call([]reflect.Value{ret, v})
if out[0].Bool() {
ret = v
}
}
return ret.In... | package missinggo
import "reflect"
func Max(_less interface{}, vals ...interface{}) interface{} {
ret := reflect.ValueOf(vals[0])
retType := ret.Type()
less := reflect.ValueOf(_less)
for _, _v := range vals[1:] {
v := reflect.ValueOf(_v).Convert(retType)
out := less.Call([]reflect.Value{ret, v})
if out[0].B... | Add MaxInt, and ensure the return type of Max matches the type of the first value | Add MaxInt, and ensure the return type of Max matches the type of the first value
| Go | mit | anacrolix/missinggo |
0e7b07fc83f74da826bb29c5dc5442e2b4f8b8a0 | handler.go | handler.go | package web
import (
"html/template"
"net/http"
"code.cloudfoundry.org/lager"
)
type templateData struct{}
type handler struct {
logger lager.Logger
template *template.Template
}
func NewHandler(logger lager.Logger) (http.Handler, error) {
tfuncs := &templateFuncs{
assetIDs: map[string]string{},
}
fun... | package web
import (
"html/template"
"net/http"
"code.cloudfoundry.org/lager"
)
type templateData struct{}
type handler struct {
logger lager.Logger
template *template.Template
}
func NewHandler(logger lager.Logger) (http.Handler, error) {
tfuncs := &templateFuncs{
assetIDs: map[string]string{},
}
fun... | 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 |
9a812ba6d411ef10b32c14d83b852be9c1688f34 | stack.go | stack.go | package main
import (
"bytes"
)
// Stack is a stack of matrices
type Stack struct {
stack []*Matrix
}
// NewStack returns a new stack
func NewStack() *Stack {
return &Stack{
stack: make([]*Matrix, 0, 100),
}
}
// Pop returns and removes the top matrix in the stack
func (s *Stack) Pop() *Matrix {
if s.IsEmpty... | package main
import (
"bytes"
)
// Stack is a stack of matrices
type Stack struct {
stack []*Matrix
}
// NewStack returns a new stack
func NewStack() *Stack {
return &Stack{
stack: make([]*Matrix, 0, 10),
}
}
// Pop returns and removes the top matrix in the stack
func (s *Stack) Pop() *Matrix {
if s.IsEmpty(... | Reduce initial size of Stack | Reduce initial size of Stack
| Go | mit | james9909/graphics-engine,james9909/graphics-engine |
2e30cacd1a2753cce932e13bb5bcf93bb12d753a | mediaInfo.go | mediaInfo.go | package mp4parser
import "time"
import "fmt"
//MediaInfo contain media information
type MediaInfo struct {
width float64 //
height float64 //found in tkhd
soundSamplingRate uint32
creationTime *time.Time
modifTime *time.Time
duration *time.Duration // result of duration/time_scale... | package mp4parser
import "time"
import "fmt"
//MediaInfo contain media information
type MediaInfo struct {
width float64 //
height float64 //found in tkhd
soundSamplingRate uint32
creationTime *time.Time
modifTime *time.Time
duration *time.Duration // result of duration/time_scale... | Add exported getter methods for all fields in MediaInfo | Add exported getter methods for all fields in MediaInfo
Acessing these fields is useful when using this package as a library.
| Go | mit | Joe-xu/mp4parser |
8a2e90d05214d4919761b35992975f881aca2bdf | normalize.go | normalize.go | package goalfred
import (
"io/ioutil"
"os/exec"
)
// Normalize fixes problems with string encoding regarding the usage of special characters in Alfred.
// For more info on this topic, please refer to this thread: http://www.alfredforum.com/topic/2015-encoding-issue/
func Normalize(input string) (output string, err ... | package goalfred
import (
"io/ioutil"
"os/exec"
)
// Normalize fixes problems with string encoding regarding the usage of special characters in Alfred.
// For more info on this topic, please refer to this thread: http://www.alfredforum.com/topic/2015-encoding-issue/
func Normalize(input string) (output string, err ... | Revert "Test setting the encoding to UTF-8 instead of UTF8-MAC" | Revert "Test setting the encoding to UTF-8 instead of UTF8-MAC"
This reverts commit b6c979d951e81f6bfc03226868ab3566e78f487f.
| Go | mit | BenchR267/goalfred,BenchR267/goalfred |
95d229239005f5523ca5f03bea21a0099312b026 | terraform/cmd_test.go | terraform/cmd_test.go | package terraform_test
import (
"bytes"
"github.com/cloudfoundry/bosh-bootloader/terraform"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Cmd", func() {
var (
stdout *bytes.Buffer
stderr *bytes.Buffer
cmd terraform.Cmd
)
BeforeEach(func() {
stdout = bytes.NewBuffer([]byt... | package terraform_test
import (
"bytes"
"github.com/cloudfoundry/bosh-bootloader/terraform"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Cmd", func() {
var (
stdout *bytes.Buffer
stderr *bytes.Buffer
cmd terraform.Cmd
)
BeforeEach(func() {
stdout = bytes.NewBuffer([]byt... | Fix cmd test to check for tmp directory | Fix cmd test to check for tmp directory
[#133220399]
Signed-off-by: Kevin Kelani <efa91e710b9557b327e9f2a4990d2dbb61dce345@pivotal.io>
| Go | apache-2.0 | niroyb/bosh-bootloader,niroyb/bosh-bootloader,pivotal-cf-experimental/bosh-bootloader,pivotal-cf-experimental/bosh-bootloader |
184afbb9d4f2505218f5094575a5d40a706857d2 | commands.go | commands.go | package main
import (
"log"
"os"
"fmt"
"github.com/timakin/ts/loader"
"github.com/codegangsta/cli"
)
var Commands = []cli.Command{
commandAll,
commandBiz,
commandHack,
}
var commandAll = cli.Command{
Name: "all",
Usage: "",
Description: `
`,
Action: doAll,
}
var commandBiz = cli.Command{
Name: "biz",... | package main
import (
"log"
"os"
"fmt"
"github.com/timakin/ts/loader"
"github.com/codegangsta/cli"
)
var Commands = []cli.Command{
commandAll,
commandBiz,
commandHack,
}
var commandAll = cli.Command{
Name: "all",
Usage: "",
Description: `
`,
Action: doAll,
}
var commandBiz = cli.Command{
Name: "biz",... | Enable to get response appropriately from HN | Enable to get response appropriately from HN
| Go | mit | timakin/ts,timakin/ts |
5e3d457f28f7d1ecbc60cdb60ff0d1b0b3f89493 | engine/dot.go | engine/dot.go | package engine
import "fmt"
type Dot struct {
X uint8
Y uint8
}
// Equals compares two dots
func (d1 Dot) Equals(d2 Dot) bool {
return d1 == d2 || (d1.X == d2.X && d1.Y == d2.Y)
}
// Implementing json.Marshaler interface
func (d Dot) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("[%d,%d]", d.X, d.Y)... | package engine
import "fmt"
type Dot struct {
X uint8
Y uint8
}
// Equals compares two dots
func (d1 Dot) Equals(d2 Dot) bool {
return d1 == d2 || (d1.X == d2.X && d1.Y == d2.Y)
}
// Implementing json.Marshaler interface
func (d Dot) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf("[%d,%d]", d.X, d.Y)... | Create Hash method to engine.Dot | Create Hash method to engine.Dot
| Go | bsd-2-clause | ivan1993spb/clever-snake |
736804a1326e0e2316c6b103824c61d88d137655 | graphs/celebrity.go | graphs/celebrity.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 graphs
// FindCelebrity returns an index into 2D slice f that represents a celebrity
// on the party who doesn't know no one. -1 is returned if ... | // 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 graphs
// FindCelebrity returns an index into 2D slice f that represents a celebrity
// on the party who doesn't know no one. -1 is returned if ... | Change local variables names in graphs.FindCelebrity function | Change local variables names in graphs.FindCelebrity function
This change makes code more readable.
| Go | mit | mrekucci/epi,mrekucci/epi |
cb5e3affcc4d7991a6f9c9fdbb8487cbd9d2a87b | examples/blink/blink.go | examples/blink/blink.go | package main
import (
"fmt"
"github.com/davecheney/gpio"
"os"
"os/signal"
"time"
)
func main() {
// set GPIO25 to output mode
pin, err := gpio.OpenPin(25)
if err != nil {
fmt.Printf("Error opening pin! %s\n", err)
return
}
pin.SetMode(gpio.ModeOutput)
// turn the led off on exit
c := make(chan os.Sig... | package main
import (
"fmt"
"github.com/davecheney/gpio"
"os"
"os/signal"
"time"
)
func main() {
// set GPIO25 to output mode
pin, err := gpio.OpenPin(25, gpio.ModeOutput)
if err != nil {
fmt.Printf("Error opening pin! %s\n", err)
return
}
// turn the led off on exit
c := make(chan os.Signal, 1)
sign... | Update example to use updated interface | Update example to use updated interface
| Go | bsd-2-clause | davecheney/gpio,griffina/gpio,alext/gpio |
801b1096548375642daa15fb221d6cdc9f5b5239 | commander.go | commander.go | package gobot
type commander struct {
commands map[string]func(map[string]interface{}) interface{}
}
// Commander is the interface which describes the behaviour for a Driver or Adaptor
// which exposes API commands.
type Commander interface {
// Command returns a command given a name. Returns nil if the command is ... | package gobot
type commander struct {
commands map[string]func(map[string]interface{}) interface{}
}
// Commander is the interface which describes the behaviour for a Driver or Adaptor
// which exposes API commands.
type Commander interface {
// Command returns a command given a name. Returns nil if the command is ... | Add missing godocs for Commander type | docs: Add missing godocs for Commander type
Signed-off-by: deadprogram <b937b287f61b7a223d4aac55072db1a5381d3bb3@hybridgroup.com>
| Go | apache-2.0 | nzmichaelh/gobot,nzmichaelh/gobot |
adc9f58df221cdfb8aae7a3f5af3c3a878d76dba | src/scummatlas/binaryutils/util.go | src/scummatlas/binaryutils/util.go | package binaryutils
import (
"encoding/binary"
"io/ioutil"
)
func BE32(data []byte, index int) int {
return int(binary.BigEndian.Uint32(data[index : index+4]))
}
func LE32(data []byte, index int) int {
return int(binary.LittleEndian.Uint32(data[index : index+4]))
}
func LE24(data []byte, index int) int {
three... | package binaryutils
import (
"encoding/binary"
"io/ioutil"
)
func BE32(data []byte, index int) int {
return int(binary.BigEndian.Uint32(data[index : index+4]))
}
func LE32(data []byte, index int) int {
return int(binary.LittleEndian.Uint32(data[index : index+4]))
}
func LE24(data []byte, index int) int {
fourb... | Fix 24bit little endian parser | Fix 24bit little endian parser
| Go | apache-2.0 | ktzar/scummatlas,ktzar/scummatlas,ktzar/scummatlas,ktzar/scummatlas |
fe7f7447725d7d454d8f632e2947de6d606a6a43 | cmd/mole/root_unix.go | cmd/mole/root_unix.go | // +build darwin linux
package main
import (
"log"
"strconv"
"syscall"
)
var realUid int
func init() {
sudoUid, ok := syscall.Getenv("SUDO_UID")
if ok {
var err error
realUid, err = strconv.Atoi(sudoUid)
if err != nil {
log.Fatal("SUDO_UID", err)
}
} else {
realUid = syscall.Getuid()
}
}
func g... | // +build darwin linux
package main
import (
"log"
"strconv"
"syscall"
)
var realUid int
func init() {
sudoUid, ok := syscall.Getenv("SUDO_UID")
if ok {
var err error
realUid, err = strconv.Atoi(sudoUid)
if err != nil {
log.Fatal("SUDO_UID", err)
}
} else {
realUid = syscall.Getuid()
}
}
func g... | Use setreuid instead of seteuid for compatibility | Use setreuid instead of seteuid for compatibility
| Go | mit | calmh/mole,reth-/mole,calmh/mole,reth-/mole |
0d172e3080f768fd419f0c97f5246983797db243 | shared/server.go | shared/server.go | package shared
type ServerStateEnvironment struct {
Addresses []string `json:"addresses"`
Architectures []string `json:"architectures"`
Certificate string `json:"certificate"`
CertificateFingerprint string `json:"certificate_fingerprint"`
Driver string `json:... | package shared
type ServerStateEnvironment struct {
Addresses []string `json:"addresses"`
Architectures []string `json:"architectures"`
Certificate string `json:"certificate"`
CertificateFingerprint string `json:"certificate_fingerprint"`
Driver string `json:... | Fix API info reporting in "lxc info" | Fix API info reporting in "lxc info"
Signed-off-by: Stéphane Graber <089afc6d81f66f1168a9849e15660feae286e024@ubuntu.com>
| Go | apache-2.0 | ollie314/lxd,Skarlso/lxd,stgraber/lxd,lxc/lxd,stgraber/lxd,lxc/lxd,chrisglass/lxd,stgraber/lxd,stgraber/lxd,jsavikko/lxd,techtonik/lxd,georghopp/lxd,erikmack/lxd,hallyn/lxd,hallyn/lxd,lxc/lxd,atxwebs/lxd,chrisglass/lxd,lxc/lxd,pcdummy/lxd,akshaykarle/lxd,jsavikko/lxd,Skarlso/lxd,mjeanson/lxd,atxwebs/lxd,pcdummy/lxd,lxc... |
32d3e4397ecb9fb3cb8bf87ab9b07f7a551f5447 | httphandlers/errorlogging.go | httphandlers/errorlogging.go | package httphandlers
import (
"github.com/gin-gonic/gin"
"github.com/pufferpanel/pufferd/logging"
)
func Recovery() gin.HandlerFunc {
return func(c *gin.Context) {
defer func() {
if err := recover(); err != nil {
logging.Errorf("Error handling route\n%+v", err)
}
}()
c.Next();
}
} | package httphandlers
import (
"github.com/gin-gonic/gin"
"github.com/pufferpanel/pufferd/logging"
"runtime/debug"
)
func Recovery() gin.HandlerFunc {
return func(c *gin.Context) {
defer func() {
if err := recover(); err != nil {
c.Status(500)
logging.Errorf("Error handling route\n%+v\n%s", err, debug... | Improve logging to print stacktrace on error | Improve logging to print stacktrace on error
| Go | apache-2.0 | PufferPanel/pufferd |
628b86fe1df445f9b0544a980123365ff96db68a | append_entries_test.go | append_entries_test.go | package raft
import (
"bytes"
"encoding/json"
"testing"
)
func BenchmarkAppendEntriesEncoding(b *testing.B) {
req, _ := createTestAppendEntriesRequest(2000)
for i := 0; i < b.N; i++ {
var buf bytes.Buffer
json.NewEncoder(&buf).Encode(req)
}
}
func BenchmarkAppendEntriesDecoding(b *testing.B) {
... | package raft
import (
"bytes"
"encoding/json"
"testing"
)
func BenchmarkAppendEntriesEncoding(b *testing.B) {
req, tmp := createTestAppendEntriesRequest(2000)
for i := 0; i < b.N; i++ {
var buf bytes.Buffer
json.NewEncoder(&buf).Encode(req)
}
b.SetBytes(int64(len(tmp)))
}
func BenchmarkAppendE... | Add throughput metrics to benchmark. | Add throughput metrics to benchmark.
| Go | mit | nckturner/influxdb,marcosnils/influxdb,nckturner/influxdb,gdi2290/influxdb,samaitra/influxdb,jgeiger/influxdb,jipperinbham/influxdb,ninjasphere/influxdb,sudabon/influxdb,evanphx/influxdb,lgpeterson/influxdb,trigrass2/influxdb,Ancillas/influxdb,roobert/influxdb,linfangrong/influxdb,toorop/influxdb,mengjinglei/influxdb,m... |
9a2175724af01291a82fdc2b9a790873036342dd | github/main.go | github/main.go | package main
import (
"html/template"
"log"
"os"
"time"
)
// Must method parses the template to ensure no errors;
// New method creates and returns a new template
var report = template.Must(template.New("issuelist").Parse(IssueList))
func main() {
result, err := SearchIssues(os.Args[1:])
if err != nil {
log.... | package main
import (
"html/template"
"log"
"os"
"time"
)
// Must method parses the template to ensure no errors;
// New method creates and returns a new template
var report = template.Must(template.New("issuelist").
// Funcs adds daysAgo as a function accessible inside the template
Funcs(template.FuncMap{"day... | Add daysAgo func to template | Add daysAgo func to template
| Go | mit | mlampedx/exercises-go |
f0db57cd1da3685c26ed3e307e210af611ab5729 | cmd/ami-publisher/listUnpackers.go | cmd/ami-publisher/listUnpackers.go | package main
import (
"fmt"
"github.com/Symantec/Dominator/imagepublishers/amipublisher"
libjson "github.com/Symantec/Dominator/lib/json"
"log"
"os"
)
func listUnpackersSubcommand(args []string, logger *log.Logger) {
err := listUnpackers(logger)
if err != nil {
fmt.Fprintf(os.Stderr, "Error preparing unpacke... | package main
import (
"fmt"
"github.com/Symantec/Dominator/imagepublishers/amipublisher"
libjson "github.com/Symantec/Dominator/lib/json"
"log"
"os"
)
func listUnpackersSubcommand(args []string, logger *log.Logger) {
err := listUnpackers(logger)
if err != nil {
fmt.Fprintf(os.Stderr, "Error listing unpackers... | Fix error message in ami-publisher list-unpackers subcommand. | Fix error message in ami-publisher list-unpackers subcommand.
| Go | apache-2.0 | Symantec/Dominator,rgooch/Dominator,rgooch/Dominator,keep94/Dominator,Symantec/Dominator,keep94/Dominator,Symantec/Dominator,keep94/Dominator,rgooch/Dominator |
890c166cadd83e916b6d6c1eaf1648bed3640ec3 | templates/content.go | templates/content.go | package templates
func ScopeTemplateContent() string {
return `#cloud-config
{{ .Name}}:
{{ range .Services }}{{ .GetName }}:
{{ range $key, $value := .GetParameters }}{{ $key }}: {{ $value }}
{{ end }}
{{ end }}units:
{{ range .Units }}- name: {{ .GetName }}
command: {{ .GetCommand }}
{{ end... | package templates
func ScopeTemplateContent() string {
return `#cloud-config
{{ .Name}}:
{{ range .Services }}{{ .GetName }}:
{{ range $key, $value := .GetParameters }}{{ $key }}: {{ $value }}
{{ end }}
{{ end }}units:
{{ range .Units }}- name: {{ .GetName }}
command: {{ .GetCommand }}
{{ e... | Fix identation error on template | Fix identation error on template
| Go | apache-2.0 | bernardolins/clustereasy,bernardolins/clustereasy |
439cd689dff5fc041b0f8a451eda6916dbac4072 | udocker.go | udocker.go | package main
import (
"os"
"os/exec"
"strconv"
)
func main() {
uid := strconv.Itoa(os.Getuid())
cmdargs := append([]string{"run", "-u", uid, "--rm", "-i"}, os.Args[1:]...)
cmd := exec.Command("docker", cmdargs...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
}
| package main
import (
"os"
"os/exec"
"strconv"
)
func main() {
uid := strconv.Itoa(os.Getuid())
cmdargs := append([]string{"run", "-u", uid, "--rm", "-i", "--"}, os.Args[1:]...)
cmd := exec.Command("docker", cmdargs...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
}
| Use -- to prevent illegal args passing to run | Use -- to prevent illegal args passing to run
Signed-off-by: Eric Windisch <96f164ad4d9b2b0dacf8ebee2bb1eeb3aa69adf1@windisch.us>
| Go | apache-2.0 | ewindisch/udocker |
c0b4ff5e384f2a5df721bac01f388810e3e0d30e | examples/channels_history.go | examples/channels_history.go | package main
import (
"fmt"
"github.com/bluele/slack"
)
// Please change these values to suit your environment
const (
token = "your-api-token"
channelName = "general"
)
func main() {
api := slack.New(token)
channel, err := api.FindChannelByName(channelName)
if err != nil {
panic(err)
}
msgs, err :=... | package main
import (
"fmt"
"github.com/bluele/slack"
)
// Please change these values to suit your environment
const (
token = "your-api-token"
channelName = "general"
)
func main() {
api := slack.New(token)
channel, err := api.FindChannelByName(channelName)
if err != nil {
panic(err)
}
msgs, err :=... | Use last API to load history messages from channel | Use last API to load history messages from channel | Go | mit | bluele/slack |
000813bb49d859b69cff62b16ac1ec7c7fb1ad59 | src/math_spec.go | src/math_spec.go | package main
import "./specify"
func init() {
specify.Behavior("Math", func(it *specify.It) {
it.Should("add integers", func(expect *specify.Expect) {
expect.That(1 + 2).Should.Be(4);
expect.That("foo").Should.Be("bar");
})
})
} | package main
import "./specify"
func init() {
specify.Behavior("Math", func(it *specify.It) {
it.Should("add", func(expect *specify.Expect) {
expect.That(1 + 2).Should.Be(3);
});
it.Should("multiply", func(expect *specify.Expect) {
expect.That(2 * 4).Should.Be(6);
});
});
specify.Behavior("Strings"... | Refactor spec to be more BDDish. | Refactor spec to be more BDDish. | Go | mit | stesla/gospecify,stesla/gospecify |
4a4d3e1ecdf1263d0b758076d07f883bb73c0bd9 | challenge46_test.go | challenge46_test.go | package cryptopals
import (
"encoding/base64"
"fmt"
"math/big"
"testing"
)
func TestDecryptRsaParityOracle(t *testing.T) {
priv := generateRsaPrivateKey(1024)
pub := priv.public()
fmt.Printf("n: %v\n\n", pub.n)
encoded := "VGhhdCdzIHdoeSBJIGZvdW5kIHlvdSBkb24ndCBwbGF5IGFyb3VuZCB3aXRoIHRoZSBGdW5reSBDb2xkIE1lZ... | package cryptopals
import (
"encoding/base64"
"fmt"
"math/big"
"testing"
)
func TestDecryptRsaParityOracle(t *testing.T) {
priv := generateRsaPrivateKey(1024)
pub := priv.public()
encoded := "VGhhdCdzIHdoeSBJIGZvdW5kIHlvdSBkb24ndCBwbGF5IGFyb3VuZCB3aXRoIHRoZSBGdW5reSBDb2xkIE1lZGluYQ=="
message, _ := base64.Ra... | Remove unneeded call to Println | Remove unneeded call to Println
| Go | mit | Metalnem/cryptopals-go,Metalnem/cryptopals-go,Metalnem/cryptopals-go |
146912ae9c43da6eea390fc58e6777757fd9746b | collector/http_util.go | collector/http_util.go | package collector
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
)
func HttpGet(endpoint string) (body []byte, err error) {
response, err := http.Get(endpoint)
if err != nil {
return nil, err
}
if response.StatusCode < 200 || response.StatusCode >= 300 {
return nil, errors.New(fmt.Sprintf(
"Got respons... | package collector
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
)
const (
userAgent = "metrics-collector/1.0"
)
func HttpGet(endpoint string) (body []byte, err error) {
// Configure custom UA header for tracing in mesos logs
request, err := http.NewRequest("GET", endpoint, nil)
if err != nil {
return nil,... | Include User-Agent header in outgoing HTTP requests | Include User-Agent header in outgoing HTTP requests
Mesos includes the agent string in logs, so this should make collector
requests more traceable
| Go | apache-2.0 | dcos/dcos-metrics,dcos/dcos-metrics,dcos/dcos-metrics,dcos/dcos-metrics,dcos/dcos-metrics |
5ff5f73465198312ab8f490a4a1dcbff125d351e | contrib/exporters/allinone/main.go | contrib/exporters/allinone/main.go | /*
* Copyright (C) 2019 IBM, 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 ofthe License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | /*
* Copyright (C) 2019 IBM, 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 ofthe License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... | Fix default config file name | contrib/exporters/allinone: Fix default config file name
| Go | apache-2.0 | lebauce/skydive,lebauce/skydive,skydive-project/skydive,skydive-project/skydive,lebauce/skydive,lebauce/skydive,lebauce/skydive,skydive-project/skydive,skydive-project/skydive,skydive-project/skydive,skydive-project/skydive,lebauce/skydive,lebauce/skydive,skydive-project/skydive,lebauce/skydive |
76d9fa255be7f727077bf48e2cc3acfb475f9975 | testutil/wait.go | testutil/wait.go | package testutil
import (
"time"
"testing"
"github.com/hashicorp/consul/consul/structs"
)
type testFn func() (bool, error)
type errorFn func(error)
func WaitForResult(test testFn, error errorFn) {
retries := 100
for retries > 0 {
time.Sleep(100 * time.Millisecond)
retries--
success, err := test()
if s... | package testutil
import (
"time"
"testing"
"github.com/hashicorp/consul/consul/structs"
)
type testFn func() (bool, error)
type errorFn func(error)
func WaitForResult(test testFn, error errorFn) {
retries := 1000
for retries > 0 {
time.Sleep(10 * time.Millisecond)
retries--
success, err := test()
if s... | Speed up test runs in `WaitForResult` | Speed up test runs in `WaitForResult`
| Go | mpl-2.0 | nicholascapo/consul,mckennajones/consul,vamage/consul,zeroae/consul,EasonYi/consul,calgaryscientific/consul,AlphaStaxLLC/consul,ryotarai/consul,marclop/consul,DivyaVavili/consul,nvoron23/consul,shaneog/consul,leowmjw/consul,mfischer-zd/consul,Pivotal-Pierre-Delagrave/consul,mbrukman/consul,linearregression/consul,Alpha... |
fca4ae33df3fb5eb3314f86b284711018bcdcc2f | src/translation/downloadhandler.go | src/translation/downloadhandler.go | /*
* Copyright (c) 2014 ZionSoft. All rights reserved.
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file.
*/
package translation
import (
"net/http"
"net/url"
"appengine"
"appengine/blobstore"
"src/core"
)
func DownloadTranslationHandler(w ... | /*
* Copyright (c) 2014 ZionSoft. All rights reserved.
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file.
*/
package translation
import (
"net/http"
"net/url"
"appengine"
"appengine/blobstore"
"src/core"
)
func DownloadTranslationHandler(w ... | Return 404 instead of 400 if the translation is not found. | Return 404 instead of 400 if the translation is not found.
| Go | bsd-3-clause | ZionSoft/Bible-Server,ZionSoft/Bible-Server |
5f0808175bc15069038ea1eaa6175d4ca928b951 | pkg/utils/utils_test.go | pkg/utils/utils_test.go | package utils
import (
"math/rand"
"sync"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRandomString(t *testing.T) {
rand.Seed(42)
s1 := RandomString(10)
s2 := RandomString(20)
rand.Seed(42)
s3 := RandomString(10)
s4 := RandomString(20)
assert.Len(t, s1, 10)
assert.Len(t, s2, 20)
assert.Le... | package utils
import (
"math/rand"
"sync"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRandomString(t *testing.T) {
rand.Seed(42)
s1 := RandomString(10)
s2 := RandomString(20)
rand.Seed(42)
s3 := RandomString(10)
s4 := RandomString(20)
assert.Len(t, s1, 10)
assert.Len(t, s2, 20)
assert.Le... | Check uniqueness of generated RandomStrings | Check uniqueness of generated RandomStrings
| Go | agpl-3.0 | sebn/cozy-stack,nono/cozy-stack,nono/cozy-stack,nono/cozy-stack,nono/cozy-stack,sebn/cozy-stack,sebn/cozy-stack,nono/cozy-stack,sebn/cozy-stack |
a0d849d3a5a1334fb18d24e0c8888f259bbce669 | webapp/webapp.go | webapp/webapp.go | package webapp
import (
"github.com/gorilla/mux"
"net/http"
)
type WebApp struct {
*mux.Router
handler http.Handler
}
type routeAgent interface {
BindRoute(app *WebApp)
}
func NewWebApp() *WebApp {
app := &WebApp{
Router: mux.NewRouter()}
app.handler = app.Router
return app
}
type Middleware func(http.Ha... | package webapp
import (
"github.com/gorilla/mux"
"net/http"
)
type WebApp struct {
*mux.Router
handler http.Handler
}
type routeAgent interface {
BindRoute(app *WebApp)
}
func NewWebApp() *WebApp {
app := &WebApp{
Router: mux.NewRouter()}
app.handler = app.Router
return app
}
type Middleware func(http.Ha... | Update some outdated function documentation | Update some outdated function documentation
| Go | mit | tsinghua-io/api-server |
734c1e9c3f485356501f8ea561b7b79adae3e6f5 | code/course-info/hello_http.go | code/course-info/hello_http.go | package main
import (
"fmt"
"html"
"io/ioutil"
"log"
"net/http"
)
func main() {
go http.ListenAndServe(":8282", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %s", html.EscapeString(r.URL.Path))
}))
res, err := http.Get("http://localhost:8282/world")
if err != nil {... | package main
import (
"fmt"
"html"
"io/ioutil"
"log"
"net/http"
)
func main() {
go http.ListenAndServe(":8282", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %s", html.EscapeString(r.URL.Path))
}))
res, err := http.Get("http://localhost:8282/world")
if err != nil {... | Refactor to use defer idiomatically | Refactor to use defer idiomatically | Go | mit | fmi/go-lectures,fmi/go-lectures,fmi/go-lectures,fmi/go-lectures |
e61acf6b42bf9ef446e6f9abd03c8b16030de1ae | elicit.go | elicit.go | // Package elicit is a native go BDD testing framework using markdown for executable specifications
package elicit
import (
"flag"
"regexp"
)
var (
reportFile = flag.String("elicit.report", "", "Path to save an execution report")
)
// New creates a new elicit context which stores specs, steps and transforms
func ... | // Package elicit is a native go BDD testing framework using markdown for executable specifications
package elicit
import (
"flag"
"fmt"
"path/filepath"
"regexp"
)
var (
reportFile = flag.String("elicit.report", "", "Path to save an execution report")
)
// New creates a new elicit context which stores specs, st... | Fix Bug with Relative Report Paths | Fix Bug with Relative Report Paths
Step execution can alter the working directory, so ensure we've
resolved the output path before running any tests.
| Go | bsd-2-clause | mpwalkerdine/elicit |
824911e61202060dfa41f012546faf0601776c4c | account.go | account.go | // GCloud - Go Packages for Cloud Services.
// Copyright (c) 2013 Garrett Woodworth (https://github.com/gwoo).
package identity
import ()
type Account struct{}
| // GCloud - Go Packages for Cloud Services.
// Copyright (c) 2013 Garrett Woodworth (https://github.com/gwoo).
package identity
import ()
type Account struct {
Key string
Token string
}
| Add some fields to Account. | Add some fields to Account.
| Go | bsd-3-clause | gcloud/identity |
6cc7365d2ec992f24519ec51445495d5d95888cc | client.go | client.go | package clc
import (
"github.com/CenturyLinkCloud/clc-sdk/aa"
"github.com/CenturyLinkCloud/clc-sdk/alert"
"github.com/CenturyLinkCloud/clc-sdk/api"
"github.com/CenturyLinkCloud/clc-sdk/dc"
"github.com/CenturyLinkCloud/clc-sdk/group"
"github.com/CenturyLinkCloud/clc-sdk/lb"
"github.com/CenturyLinkCloud/clc-sdk/s... | package clc
import (
"github.com/CenturyLinkCloud/clc-sdk/aa"
"github.com/CenturyLinkCloud/clc-sdk/alert"
"github.com/CenturyLinkCloud/clc-sdk/api"
"github.com/CenturyLinkCloud/clc-sdk/dc"
"github.com/CenturyLinkCloud/clc-sdk/group"
"github.com/CenturyLinkCloud/clc-sdk/lb"
"github.com/CenturyLinkCloud/clc-sdk/s... | Add support for using multiple aliases | Add support for using multiple aliases
| Go | apache-2.0 | mikebeyer/clc-sdk,mikebeyer/clc-sdk,CenturyLinkCloud/clc-sdk,ack/clc-sdk,ack/clc-sdk,CenturyLinkCloud/clc-sdk |
fd8f334f2670cd4c500cad1471ef2df73327cea7 | ury-rapid-go.go | ury-rapid-go.go | package main
import "os"
import "fmt"
import "net"
import "bufio"
func main() {
conn, err := net.Dial("tcp", "127.0.0.1:1350")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
for {
data, err := bufio.NewReader(conn).ReadString('\n')
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Printf(data)
}... | package main
import "os"
import "fmt"
import "net"
import "bufio"
import "bytes"
import "github.com/UniversityRadioYork/ury-rapid-go/tokeniser"
func main() {
conn, err := net.Dial("tcp", "127.0.0.1:1350")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
t := tokeniser.NewTokeniser()
for {
data, err := bufio.... | Print lines as they come in | Print lines as they come in
| Go | mit | UniversityRadioYork/bifrost,UniversityRadioYork/bifrost,UniversityRadioYork/heimdallr,UniversityRadioYork/heimdallr,UniversityRadioYork/bifrost,UniversityRadioYork/heimdallr |
02adfa95cc7ea83b13b135a67877b8669fb4ae0d | docker.go | docker.go | package dockercommand
import (
docker "github.com/fsouza/go-dockerclient"
"os"
)
type Docker struct {
client *docker.Client
}
func NewDocker(endpoint string) (*Docker, error) {
endpoint = resolveDockerEndpoint(endpoint)
client, err := docker.NewClient(resolveDockerEndpoint(endpoint))
if err != nil {
return n... | package dockercommand
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"log"
"net/http"
"os"
docker "github.com/fsouza/go-dockerclient"
)
type Docker struct {
client *docker.Client
}
func NewDocker(endpoint string) (*Docker, error) {
endpoint = resolveDockerEndpoint(endpoint)
client, err := docker.NewClien... | Handle TLS with Docker 1.3+ | Handle TLS with Docker 1.3+
| Go | mit | bywan/go-dockercommand |
3bfd0189e135d14a3da6af7ee26638660dd80b63 | groker.go | groker.go | package main
import (
"fmt"
"flag"
"bufio"
"os"
"encoding/json"
"github.com/gemsi/grok"
)
func main() {
pattern := flag.String("pattern", "%{GREEDYDATA:msg}", "a grok expression")
namedcapture := flag.Bool("namedcapture", false, "parse only named captures (default is false)")
flag.... | package main
import (
"bufio"
"encoding/json"
"flag"
"fmt"
"os"
"github.com/gemsi/grok"
)
func main() {
pattern := flag.String("pattern", "%{GREEDYDATA:msg}", "a grok expression")
namedcapture := flag.Bool("namedcapture", false, "parse only named captures (default is false)")
flag.Parse()
var g *grok.Grok... | Change to match the gemsi/grok New() usage update | Change to match the gemsi/grok New() usage update
| Go | unknown | palmerabollo/groker,palmerabollo/grok |
a9748f2657b41b03a4209baa8a04e07ba1c023b8 | errors.go | errors.go | package hdf5
// #include "hdf5.h"
//
// herr_t _go_hdf5_unsilence_errors(void) {
// return H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)(H5Eprint), stderr);
// }
//
// herr_t _go_hdf5_silence_errors(void) {
// return H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
// }
import "C"
import (
"fmt"
)
// DisplayErrors enables/disa... | package hdf5
// #include "hdf5.h"
//
// herr_t _go_hdf5_unsilence_errors(void) {
// return H5Eset_auto2(H5E_DEFAULT, (H5E_auto2_t)(H5Eprint), stderr);
// }
//
// herr_t _go_hdf5_silence_errors(void) {
// return H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
// }
import "C"
import (
"fmt"
)
// DisplayErrors enables/disa... | Replace switch on bool with if-else | Replace switch on bool with if-else
| Go | bsd-3-clause | disktnk/go-hdf5,sbinet/go-hdf5 |
27bc0818b7cea9ad1d585d4be89832bc85a14c3e | comp/comp_test.go | comp/comp_test.go | // Copyright (c) 2014, Rob Thornton
// All rights reserved.
// This source code is governed by a Simplied BSD-License. Please see the
// LICENSE included in this distribution for a copy of the full license
// or, if one is not included, you may also find a copy at
// http://opensource.org/licenses/BSD-2-Clause
package... | package comp_test
import (
"os"
"os/exec"
"testing"
"github.com/rthornton128/calc1/comp"
)
func TestInteger(t *testing.T) {
test_handler(t, "42", "42")
}
func TestSimpleExpression(t *testing.T) {
test_handler(t, "(+ 5 3)", "8")
}
func TestSimpleExpressionWithComments(t *testing.T) {
test_handler(t, ";commen... | Fix scan bug not properly fixed by commit 20f422c052 and add compiler tests | Fix scan bug not properly fixed by commit 20f422c052 and add compiler tests
| Go | bsd-2-clause | rthornton128/calc |
4eaa1d6e1d082f89729f8447c4e5007b5d75fe65 | draw2d/src/cmd/gettingStarted.go | draw2d/src/cmd/gettingStarted.go | package main
import (
"fmt"
"log"
"os"
"bufio"
"image"
"image/png"
"draw2d"
)
func saveToPngFile(filePath string, m image.Image) {
f, err := os.Open(filePath, os.O_CREAT|os.O_WRONLY, 0600)
if err != nil {
log.Println(err)
os.Exit(1)
}
defer f.Close()
b := bufio.NewWriter(f)
err = png.Encode(b, m)
... | package main
import (
"fmt"
"log"
"os"
"bufio"
"image"
"image/png"
"draw2d.googlecode.com/svn/trunk/draw2d/src/pkg/draw2d"
)
func saveToPngFile(filePath string, m image.Image) {
f, err := os.Open(filePath, os.O_CREAT|os.O_WRONLY, 0600)
if err != nil {
log.Println(err)
os.Exit(1)
}
defer f.Close()
b ... | Modify getting started to use svn url | Modify getting started to use svn url
| Go | bsd-2-clause | magj2006/draw2d,dddaisuke/draw2d,stephenwithav/draw2d,bigunagi/draw2d,dddaisuke/draw2d,zqc115322536/draw2d,iand/draw2d.newdraw2d,lain-dono/draw2d,xushiwei/draw2d,iand/draw2d,google-feinberg/feinberg-draw2d,bigunagi/draw2d,magj2006/draw2d.newdraw2d,google-feinberg/feinberg-draw2d,zqc115322536/draw2d.newdraw2d,stanim/dra... |
ac78c8d8ca36008e9a8afbd4775eb450dcdb8b2b | lunchy.go | lunchy.go | package main
import(
"fmt"
"os"
"io/ioutil"
"path/filepath"
)
const(
LUNCHY_VERSION = "0.1.0"
)
func printUsage() {
fmt.Printf("Lunchy %s, the friendly launchctl wrapper\n", LUNCHY_VERSION)
fmt.Println("Usage: lunchy [start|stop|restart|list|status|install|show|edit] [options]")
}
func findPlists(path... | package main
import(
"fmt"
"os"
"io/ioutil"
"path/filepath"
)
const(
LUNCHY_VERSION = "0.1.0"
)
func printUsage() {
fmt.Printf("Lunchy %s, the friendly launchctl wrapper\n", LUNCHY_VERSION)
fmt.Println("Usage: lunchy [start|stop|restart|list|status|install|show|edit] [options]")
}
func findPlists(path... | Use switch to handle user command | Use switch to handle user command
| Go | mit | sosedoff/lunchy-go,sosedoff/lunchy-go |
572b1f31acd143eef188936cc2efba7ec433af6f | packet.go | packet.go | package sphere
import (
"bytes"
"encoding/gob"
"encoding/json"
"errors"
)
// Packet indicates the data of the message
type Packet struct {
Success bool `json:"success"`
Type PacketType `json:"type"`
Channel string `json:"channel,omitempty"`
Cid int `json:"cid,omitempty"`
Rid int ... | package sphere
import (
"bytes"
"encoding/gob"
"encoding/json"
"errors"
)
// Packet indicates the data of the message
type Packet struct {
Type PacketType `json:"type"`
Namespace string `json:"namespace,omitempty"`
Room string `json:"room,omitempty"`
Cid int `json:"cid,omitempty... | Remove unused success and use "Error" object | Remove unused success and use "Error" object
| Go | mit | samuelngs/go-sphere |
53f26d7d04a38db0a5ce8b2c5c8cfe819ca148ac | webseed/request_test.go | webseed/request_test.go | package webseed
import (
"net/url"
"testing"
qt "github.com/frankban/quicktest"
)
func TestTrailingPath(t *testing.T) {
c := qt.New(t)
test := func(parts []string, result string) {
unescaped, err := url.QueryUnescape(trailingPath(parts[0], parts[1:]))
if !c.Check(err, qt.IsNil) {
return
}
c.Check(une... | package webseed
import (
"net/url"
"testing"
qt "github.com/frankban/quicktest"
)
func TestTrailingPath(t *testing.T) {
c := qt.New(t)
test := func(parts []string, result string) {
unescaped, err := url.QueryUnescape(trailingPath(parts[0], parts[1:]))
if !c.Check(err, qt.IsNil) {
return
}
c.Check(une... | Test that empty info names are ignored in multi-file torrent webseed URLs | Test that empty info names are ignored in multi-file torrent webseed URLs
| Go | mpl-2.0 | anacrolix/torrent,anacrolix/torrent |
6631db9b4532973843688d419acddea0eec51942 | src/dotnetcore/integration/push_app_second_time_test.go | src/dotnetcore/integration/push_app_second_time_test.go | package integration_test
import (
"path/filepath"
"github.com/cloudfoundry/libbuildpack/cutlass"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("pushing an app a second time", func() {
const (
DownloadRegexp = `Download \[.*/dotnet-sdk\..*\.tar\.xz\]`
CopyRegexp = `Copy \[.*/d... | package integration_test
import (
"path/filepath"
"github.com/cloudfoundry/libbuildpack/cutlass"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("pushing an app a second time", func() {
const (
DownloadRegexp = `Download \[.*/dotnet-sdk\..*\.tar\.xz\]`
CopyRegexp = `Copy \[.*/d... | Fix bug with buildpacks field not being set | Fix bug with buildpacks field not being set
Co-authored-by: An Yu <446e9838deaeb979640d56c46523b7c882d598cd@pivotal.io>
| Go | apache-2.0 | cloudfoundry-community/asp.net5-buildpack |
d78491a4910526b59c42689781b4926f433cadb0 | kbfsfuse/test_test.go | kbfsfuse/test_test.go | package main
import (
"flag"
"fmt"
"github.com/keybase/client/go/libkb"
bserver "github.com/keybase/kbfs/bserver"
"log"
"math/rand"
"testing"
"time"
)
var (
BServerRemote = flag.Bool("kbfs.bserverRemote", false, "which bserver to use, local or remote")
)
func init() {
flag.Parse()
}
func TestMain(m *testi... | package main
import (
"flag"
"fmt"
"log"
"math/rand"
"os"
"testing"
"time"
"github.com/keybase/client/go/libkb"
bserver "github.com/keybase/kbfs/bserver"
)
var (
BServerRemote = flag.Bool("kbfs.bserverRemote", false, "which bserver to use, local or remote")
)
func init() {
flag.Parse()
}
func TestMain(m... | Call os.Exit() with m.Run()'s return value | Call os.Exit() with m.Run()'s return value
This closes #149. This closes #151.
| Go | bsd-3-clause | keybase/kbfs,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/kbfs,keybase/client,keybase/client,keybase/kbfs,keybase/client,keybase/client,keybase/client,keybase/client,keybase/client,keybase/kbfs |
6e8965f3d3bc78e86d747ec57b40702c684111f8 | handler/response.go | handler/response.go | package handler
import (
"encoding/json"
"net/http"
"github.com/yuuki/dynamond/log"
)
func JSON(w http.ResponseWriter, status int, v interface{}) error {
res, err := json.Marshal(v)
if err != nil {
return err
}
w.WriteHeader(status)
w.Header().Set("Content-Type", "application/json")
w.Write(res)
return ... | package handler
import (
"encoding/json"
"net/http"
"github.com/yuuki/dynamond/log"
)
func JSON(w http.ResponseWriter, status int, v interface{}) {
res, err := json.Marshal(v)
if err != nil {
ServerError(w, err.Error())
return
}
w.WriteHeader(status)
w.Header().Set("Content-Type", "application/json")
w... | Add handling errors of json marshal | Add handling errors of json marshal
| Go | apache-2.0 | yuuki/diamondb,yuuki/diamondb |
9fca5f3f39cabb2bb2e5a53fd273e2e45c3b00a2 | src/drivers/websocket/websocket.go | src/drivers/websocket/websocket.go | package websocket
import (
"net/http"
"github.com/gorilla/websocket"
"github.com/spring1843/chat-server/src/chat"
"github.com/spring1843/chat-server/src/shared/logs"
)
var (
chatServerInstance *chat.Server
upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}
)
// Handl... | package websocket
import (
"net/http"
"github.com/gorilla/websocket"
"github.com/spring1843/chat-server/src/chat"
"github.com/spring1843/chat-server/src/shared/logs"
)
var (
chatServerInstance *chat.Server
upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin:... | Check http origin for Websocket | Check http origin for Websocket
| Go | mit | spring1843/chat-server |
82cdf2486557310ad85a95647cf5a8b94d16de40 | backend.go | backend.go | /* MEL app backend
Author: Alastair Hughes
Contact: <hobbitalastair at yandex dot com>
*/
package main
import (
"net/http"
"fmt"
"html"
)
// Handle a single HTTP request.
func MELHandler(writer http.ResponseWriter, request *http.Request) {
fmt.Printf("Handling request for %q\n", html.EscapeString(request.UR... | /*
MEL app backend.
Author: Alastair Hughes
Contact: <hobbitalastair at yandex dot com>
*/
package main
import (
"net/http"
"fmt"
"html"
)
// Handle a single HTTP request.
func Handle(writer http.ResponseWriter, request *http.Request) {
fmt.Printf("Handling request for %q\n", html.EscapeString(request.URL.... | Rewrite to use http.* for errors, fix function style | Rewrite to use http.* for errors, fix function style
| Go | mit | mel-app/backend |
eb35552fb363ccc70c0473a29e40161ead848e37 | daemon.go | daemon.go | package main
const daemonBinary = "dockerd"
// DaemonProxy acts as a cli.Handler to proxy calls to the daemon binary
type DaemonProxy struct{}
// NewDaemonProxy returns a new handler
func NewDaemonProxy() DaemonProxy {
return DaemonProxy{}
}
| package main
const daemonBinary = "dockerd"
// DaemonProxy acts as a cli.Handler to proxy calls to the daemon binary
type DaemonProxy struct{}
// NewDaemonProxy returns a new handler
func NewDaemonProxy() DaemonProxy {
return DaemonProxy{}
}
// Command returns a cli command handler if one exists
func (p DaemonProx... | Remove reflection on CLI init | Remove reflection on CLI init
before:
```
$ time docker --help
real 0m0.177s
user 0m0.000s
sys 0m0.040s
```
after:
```
$ time docker --help
real 0m0.010s
user 0m0.000s
sys 0m0.000s
```
Signed-off-by: Brian Goff <dc73d0991b982a8303e713ef531a313af77e242a@gmail.com>
| Go | apache-2.0 | ashfall/cli,gdevillele/cli,cpuguy83/cli,dnephin/cli,cpuguy83/cli,riyazdf/cli,redpanda/cli,thaJeztah/cli,allencloud/cli,Zebrilee/cli,thaJeztah/cli,docker/cli,allencloud/cli,redpanda/cli,ashfall/cli,dnephin/cli,Zebrilee/cli,e11137/cli,riyazdf/cli,e11137/cli,docker/cli |
fa834b3d2a342c0c2f7656f2a3191ed654f9bdb6 | defdir_windows.go | defdir_windows.go | // +build windows
package config
import (
"os"
"path/filepath"
)
func defaultDirectory() string {
base := filepath.Base(os.Args[0])
ext := filepath.Ext(base)
drv := os.Getenv("SystemDrive")
pdDir := "ProgramData"
name := base[0 : len(base)-len(ext)]
return filepath.Join(drv, pdDir, name, name)
}
| package config
import (
"os"
"path/filepath"
)
func defaultDirectory() string {
base := filepath.Base(os.Args[0])
ext := filepath.Ext(base)
drv := os.Getenv("SystemDrive")
pdDir := "ProgramData"
name := base[0 : len(base)-len(ext)]
return filepath.Join(drv, pdDir, name, name)
}
| Remove build tag from windows file. | Remove build tag from windows file.
| Go | mit | codemodus/config |
49437f7515d62783e390757d1afb9ef96308249e | errors.go | errors.go | package main
import (
"errors"
"fmt"
)
type ErrMalformedDB struct {
Bucket string
}
func (e ErrMalformedDB) Error() string {
return fmt.Sprintf("malformed database no %s bucket", e.Bucket)
}
type ErrNoService struct {
Name string
}
func (e ErrNoService) Error() string {
return fmt.Sprintf("no service %s foun... | package main
import (
"errors"
"fmt"
)
type ErrMalformedDB struct {
Bucket string
}
func (e ErrMalformedDB) Error() string {
return fmt.Sprintf("malformed database no %s bucket, initialise a service try 'rest help service init' for init help", e.Bucket)
}
type ErrNoService struct {
Name string
}
func (e ErrNo... | Improve malformed db error messages | Improve malformed db error messages
| Go | mit | zan-xhipe/rest |
4273e30e47896655080ffb57b4585adf3af69eb7 | github.go | github.go | package main
import (
"fmt"
"net/http"
"github.com/google/go-github/github"
)
func fetchLicenseList() ([]github.License, error) {
// Create default client
client := github.NewClient(nil)
// Fetch list of LICENSE from Github API
list, res, err := client.Licenses.List()
if err != nil {
return nil, err
}
... | package main
import (
"fmt"
"net/http"
"github.com/google/go-github/github"
)
func fetchLicenseList() ([]*github.License, error) {
// Create default client
client := github.NewClient(nil)
// Fetch list of LICENSE from Github API
list, res, err := client.Licenses.List()
if err != nil {
return nil, err
}
... | Update the type of the license list of Github API | Update the type of the license list of Github API
See https://github.com/google/go-github/commit/4ea1b10b743379453db2efbbc8fc5edb9b8dd1e8#diff-d4a3e908e3dc5265a44f849d7b9396c2
| Go | mit | tcnksm/license,tcnksm/license |
2be48978007b69726e0f84febd4a537524297cd2 | 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
https://golang.org/cl/183049
| Go | bsd-3-clause | jonathanmarvens/go,mk0x9/go,linux-on-ibm-z/go,agaurav/go,cookerzhu/go,parkdy/go,mikekap/go,lihuanghai/go,yangzhongj/go,vanloswang/go,stormltf/go,theass/go,Davidzhu001/go-1,klueska/go-akaros,odeke-em/go,odeke-em/go,CAFxX/go,jdeng/go,g522342435/go,g522342435/go,9618211/go,vsdutka/go,dkolbly/go,nawawi/go,jdhenke/go,shishk... |
e219224a98297212369e5576f5b203f498a8ea13 | filters/smudge.go | filters/smudge.go | package gitmediafilters
import (
".."
"../client"
"io"
"os"
)
func Smudge(writer io.Writer, sha string) error { // stdout, sha
mediafile := gitmedia.LocalMediaPath(sha)
reader, err := gitmediaclient.Get(mediafile)
if err != nil {
return &SmudgeError{sha, mediafile, err.Error()}
}
defer reader.Close()
me... | package gitmediafilters
import (
".."
"../client"
"io"
"os"
)
func Smudge(writer io.Writer, sha string) error {
mediafile := gitmedia.LocalMediaPath(sha)
if stat, err := os.Stat(mediafile); err != nil || stat == nil {
reader, err := gitmediaclient.Get(mediafile)
if err != nil {
return &SmudgeError{sha, ... | Create media file when it doesn't exist, use local copy when it does | Create media file when it doesn't exist, use local copy when it does
| Go | mit | ModernTechnologyPlayers01/git-lfs,dakotahawkins/git-lfs,ssgelm/git-lfs,iSC-Labs/git-lfs,ttaylorr/git-lfs,ModernTechnologyPlayers01/git-lfs,yonglehou/git-lfs,billygor/git-lfs,ssgelm/git-lfs,iSC-Labs/git-lfs,bozaro/git-lfs,beni55/git-lfs,billygor/git-lfs,ChaseFlorell/git-lfs,ryansimmen/git-lfs,WillHipschman/git-lfs,y12uc... |
efa3f7929d27a919286246551cb146506e734d13 | pkg/rand/random_std.go | pkg/rand/random_std.go | // Copyright 2020 the u-root 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 plan9
package rand
import (
"context"
"crypto/rand"
)
var defaultContextReader = &cryptoRandReader{}
type cryptoRandReader struct{}
// ReadC... | // Copyright 2020 the u-root 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 plan9 windows
package rand
import (
"context"
"crypto/rand"
)
var defaultContextReader = &cryptoRandReader{}
type cryptoRandReader struct{}
... | Use Go crypto/rand as rand implementation for Windows | Use Go crypto/rand as rand implementation for Windows
Signed-off-by: Guillaume Rose <2f62e3fe920ce0f1d8161b55fdcb51ab6116a042@redhat.com>
| Go | bsd-3-clause | u-root/u-root,u-root/u-root,u-root/u-root |
fa93655d90d1518b04e7cfca7d7548d7d133a34e | watchdog/metrics/metrics_test.go | watchdog/metrics/metrics_test.go | package metrics
import (
"testing"
"time"
)
func Test_RegisterServer(t *testing.T) {
metricsPort := 31111
metricsServer := MetricsServer{}
metricsServer.Register(metricsPort)
cancel := make(chan bool)
go metricsServer.Serve(cancel)
time.AfterFunc(time.Millisecond*500, func() {
cancel <- true
})
}
| package metrics
import (
"fmt"
"net/http"
"testing"
"time"
)
func Test_Register_ProvidesBytes(t *testing.T) {
metricsPort := 31111
metricsServer := MetricsServer{}
metricsServer.Register(metricsPort)
cancel := make(chan bool)
go metricsServer.Serve(cancel)
defer func() {
cancel <- true
}()
retries ... | Update test for metrics server | Update test for metrics server
Updates metrics server test so that it checks for the status
code and that bytes are returned.
Signed-off-by: Alex Ellis <5f7133baa0f5c7ca63ff11e11f2e2b0d2cf077c8@gmail.com>
| Go | mit | alexellis/faas,rgee0/faas,rgee0/faas,alexellis/faas,rgee0/faas,alexellis/faas,rgee0/faas,alexellis/faas,rgee0/faas,alexellis/faas,openfaas/faas,rgee0/faas,rgee0/faas,openfaas/faas,alexellis/faas,alexellis/faas,rgee0/faas,rgee0/faas,alexellis/faas,alexellis/faas,rgee0/faas,openfaas/faas |
df3a2d70505c11b1b832101e718fd084418175fb | runner.go | runner.go | package main
import (
"fmt"
"goof/plugs"
"github.com/codegangsta/cli"
"os"
)
func main() {
var (
plug string
debug bool
)
app := cli.NewApp()
app.Name = "goof"
app.Usage = "Extracts blogs from top web magazines"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "plug",
Value: "",
Usage: "Tells wh... | package main
import (
"fmt"
"goof/plugs"
"github.com/codegangsta/cli"
"os"
)
func main() {
var (
plug string
debug bool
page int
)
app := cli.NewApp()
app.Name = "goof"
app.Usage = "Extracts blogs from top web magazines"
app.Flags = []cli.Flag{
cli.IntFlag{
Name: "page",
Value: 1,
Usage: "T... | Add functionality for multiple pages | Add functionality for multiple pages
| Go | mit | umayr/goof |
2c2004859bfb38fde111d3a5f1c0d4df3d501c07 | x/validator/types/proposed_disable_validator.go | x/validator/types/proposed_disable_validator.go | package types
import sdk "github.com/cosmos/cosmos-sdk/types"
func (disabledValidator ProposedDisableValidator) HasApprovalFrom(address sdk.AccAddress) bool {
addrStr := address.String()
for _, approval := range disabledValidator.Approvals {
if approval.Address == addrStr {
return true
}
}
return false
}
| package types
import sdk "github.com/cosmos/cosmos-sdk/types"
func (disabledValidator ProposedDisableValidator) HasApprovalFrom(address sdk.AccAddress) bool {
addrStr := address.String()
for _, approval := range disabledValidator.Approvals {
if approval.Address == addrStr {
return true
}
}
return false
}
... | Add function for checking has reject disable from some account | Add function for checking has reject disable from some account
| Go | apache-2.0 | zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger,zigbee-alliance/distributed-compliance-ledger |
af819e8db4e198b56639025a9efee24fbff50faa | template/assets/css_bundler.go | template/assets/css_bundler.go | package assets
import (
"gnd.la/log"
"io"
)
type cssBundler struct {
}
func (c *cssBundler) Bundle(w io.Writer, r io.Reader, opts Options) error {
p, n, err := reducer("css", w, r)
if err != nil {
return err
}
log.Debugf("Reduced CSS size from %d to %d bytes", p, n)
return err
}
func (c *cssBundler) Type()... | package assets
import (
"io"
"os/exec"
"gnd.la/log"
)
var (
cleanCSSPath, _ = exec.LookPath("cleancss")
)
type cssBundler struct {
}
func (c *cssBundler) Bundle(w io.Writer, r io.Reader, opts Options) error {
if cleanCSSPath != "" {
return command(cleanCSSPath, []string{"--s0"}, w, r, opts)
}
p, n, err :=... | Add support for bundling CSS locally with cleancss | Add support for bundling CSS locally with cleancss
| Go | mpl-2.0 | rainycape/gondola,rainycape/gondola,rainycape/gondola,rainycape/gondola |
98bae9747cc550a1d7a0038d1785591f863e762f | errors/http_error.go | errors/http_error.go | package errors
import (
"encoding/json"
"net/http"
)
type HttpError struct {
Code int `json:"code"`
Message string `json:"message"`
}
var HttpErrors map[string]*HttpError = map[string]*HttpError {
"ErrorApiKeyMandatory": &HttpError{Code: 403, Message: "apikey is mandatory"},
"ErrorApiKeyInvalid": &Http... | package errors
import (
"encoding/json"
"net/http"
)
type HttpError struct {
Code int `json:"code"`
Message string `json:"message"`
}
var HttpErrors map[string]*HttpError = map[string]*HttpError {
"ErrorApiKeyMandatory": &HttpError{Code: 401, Message: "apikey is mandatory"},
"ErrorApiKeyInvalid": &Http... | Fix wrong http code for errors | Fix wrong http code for errors
| Go | mit | xaviergodart/gydro |
c8fe8c5d2ddb56ce412cc49385605f2140131bde | cmd/twsereport/filter/filter_test.go | cmd/twsereport/filter/filter_test.go | package filter
import (
"testing"
"time"
"github.com/toomore/gogrs/tradingdays"
"github.com/toomore/gogrs/twse"
)
var stock = twse.NewTWSE("2618", tradingdays.FindRecentlyOpened(time.Now()))
func TestCheckGroup(t *testing.T) {
for i, v := range AllList {
t.Log(i, v.No(), v.String(), v.Mindata(), v.CheckFunc(... | package filter
import (
"testing"
"time"
"github.com/toomore/gogrs/twse"
"github.com/toomore/gogrs/utils"
)
var stocklist = []*twse.Data{
twse.NewTWSE("2618", time.Date(2017, 4, 7, 0, 0, 0, 0, utils.TaipeiTimeZone)),
twse.NewTWSE("2618", time.Date(2017, 3, 21, 0, 0, 0, 0, utils.TaipeiTimeZone)),
twse.NewTWSE(... | Add more test for filter | Add more test for filter
| Go | mit | toomore/gogrs,toomore/gogrs |
5c3ed5d14c129b7cf0370081e0d73203341c11a1 | message.go | message.go | package coinbase
type Message struct {
Type string `json:"type"`
TradeId int `json:"trade_id,number"`
OrderId string `json:"order_id"`
Sequence int `json:"sequence,number"`
MakerOrderId string `json:"maker_order_id"`
TakerOrderId string `json:"taker_order_id"`
Time Time `json:"time,string"`
RemainingSi... | package coinbase
type Message struct {
Type string `json:"type"`
TradeId int `json:"trade_id,number"`
OrderId string `json:"order_id"`
Sequence int `json:"sequence,number"`
MakerOrderId string `json:"maker_order_id"`
TakerOrderId string `json:"taker_order_id"`
Time Time `json:"time,string"`
RemainingSi... | Add new fields to Message. | Add new fields to Message.
Updating according to https://developers.coinbase.com/blog/2015/06/21/exchange-feed-changes
| Go | mit | preichenberger/go-coinbase-exchange |
28223969d81015cd2ad11e54c3d65868999b97c8 | people_cypher_test.go | people_cypher_test.go | package main
import (
"github.com/jmcvetta/neoism"
"github.com/stretchr/testify/assert"
"testing"
)
func TestCreate(t *testing.T) {
assert := assert.New(t)
person := person{UUID: "123", Name: "Test", Identifiers: []identifier{identifier{fsAuthority, "FACTSET_ID"}}}
db, err := neoism.Connect("http://localhost:7... | // +build !jenkins
package main
import (
"github.com/jmcvetta/neoism"
"github.com/stretchr/testify/assert"
"testing"
)
func TestCreate(t *testing.T) {
assert := assert.New(t)
person := person{UUID: "123", Name: "Test", Identifiers: []identifier{identifier{fsAuthority, "FACTSET_ID"}}}
db, err := neoism.Connect... | Tag tests that require a local neo4j instance to not run for tests run for: go test -tags jenkins | Tag tests that require a local neo4j instance to not run for tests run for: go test -tags jenkins
| Go | mit | Financial-Times/people-rw-neo4j |
44242d5740b531e5f8e914d7b5320c1432cd7d3d | state_machine/state.go | state_machine/state.go | package state_machine
import "strings"
type State struct {
State string
StateChangeLogs []StateChangeLog
}
func (state *State) SetState(name string) {
state.State = name
}
func (state *State) GetState() string {
return state.State
}
func (s *State) UnmarshalJSON(data []byte) error {
s.SetState(strin... | package state_machine
import "strings"
type State struct {
State string
StateChangeLogs []StateChangeLog `sql:"-"`
}
func (state *State) SetState(name string) {
state.State = name
}
func (state *State) GetState() string {
return state.State
}
func (s *State) UnmarshalJSON(data []byte) error {
s.SetS... | Save save StateChangeLog from embedded structs | Save save StateChangeLog from embedded structs
| Go | mit | strogo/qor,yanzay/qor,gavinzhs/qor,shaunstanislaus/qor,strogo/qor,lance2088/qor,qor/qor,trigrass2/qor,shidao-fm/qor,jmptrader/qor,codevlabs/qor,codedogfish/qor,qor/qor,trigrass2/qor,insionng/qor,gavinzhs/qor,amirrpp/qor,youprofit/qor,insionng/qor,amirrpp/qor,youprofit/qor,shidao-fm/qor,yanzay/qor,codedogfish/qor,jmptra... |
c074f635f3681f2fb29d4350e34a528a18fbce1e | command/funcs/private_host_create.go | command/funcs/private_host_create.go | package funcs
import (
"fmt"
"github.com/sacloud/usacloud/command"
"github.com/sacloud/usacloud/command/params"
)
func PrivateHostCreate(ctx command.Context, params *params.CreatePrivateHostParam) error {
client := ctx.GetAPIClient()
api := client.GetPrivateHostAPI()
p := api.New()
// set params
p.SetName... | package funcs
import (
"fmt"
"github.com/sacloud/usacloud/command"
"github.com/sacloud/usacloud/command/params"
)
func PrivateHostCreate(ctx command.Context, params *params.CreatePrivateHostParam) error {
client := ctx.GetAPIClient()
api := client.GetPrivateHostAPI()
p := api.New()
// set params
p.SetName... | Use filtering parameter at ProductPrivateHost API | Use filtering parameter at ProductPrivateHost API
| Go | apache-2.0 | sacloud/usacloud,yamamoto-febc/usacloud,sacloud/usacloud,yamamoto-febc/usacloud |
b5429f99a49631390261994a5ca8283b548d0564 | rfc3797.go | rfc3797.go | package rfc3797
import (
"math"
)
func main() {
}
func Entropy(n int, p int) int {
i := 0
result := 0.0
// These cases represent invalid input values.
if (n < 1) || (n >= p) {
return 0.0
}
for i = p; i > (p - n); i-- {
result += math.Log(float64(i))
}
for i = n; i > 1; i-- {
result -= math.Log(flo... | package rfc3797
import (
"math"
)
func main() {
}
func usage() {
}
func Entropy(n int, p int) int {
i := 0
result := 0.0
// These cases represent invalid input values.
if (n < 1) || (n >= p) {
return 0
}
for i = p; i > (p - n); i-- {
result += math.Log(float64(i))
}
for i = n; i > 1; i-- {
resul... | Return value for degenerate cases is more clearly not a float. | Return value for degenerate cases is more clearly not a float.
| Go | isc | kyleroot/go-sortition |
bddf1a99a2f09e30e9e7bc082e4bf0594b6dd069 | commands/helloworld_command_test.go | commands/helloworld_command_test.go | package commands
import (
"testing"
)
func TestHelloworld(t *testing.T) {
want := "Hello world!"
got := "Hello world!"
if got != want {
t.Errorf("Expected '%v' got '%v'", want, got)
}
}
| package commands
import (
"testing"
)
func TestHelloworld(t *testing.T) {
want := "Hello world!"
got := Helloworld([]string{"any string"})
if got != want {
t.Errorf("Expected '%v' got '%v'", want, got)
}
}
| Fix for helloworld command test | Fix for helloworld command test
| Go | mit | nloadholtes/go-bot,go-chat-bot/bot,pyinx/bot,go-chat-bot/bot,martinusso/plugins,nloadholtes/go-bot,go-chat-bot/plugins,fabioxgn/go-bot,fabioxgn/go-bot,pyinx/bot,go-chat-bot/plugins-br,martinusso/bot |
6af9fabc9afe4e2f0e127130332e00d858ff394d | info.go | info.go | package main
import "encoding/json"
import "fmt"
import "io/ioutil"
import "net/http"
func GetInfo(url string) map[string]interface{} {
resp, err := http.Get(url)
Check(err)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var data map[string]interface{}
var jErr = json.Unmarshal(body, &data)
Ch... | package main
import "encoding/json"
import "fmt"
import "io/ioutil"
import "net/http"
func GetInfo(url string) map[string]interface{} {
resp, err := http.Get(url)
Check(err)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
var data map[string]interface{}
var jErr = json.Unmarshal(body, &data)
Ch... | Change API host to ntwrk.waits.io | Change API host to ntwrk.waits.io
| Go | mit | waits/ntwrk-cli |
be3ca4d050d41ba9e24d9814ca4b77c2a006235a | util/rootnames_test.go | util/rootnames_test.go | package util
import (
"os/exec"
"reflect"
"sort"
"strings"
"testing"
)
func TestRootNames(t *testing.T) {
// NOTE: will fail if there are newlines in /*.
want, err := exec.Command("ls", "/").Output()
mustOK(err)
wantNames := strings.Split(strings.Trim(string(want), "\n"), "\n")
for i := range wantNames {
... | package util
import (
"os/exec"
"reflect"
"sort"
"strings"
"testing"
)
func TestRootNames(t *testing.T) {
// NOTE: will fail if there are newlines in /*.
want, err := exec.Command("ls", "-A", "/").Output()
mustOK(err)
wantNames := strings.Split(strings.Trim(string(want), "\n"), "\n")
for i := range wantName... | Use "ls -A" to test against RootNames. | Use "ls -A" to test against RootNames.
| Go | bsd-2-clause | elves/elvish,elves/elvish,elves/elvish,elves/elvish,elves/elvish |
ee8f3f8991405d6fda391e883d4df5340cfb264a | pair.go | pair.go | package rel
// A Pair consisting of an element and its real value.
type Pair struct {
Element interface{}
Value float64
}
// MakePair evaluates the input function f at the input x and returns
// the associated (element, mass) pair.
func MakePair(f func(interface{}) float64, x interface{}) *Pair {
return &Pair{
... | package rel
// A Pair consisting of an element and its real value.
type Pair struct {
Element interface{}
Value float64
}
// NewPair creates a *Pair from the input interface and value.
func NewPair(elem interface{}, val float64) *Pair {
return &Pair{
Element: elem,
Value: val,
}
}
| Replace MakePair with NewPair constructor. | Replace MakePair with NewPair constructor.
| Go | mit | shawnohare/go-rel |
3c9f390b2a7ca2afe293fde604a8cd821687e99b | src/gatekeeper/main.go | src/gatekeeper/main.go | package main
import (
"io"
"log"
"net/http"
)
func main() {
http.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "gatekeeper v0")
})
log.Fatal(http.ListenAndServe(":800", nil))
}
| package main
import (
"errors"
"io"
"log"
"net/http"
)
type gatekeeper struct {
objects map[string] struct {
value string
owner string
permissions map[string]bool
}
owners map[string]bool
}
func(g *gatekeeper) Get(item, key string) (value string, err error) {
err = er... | Add the core datastructure and some items | gatekeeper: Add the core datastructure and some items
| Go | apache-2.0 | c00w/skeleton,c00w/skeleton,c00w/skeleton |
16d1b7e80e99b1ac4fac8a822d4fc252fdd24058 | middleware/middleware.go | middleware/middleware.go | package middleware
import (
"github.com/labstack/echo"
"strings"
"net/http"
"log"
)
func ServerInfo(pipe echo.HandlerFunc) echo.HandlerFunc{
return func (c echo.Context) error{
c.Response().Header().Set(echo.HeaderServer, "GoChat/1.0")
c.Response().Header().Set("Author", "Ethan Garnier")
return pipe(c)
}
... | package middleware
import (
"github.com/labstack/echo"
"strings"
"net/http"
"log"
)
func ServerInfo(pipe echo.HandlerFunc) echo.HandlerFunc{
return func (c echo.Context) error{
c.Response().Header().Set(echo.HeaderServer, "GoChat/1.0")
c.Response().Header().Set("Author", "Ethan Garnier")
return pipe(c)
}
... | Use UUID with cookie checker | Use UUID with cookie checker
| Go | apache-2.0 | EthanG78/golang_chat,EthanG78/GoChat,EthanG78/GoChat |
30ece74c19d39788d2a48bee0771c2f5892bfdd5 | src/webserver/router.go | src/webserver/router.go | package webserver
import (
"fmt"
"reflect"
)
/*
Interacts with urls.go to route requests to their corresponding functions.
Wires the capture groups from a url's regex to the callbacks arguments
*/
type router struct {
*callbackHandler
}
func NewRouter() *router {
cbh := newcallbackHandler()
r :=... | package webserver
import (
"net/http"
"reflect"
)
/*
Interacts with urls.go to route requests to their corresponding functions.
Wires the capture groups from a url's regex to the callbacks arguments
*/
type router struct {
cbh *callbackHandler
}
func NewRouter() *router {
cbh := newcallbackHandler()... | Refactor to remove embedded urls struct | Refactor to remove embedded urls struct
| Go | mit | edbrown23/SubtleLion |
706797bd56e2cfab5c821b977cb2cd63f6a99587 | container/container.go | container/container.go | // Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package container
import (
"launchpad.net/juju-core/environs"
"launchpad.net/juju-core/environs/config"
"launchpad.net/juju-core/state"
"launchpad.net/juju-core/state/api"
)
// A Container represents a containerized virt... | // Copyright 2013 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package container
import (
"launchpad.net/juju-core/environs/config"
"launchpad.net/juju-core/instance"
"launchpad.net/juju-core/state"
"launchpad.net/juju-core/state/api"
)
// A Container represents a containerized virt... | Make a Container contain an instance.Instance. | Make a Container contain an instance.Instance. | Go | agpl-3.0 | cloud-green/juju,perrito666/juju,howbazaar/juju,marcmolla/juju,AdamIsrael/juju,dimitern/juju,bz2/juju,ericsnowcurrently/juju,sinzui/juju,frankban/juju,marcoceppi/juju,frankban/juju-tmp,perrito666/juju,waigani/juju,thomnico/juju,ericsnowcurrently/juju,tsakas/juju,anastasiamac/juju,cloud-green/juju,tsakas/juju,dimitern/j... |
56ab6a330a050dc12ef42888fb02386e2d378b43 | lib/verstr/less_test.go | lib/verstr/less_test.go | package verstr
import (
"testing"
)
func TestLess(t *testing.T) {
var tests = []struct {
left, right string
want bool
}{
{"file.1.ext", "file.10.ext", true},
{"file.10.ext", "file.1.ext", false},
{"sparse", "sparse.0", true},
{"sparse.0", "sparse", false},
}
for _, test := range tests {
if g... | package verstr
import (
"testing"
)
func TestLess(t *testing.T) {
var tests = []struct {
left, right string
want bool
}{
{"file.0.ext", "file.1.ext", true},
{"file.1.ext", "file.0.ext", false},
{"file.1.ext", "file.10.ext", true},
{"file.10.ext", "file.1.ext", false},
{"sparse", "sparse.0", tr... | Add another pair to test for lib/verstr.Less(). | Add another pair to test for lib/verstr.Less().
| Go | apache-2.0 | rgooch/Dominator,keep94/Dominator,keep94/Dominator,keep94/Dominator,Symantec/Dominator,rgooch/Dominator,Symantec/Dominator,Symantec/Dominator,rgooch/Dominator |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.