This commit is contained in:
Jeff Mitchell 2017-02-16 23:42:07 -05:00
parent 4a966726e5
commit 776e120740
169 changed files with 2838 additions and 1693 deletions

View File

@ -27,6 +27,7 @@ type ACLRole string
const (
RoleOwner ACLRole = "OWNER"
RoleReader ACLRole = "READER"
RoleWriter ACLRole = "WRITER"
)
// ACLEntity refers to a user or group.

View File

@ -82,7 +82,7 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error
option.WithUserAgent(userAgent),
}
opts = append(o, opts...)
hc, _, err := transport.NewHTTPClient(ctx, opts...)
hc, ep, err := transport.NewHTTPClient(ctx, opts...)
if err != nil {
return nil, fmt.Errorf("dialing: %v", err)
}
@ -90,6 +90,9 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error
if err != nil {
return nil, fmt.Errorf("storage client: %v", err)
}
if ep != "" {
rawService.BasePath = ep
}
return &Client{
hc: hc,
raw: rawService,
@ -508,27 +511,33 @@ func (o *ObjectHandle) NewRangeReader(ctx context.Context, offset, length int64)
return nil, err
}
var res *http.Response
err = runWithRetry(ctx, func() error { res, err = o.c.hc.Do(req); return err })
err = runWithRetry(ctx, func() error {
res, err = o.c.hc.Do(req)
if err != nil {
return err
}
if res.StatusCode == http.StatusNotFound {
res.Body.Close()
return ErrObjectNotExist
}
if res.StatusCode < 200 || res.StatusCode > 299 {
body, _ := ioutil.ReadAll(res.Body)
res.Body.Close()
return &googleapi.Error{
Code: res.StatusCode,
Header: res.Header,
Body: string(body),
}
}
if offset > 0 && length != 0 && res.StatusCode != http.StatusPartialContent {
res.Body.Close()
return errors.New("storage: partial request not satisfied")
}
return nil
})
if err != nil {
return nil, err
}
if res.StatusCode == http.StatusNotFound {
res.Body.Close()
return nil, ErrObjectNotExist
}
if res.StatusCode < 200 || res.StatusCode > 299 {
body, _ := ioutil.ReadAll(res.Body)
res.Body.Close()
return nil, &googleapi.Error{
Code: res.StatusCode,
Header: res.Header,
Body: string(body),
}
}
if offset > 0 && length != 0 && res.StatusCode != http.StatusPartialContent {
res.Body.Close()
return nil, errors.New("storage: partial request not satisfied")
}
var size int64 // total size of object, even if a range was requested.
if res.StatusCode == http.StatusPartialContent {

View File

@ -228,7 +228,7 @@ This is the easiest part:
```go
...
jsonParsedObj := gabs.ParseJSON([]byte(`{
jsonParsedObj, _ := gabs.ParseJSON([]byte(`{
"outter":{
"values":{
"first":10,

View File

@ -24,6 +24,13 @@ type ConfigProvider interface {
ClientConfig(serviceName string, cfgs ...*aws.Config) Config
}
// ConfigNoResolveEndpointProvider same as ConfigProvider except it will not
// resolve the endpoint automatically. The service client's endpoint must be
// provided via the aws.Config.Endpoint field.
type ConfigNoResolveEndpointProvider interface {
ClientConfigNoResolveEndpoint(cfgs ...*aws.Config) Config
}
// A Client implements the base client request and response handling
// used by all service clients.
type Client struct {

View File

@ -27,6 +27,25 @@ type Options struct {
// error will be returned. This option will prevent returning endpoints
// that look valid, but may not resolve to any real endpoint.
StrictMatching bool
// Enables resolving a service endpoint based on the region provided if the
// service does not exist. The service endpoint ID will be used as the service
// domain name prefix. By default the endpoint resolver requires the service
// to be known when resolving endpoints.
//
// If resolving an endpoint on the partition list the provided region will
// be used to determine which partition's domain name pattern to the service
// endpoint ID with. If both the service and region are unkonwn and resolving
// the endpoint on partition list an UnknownEndpointError error will be returned.
//
// If resolving and endpoint on a partition specific resolver that partition's
// domain name pattern will be used with the service endpoint ID. If both
// region and service do not exist when resolving an endpoint on a specific
// partition the partition's domain pattern will be used to combine the
// endpoint and region together.
//
// This option is ignored if StrictMatching is enabled.
ResolveUnknownService bool
}
// Set combines all of the option functions together.
@ -54,6 +73,12 @@ func StrictMatchingOption(o *Options) {
o.StrictMatching = true
}
// ResolveUnknownServiceOption sets the ResolveUnknownService option. Can be used
// as a functional option when resolving endpoints.
func ResolveUnknownServiceOption(o *Options) {
o.ResolveUnknownService = true
}
// A Resolver provides the interface for functionality to resolve endpoints.
// The build in Partition and DefaultResolver return value satisfy this interface.
type Resolver interface {
@ -114,15 +139,18 @@ func (p *Partition) ID() string { return p.id }
//
// If the service cannot be found in the metadata the UnknownServiceError
// error will be returned. This validation will occur regardless if
// StrictMatching is enabled.
// StrictMatching is enabled. To enable resolving unknown services set the
// "ResolveUnknownService" option to true. When StrictMatching is disabled
// this option allows the partition resolver to resolve a endpoint based on
// the service endpoint ID provided.
//
// When resolving endpoints you can choose to enable StrictMatching. This will
// require the provided service and region to be known by the partition.
// If the endpoint cannot be strictly resolved an error will be returned. This
// mode is useful to ensure the endpoint resolved is valid. Without
// StrictMatching enabled the enpoint returned my look valid but may not work.
// StrictMatching enabled the endpoint returned my look valid but may not work.
// StrictMatching requires the SDK to be updated if you want to take advantage
// of new regions and services expantions.
// of new regions and services expansions.
//
// Errors that can be returned.
// * UnknownServiceError

View File

@ -79,7 +79,9 @@ func (p partition) EndpointFor(service, region string, opts ...func(*Options)) (
opt.Set(opts...)
s, hasService := p.Services[service]
if !hasService {
if !(hasService || opt.ResolveUnknownService) {
// Only return error if the resolver will not fallback to creating
// endpoint based on service endpoint ID passed in.
return resolved, NewUnknownServiceError(p.ID, service, serviceList(p.Services))
}

View File

@ -404,6 +404,10 @@ func (s *Session) clientConfigWithErr(serviceName string, cfgs ...*aws.Config) (
func(opt *endpoints.Options) {
opt.DisableSSL = aws.BoolValue(s.Config.DisableSSL)
opt.UseDualStack = aws.BoolValue(s.Config.UseDualStack)
// Support the condition where the service is modeled but its
// endpoint metadata is not available.
opt.ResolveUnknownService = true
},
)
}
@ -416,3 +420,27 @@ func (s *Session) clientConfigWithErr(serviceName string, cfgs ...*aws.Config) (
SigningName: resolved.SigningName,
}, err
}
// ClientConfigNoResolveEndpoint is the same as ClientConfig with the exception
// that the EndpointResolver will not be used to resolve the endpoint. The only
// endpoint set must come from the aws.Config.Endpoint field.
func (s *Session) ClientConfigNoResolveEndpoint(cfgs ...*aws.Config) client.Config {
s = s.Copy(cfgs...)
var resolved endpoints.ResolvedEndpoint
region := aws.StringValue(s.Config.Region)
if ep := aws.StringValue(s.Config.Endpoint); len(ep) > 0 {
resolved.URL = endpoints.AddScheme(ep, aws.BoolValue(s.Config.DisableSSL))
resolved.SigningRegion = region
}
return client.Config{
Config: s.Config,
Handlers: s.Handlers,
Endpoint: resolved.URL,
SigningRegion: resolved.SigningRegion,
SigningName: resolved.SigningName,
}
}

View File

@ -5,4 +5,4 @@ package aws
const SDKName = "aws-sdk-go"
// SDKVersion is the version of this SDK
const SDKVersion = "1.6.19"
const SDKVersion = "1.6.24"

File diff suppressed because it is too large Load Diff

View File

@ -498,7 +498,7 @@ func (c *EC2) WaitUntilKeyPairExists(input *DescribeKeyPairsInput) error {
Acceptors: []waiter.WaitAcceptor{
{
State: "success",
Matcher: "pathAll",
Matcher: "path",
Argument: "length(KeyPairs[].KeyName) > `0`",
Expected: true,
},
@ -921,6 +921,39 @@ func (c *EC2) WaitUntilVpcExists(input *DescribeVpcsInput) error {
return w.Wait()
}
// WaitUntilVpcPeeringConnectionDeleted uses the Amazon EC2 API operation
// DescribeVpcPeeringConnections to wait for a condition to be met before returning.
// If the condition is not meet within the max attempt window an error will
// be returned.
func (c *EC2) WaitUntilVpcPeeringConnectionDeleted(input *DescribeVpcPeeringConnectionsInput) error {
waiterCfg := waiter.Config{
Operation: "DescribeVpcPeeringConnections",
Delay: 15,
MaxAttempts: 40,
Acceptors: []waiter.WaitAcceptor{
{
State: "success",
Matcher: "pathAll",
Argument: "VpcPeeringConnections[].Status.Code",
Expected: "deleted",
},
{
State: "success",
Matcher: "error",
Argument: "",
Expected: "InvalidVpcPeeringConnectionID.NotFound",
},
},
}
w := waiter.Waiter{
Client: c,
Input: input,
Config: waiterCfg,
}
return w.Wait()
}
// WaitUntilVpcPeeringConnectionExists uses the Amazon EC2 API operation
// DescribeVpcPeeringConnections to wait for a condition to be met before returning.
// If the condition is not meet within the max attempt window an error will

View File

@ -32,6 +32,7 @@ func main() {
cfg.CheckManager.API.TokenKey = ""
cfg.CheckManager.API.TokenApp = "circonus-gometrics"
cfg.CheckManager.API.TokenURL = "https://api.circonus.com/v2"
cfg.CheckManager.API.CACert = nil
// Check
_, an := path.Split(os.Args[0])
@ -72,6 +73,7 @@ func main() {
| `cfg.CheckManager.API.TokenKey` | "" | [Circonus API Token key](https://login.circonus.com/user/tokens) |
| `cfg.CheckManager.API.TokenApp` | "circonus-gometrics" | App associated with API token |
| `cfg.CheckManager.API.URL` | "https://api.circonus.com/v2" | Circonus API URL |
| `cfg.CheckManager.API.CACert` | nil | [*x509.CertPool](https://golang.org/pkg/crypto/x509/#CertPool) with CA Cert to validate API endpoint using internal CA or self-signed certificates |
|Check||
| `cfg.CheckManager.Check.ID` | "" | Check ID of previously created check. (*Note: **check id** not **check bundle id**.*) |
| `cfg.CheckManager.Check.SubmissionURL` | "" | Submission URL of previously created check. |

View File

@ -7,6 +7,8 @@ package api
import (
"bytes"
crand "crypto/rand"
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"io/ioutil"
@ -14,6 +16,7 @@ import (
"math"
"math/big"
"math/rand"
"net"
"net/http"
"net/url"
"os"
@ -72,6 +75,7 @@ type Config struct {
URL string
TokenKey string
TokenApp string
CACert *x509.CertPool
Log *log.Logger
Debug bool
}
@ -81,6 +85,7 @@ type API struct {
apiURL *url.URL
key TokenKeyType
app TokenAppType
caCert *x509.CertPool
Debug bool
Log *log.Logger
useExponentialBackoff bool
@ -135,6 +140,7 @@ func New(ac *Config) (*API, error) {
apiURL: apiURL,
key: key,
app: app,
caCert: ac.CACert,
Debug: ac.Debug,
Log: ac.Log,
useExponentialBackoff: false,
@ -287,6 +293,33 @@ func (a *API) apiCall(reqMethod string, reqPath string, data []byte) ([]byte, er
req.Header.Add("X-Circonus-App-Name", string(a.app))
client := retryablehttp.NewClient()
if a.apiURL.Scheme == "https" && a.caCert != nil {
client.HTTPClient.Transport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
TLSClientConfig: &tls.Config{RootCAs: a.caCert},
DisableKeepAlives: true,
MaxIdleConnsPerHost: -1,
DisableCompression: true,
}
} else {
client.HTTPClient.Transport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
DisableKeepAlives: true,
MaxIdleConnsPerHost: -1,
DisableCompression: true,
}
}
a.useExponentialBackoffmu.Lock()
eb := a.useExponentialBackoff
a.useExponentialBackoffmu.Unlock()

View File

@ -76,6 +76,7 @@ type GraphGuide struct {
type GraphMetricCluster struct {
AggregateFunc string `json:"aggregate_function,omitempty"` // string
Axis string `json:"axis,omitempty"` // string
Color *string `json:"color,omitempty"` // string
DataFormula *string `json:"data_formula"` // string or null
Hidden bool `json:"hidden"` // boolean
LegendFormula *string `json:"legend_formula"` // string or null

View File

@ -144,16 +144,19 @@ type keepAlive struct {
}
func NewLease(c *Client) Lease {
return NewLeaseFromLeaseClient(RetryLeaseClient(c), c.cfg.DialTimeout+time.Second)
}
func NewLeaseFromLeaseClient(remote pb.LeaseClient, keepAliveTimeout time.Duration) Lease {
l := &lessor{
donec: make(chan struct{}),
keepAlives: make(map[LeaseID]*keepAlive),
remote: RetryLeaseClient(c),
firstKeepAliveTimeout: c.cfg.DialTimeout + time.Second,
remote: remote,
firstKeepAliveTimeout: keepAliveTimeout,
}
if l.firstKeepAliveTimeout == time.Second {
l.firstKeepAliveTimeout = defaultTTL
}
l.stopCtx, l.stopCancel = context.WithCancel(context.Background())
return l
}
@ -255,7 +258,7 @@ func (l *lessor) KeepAliveOnce(ctx context.Context, id LeaseID) (*LeaseKeepAlive
for {
resp, err := l.keepAliveOnce(ctx, id)
if err == nil {
if resp.TTL == 0 {
if resp.TTL <= 0 {
err = rpctypes.ErrLeaseNotFound
}
return resp, err
@ -407,7 +410,7 @@ func (l *lessor) recvKeepAlive(resp *pb.LeaseKeepAliveResponse) {
}
// send update to all channels
nextKeepAlive := time.Now().Add(1 + time.Duration(karesp.TTL/3)*time.Second)
nextKeepAlive := time.Now().Add(time.Duration(karesp.TTL+2) / 3 * time.Second)
ka.deadline = time.Now().Add(time.Duration(karesp.TTL) * time.Second)
for _, ch := range ka.chs {
select {

View File

@ -211,6 +211,7 @@ func WithLease(leaseID LeaseID) OpOption {
}
// WithLimit limits the number of results to return from 'Get' request.
// If WithLimit is given a 0 limit, it is treated as no limit.
func WithLimit(n int64) OpOption { return func(op *Op) { op.limit = n } }
// WithRev specifies the store revision for 'Get' request.

View File

@ -232,7 +232,8 @@ type RangeRequest struct {
// then the range request gets all keys prefixed with key.
// If both key and range_end are '\0', then the range request returns all keys.
RangeEnd []byte `protobuf:"bytes,2,opt,name=range_end,json=rangeEnd,proto3" json:"range_end,omitempty"`
// limit is a limit on the number of keys returned for the request.
// limit is a limit on the number of keys returned for the request. When limit is set to 0,
// it is treated as no limit.
Limit int64 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"`
// revision is the point-in-time of the key-value store to use for the range.
// If revision is less or equal to zero, the range is over the newest key-value store.

View File

@ -356,7 +356,8 @@ message RangeRequest {
// then the range request gets all keys prefixed with key.
// If both key and range_end are '\0', then the range request returns all keys.
bytes range_end = 2;
// limit is a limit on the number of keys returned for the request.
// limit is a limit on the number of keys returned for the request. When limit is set to 0,
// it is treated as no limit.
int64 limit = 3;
// revision is the point-in-time of the key-value store to use for the range.
// If revision is less or equal to zero, the range is over the newest key-value store.

View File

@ -224,6 +224,13 @@ func recursivePreReleaseCompare(versionA []string, versionB []string) int {
bInt = true
}
// Numeric identifiers always have lower precedence than non-numeric identifiers.
if aInt && !bInt {
return -1
} else if !aInt && bInt {
return 1
}
// Handle Integer Comparison
if aInt && bInt {
if aI > bI {

View File

@ -649,6 +649,12 @@ func (sd *SignedData) AddCertificate(cert *x509.Certificate) {
sd.certs = append(sd.certs, cert)
}
// Detach removes content from the signed data struct to make it a detached signature.
// This must be called right before Finish()
func (sd *SignedData) Detach() {
sd.sd.ContentInfo = contentInfo{ContentType: oidSignedData}
}
// Finish marshals the content and its signers
func (sd *SignedData) Finish() ([]byte, error) {
sd.sd.Certificates = marshalCertificates(sd.certs)

View File

@ -1,4 +1,4 @@
INI [![Build Status](https://travis-ci.org/go-ini/ini.svg?branch=master)](https://travis-ci.org/go-ini/ini)
INI [![Build Status](https://travis-ci.org/go-ini/ini.svg?branch=master)](https://travis-ci.org/go-ini/ini) [![Sourcegraph](https://sourcegraph.com/github.com/go-ini/ini/-/badge.svg)](https://sourcegraph.com/github.com/go-ini/ini?badge)
===
![](https://avatars0.githubusercontent.com/u/10216035?v=3&s=200)

View File

@ -85,3 +85,4 @@ Nathan Davies <nathanjamesdavies@gmail.com>
Bo Blanton <bo.blanton@gmail.com>
Vincent Rischmann <me@vrischmann.me>
Jesse Claven <jesse.claven@gmail.com>
Derrick Wippler <thrawn01@gmail.com>

View File

@ -185,7 +185,7 @@ Ecosystem
The following community maintained tools are known to integrate with gocql:
* [migrate](https://github.com/mattes/migrate) is a migration handling tool written in Go with Cassandra support.
* [journey](https://github.com/db-journey/journey) is a migration tool with Cassandra support.
* [negronicql](https://github.com/mikebthun/negronicql) is gocql middleware for Negroni.
* [cqlr](https://github.com/relops/cqlr) adds the ability to auto-bind a CQL iterator to a struct or to bind a struct to an INSERT statement.
* [cqlc](http://relops.com/cqlc) generates gocql compliant code from your Cassandra schema so that you can write type safe CQL statements in Go with a natural query syntax.

View File

@ -46,6 +46,7 @@ type ClusterConfig struct {
// versions the protocol selected is not defined (ie, it can be any of the supported in the cluster)
ProtoVersion int
Timeout time.Duration // connection timeout (default: 600ms)
ConnectTimeout time.Duration // initial connection timeout, used during initial dial to server (default: 600ms)
Port int // port (default: 9042)
Keyspace string // initial keyspace (optional)
NumConns int // number of connections per host (default: 2)
@ -132,6 +133,7 @@ func NewCluster(hosts ...string) *ClusterConfig {
Hosts: hosts,
CQLVersion: "3.0.0",
Timeout: 600 * time.Millisecond,
ConnectTimeout: 600 * time.Millisecond,
Port: 9042,
NumConns: 2,
Consistency: Quorum,

View File

@ -93,13 +93,14 @@ type SslOptions struct {
}
type ConnConfig struct {
ProtoVersion int
CQLVersion string
Timeout time.Duration
Compressor Compressor
Authenticator Authenticator
Keepalive time.Duration
tlsConfig *tls.Config
ProtoVersion int
CQLVersion string
Timeout time.Duration
ConnectTimeout time.Duration
Compressor Compressor
Authenticator Authenticator
Keepalive time.Duration
tlsConfig *tls.Config
}
type ConnErrorHandler interface {
@ -167,7 +168,7 @@ func Connect(host *HostInfo, cfg *ConnConfig, errorHandler ConnErrorHandler, ses
)
dialer := &net.Dialer{
Timeout: cfg.Timeout,
Timeout: cfg.ConnectTimeout,
}
// TODO(zariel): handle ipv6 zone
@ -212,8 +213,8 @@ func Connect(host *HostInfo, cfg *ConnConfig, errorHandler ConnErrorHandler, ses
ctx context.Context
cancel func()
)
if c.timeout > 0 {
ctx, cancel = context.WithTimeout(context.Background(), c.timeout)
if cfg.ConnectTimeout > 0 {
ctx, cancel = context.WithTimeout(context.Background(), cfg.ConnectTimeout)
} else {
ctx, cancel = context.WithCancel(context.Background())
}

View File

@ -85,13 +85,14 @@ func connConfig(cfg *ClusterConfig) (*ConnConfig, error) {
}
return &ConnConfig{
ProtoVersion: cfg.ProtoVersion,
CQLVersion: cfg.CQLVersion,
Timeout: cfg.Timeout,
Compressor: cfg.Compressor,
Authenticator: cfg.Authenticator,
Keepalive: cfg.SocketKeepalive,
tlsConfig: tlsConfig,
ProtoVersion: cfg.ProtoVersion,
CQLVersion: cfg.CQLVersion,
Timeout: cfg.Timeout,
ConnectTimeout: cfg.ConnectTimeout,
Compressor: cfg.Compressor,
Authenticator: cfg.Authenticator,
Keepalive: cfg.SocketKeepalive,
tlsConfig: tlsConfig,
}, nil
}
@ -395,8 +396,8 @@ func (pool *hostConnPool) fill() {
// probably unreachable host
pool.fillingStopped(true)
// this is calle with the connetion pool mutex held, this call will
// then recursivly try to lock it again. FIXME
// this is call with the connection pool mutex held, this call will
// then recursively try to lock it again. FIXME
go pool.session.handleNodeDown(pool.host.Peer(), pool.port)
return
}

View File

@ -250,6 +250,42 @@ func (iter *Iter) SliceMap() ([]map[string]interface{}, error) {
// MapScan takes a map[string]interface{} and populates it with a row
// that is returned from cassandra.
//
// Each call to MapScan() must be called with a new map object.
// During the call to MapScan() any pointers in the existing map
// are replaced with non pointer types before the call returns
//
// iter := session.Query(`SELECT * FROM mytable`).Iter()
// for {
// // New map each iteration
// row = make(map[string]interface{})
// if !iter.MapScan(row) {
// break
// }
// // Do things with row
// if fullname, ok := row["fullname"]; ok {
// fmt.Printf("Full Name: %s\n", fullname)
// }
// }
//
// You can also pass pointers in the map before each call
//
// var fullName FullName // Implements gocql.Unmarshaler and gocql.Marshaler interfaces
// var address net.IP
// var age int
// iter := session.Query(`SELECT * FROM scan_map_table`).Iter()
// for {
// // New map each iteration
// row := map[string]interface{}{
// "fullname": &fullName,
// "age": &age,
// "address": &address,
// }
// if !iter.MapScan(row) {
// break
// }
// fmt.Printf("First: %s Age: %d Address: %q\n", fullName.FirstName, age, address)
// }
func (iter *Iter) MapScan(m map[string]interface{}) bool {
if iter.err != nil {
return false

View File

@ -1,6 +1,10 @@
package gocql
import "log"
import (
"bytes"
"fmt"
"log"
)
type StdLogger interface {
Print(v ...interface{})
@ -8,6 +12,15 @@ type StdLogger interface {
Println(v ...interface{})
}
type testLogger struct {
capture bytes.Buffer
}
func (l *testLogger) Print(v ...interface{}) { fmt.Fprint(&l.capture, v...) }
func (l *testLogger) Printf(format string, v ...interface{}) { fmt.Fprintf(&l.capture, format, v...) }
func (l *testLogger) Println(v ...interface{}) { fmt.Fprintln(&l.capture, v...) }
func (l *testLogger) String() string { return l.capture.String() }
type defaultLogger struct{}
func (l *defaultLogger) Print(v ...interface{}) { log.Print(v...) }

View File

@ -138,7 +138,7 @@ func NewBufferedWriter(w io.Writer) *Writer {
}
}
// Writer is an io.Writer than can write Snappy-compressed bytes.
// Writer is an io.Writer that can write Snappy-compressed bytes.
type Writer struct {
w io.Writer
err error

View File

@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Some documentation is taken from the GitHub Developer site
<http://developer.github.com/>, which is available under the following Creative
Commons Attribution 3.0 License. This applies only to the go-github source
Commons Attribution 3.0 License. This applies only to the go-github source
code and would not apply to any compiled binaries.
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE

View File

@ -67,7 +67,7 @@ func (s *ActivityService) ListNotifications(opt *NotificationListOptions) ([]*No
return nil, resp, err
}
return notifications, resp, err
return notifications, resp, nil
}
// ListRepositoryNotifications lists all notifications in a given repository
@ -92,7 +92,7 @@ func (s *ActivityService) ListRepositoryNotifications(owner, repo string, opt *N
return nil, resp, err
}
return notifications, resp, err
return notifications, resp, nil
}
type markReadOptions struct {
@ -148,7 +148,7 @@ func (s *ActivityService) GetThread(id string) (*Notification, *Response, error)
return nil, resp, err
}
return notification, resp, err
return notification, resp, nil
}
// MarkThreadRead marks the specified thread as read.
@ -183,7 +183,7 @@ func (s *ActivityService) GetThreadSubscription(id string) (*Subscription, *Resp
return nil, resp, err
}
return sub, resp, err
return sub, resp, nil
}
// SetThreadSubscription sets the subscription for the specified thread for the
@ -204,7 +204,7 @@ func (s *ActivityService) SetThreadSubscription(id string, subscription *Subscri
return nil, resp, err
}
return sub, resp, err
return sub, resp, nil
}
// DeleteThreadSubscription deletes the subscription for the specified thread

View File

@ -49,18 +49,18 @@ func (s *ActivityService) ListStargazers(owner, repo string, opt *ListOptions) (
// ActivityListStarredOptions specifies the optional parameters to the
// ActivityService.ListStarred method.
type ActivityListStarredOptions struct {
// How to sort the repository list. Possible values are: created, updated,
// pushed, full_name. Default is "full_name".
// How to sort the repository list. Possible values are: created, updated,
// pushed, full_name. Default is "full_name".
Sort string `url:"sort,omitempty"`
// Direction in which to sort repositories. Possible values are: asc, desc.
// Direction in which to sort repositories. Possible values are: asc, desc.
// Default is "asc" when sort is "full_name", otherwise default is "desc".
Direction string `url:"direction,omitempty"`
ListOptions
}
// ListStarred lists all the repos starred by a user. Passing the empty string
// ListStarred lists all the repos starred by a user. Passing the empty string
// will list the starred repositories for the authenticated user.
//
// GitHub API docs: http://developer.github.com/v3/activity/starring/#list-repositories-being-starred

View File

@ -46,7 +46,7 @@ func (s *ActivityService) ListWatchers(owner, repo string, opt *ListOptions) ([]
return watchers, resp, nil
}
// ListWatched lists the repositories the specified user is watching. Passing
// ListWatched lists the repositories the specified user is watching. Passing
// the empty string will fetch watched repos for the authenticated user.
//
// GitHub API Docs: https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
@ -77,7 +77,7 @@ func (s *ActivityService) ListWatched(user string, opt *ListOptions) ([]*Reposit
}
// GetRepositorySubscription returns the subscription for the specified
// repository for the authenticated user. If the authenticated user is not
// repository for the authenticated user. If the authenticated user is not
// watching the repository, a nil Subscription is returned.
//
// GitHub API Docs: https://developer.github.com/v3/activity/watching/#get-a-repository-subscription
@ -97,7 +97,7 @@ func (s *ActivityService) GetRepositorySubscription(owner, repo string) (*Subscr
return nil, resp, err
}
return sub, resp, err
return sub, resp, nil
}
// SetRepositorySubscription sets the subscription for the specified repository
@ -122,7 +122,7 @@ func (s *ActivityService) SetRepositorySubscription(owner, repo string, subscrip
return nil, resp, err
}
return sub, resp, err
return sub, resp, nil
}
// DeleteRepositorySubscription deletes the subscription for the specified

View File

@ -75,7 +75,7 @@ func (s *AdminService) UpdateUserLDAPMapping(user string, mapping *UserLDAPMappi
return nil, resp, err
}
return m, resp, err
return m, resp, nil
}
// UpdateTeamLDAPMapping updates the mapping between a GitHub team and an LDAP group.
@ -94,5 +94,5 @@ func (s *AdminService) UpdateTeamLDAPMapping(team int, mapping *TeamLDAPMapping)
return nil, resp, err
}
return m, resp, err
return m, resp, nil
}

View File

@ -114,7 +114,7 @@ func (a AuthorizationRequest) String() string {
// AuthorizationUpdateRequest represents a request to update an authorization.
//
// Note that for any one update, you must only provide one of the "scopes"
// fields. That is, you may provide only one of "Scopes", or "AddScopes", or
// fields. That is, you may provide only one of "Scopes", or "AddScopes", or
// "RemoveScopes".
//
// GitHub API docs: https://developer.github.com/v3/oauth_authorizations/#update-an-existing-authorization
@ -170,7 +170,7 @@ func (s *AuthorizationsService) Get(id int) (*Authorization, *Response, error) {
if err != nil {
return nil, resp, err
}
return a, resp, err
return a, resp, nil
}
// Create a new authorization for the specified OAuth application.
@ -189,7 +189,7 @@ func (s *AuthorizationsService) Create(auth *AuthorizationRequest) (*Authorizati
if err != nil {
return nil, resp, err
}
return a, resp, err
return a, resp, nil
}
// GetOrCreateForApp creates a new authorization for the specified OAuth
@ -225,7 +225,7 @@ func (s *AuthorizationsService) GetOrCreateForApp(clientID string, auth *Authori
return nil, resp, err
}
return a, resp, err
return a, resp, nil
}
// Edit a single authorization.
@ -245,7 +245,7 @@ func (s *AuthorizationsService) Edit(id int, auth *AuthorizationUpdateRequest) (
return nil, resp, err
}
return a, resp, err
return a, resp, nil
}
// Delete a single authorization.
@ -285,7 +285,7 @@ func (s *AuthorizationsService) Check(clientID string, token string) (*Authoriza
return nil, resp, err
}
return a, resp, err
return a, resp, nil
}
// Reset is used to reset a valid OAuth token without end user involvement.
@ -313,7 +313,7 @@ func (s *AuthorizationsService) Reset(clientID string, token string) (*Authoriza
return nil, resp, err
}
return a, resp, err
return a, resp, nil
}
// Revoke an authorization for an application.
@ -352,7 +352,7 @@ func (s *AuthorizationsService) ListGrants() ([]*Grant, *Response, error) {
return nil, resp, err
}
return grants, resp, err
return grants, resp, nil
}
// GetGrant gets a single OAuth application grant.
@ -371,7 +371,7 @@ func (s *AuthorizationsService) GetGrant(id int) (*Grant, *Response, error) {
return nil, resp, err
}
return grant, resp, err
return grant, resp, nil
}
// DeleteGrant deletes an OAuth application grant. Deleting an application's
@ -408,7 +408,7 @@ func (s *AuthorizationsService) CreateImpersonation(username string, authReq *Au
if err != nil {
return nil, resp, err
}
return a, resp, err
return a, resp, nil
}
// DeleteImpersonation deletes an impersonation OAuth token.

View File

@ -180,7 +180,7 @@ func (s *GistsService) Get(id string) (*Gist, *Response, error) {
return nil, resp, err
}
return gist, resp, err
return gist, resp, nil
}
// GetRevision gets a specific revision of a gist.
@ -198,7 +198,7 @@ func (s *GistsService) GetRevision(id, sha string) (*Gist, *Response, error) {
return nil, resp, err
}
return gist, resp, err
return gist, resp, nil
}
// Create a gist for authenticated user.
@ -216,7 +216,7 @@ func (s *GistsService) Create(gist *Gist) (*Gist, *Response, error) {
return nil, resp, err
}
return g, resp, err
return g, resp, nil
}
// Edit a gist.
@ -234,7 +234,7 @@ func (s *GistsService) Edit(id string, gist *Gist) (*Gist, *Response, error) {
return nil, resp, err
}
return g, resp, err
return g, resp, nil
}
// ListCommits lists commits of a gist.
@ -322,7 +322,7 @@ func (s *GistsService) Fork(id string) (*Gist, *Response, error) {
return nil, resp, err
}
return g, resp, err
return g, resp, nil
}
// ListForks lists forks of a gist.

View File

@ -63,7 +63,7 @@ func (s *GistsService) GetComment(gistID string, commentID int) (*GistComment, *
return nil, resp, err
}
return c, resp, err
return c, resp, nil
}
// CreateComment creates a comment for a gist.
@ -82,7 +82,7 @@ func (s *GistsService) CreateComment(gistID string, comment *GistComment) (*Gist
return nil, resp, err
}
return c, resp, err
return c, resp, nil
}
// EditComment edits an existing gist comment.
@ -101,7 +101,7 @@ func (s *GistsService) EditComment(gistID string, commentID int, comment *GistCo
return nil, resp, err
}
return c, resp, err
return c, resp, nil
}
// DeleteComment deletes a gist comment.

View File

@ -30,7 +30,7 @@ type Commit struct {
URL *string `json:"url,omitempty"`
Verification *SignatureVerification `json:"verification,omitempty"`
// CommentCount is the number of GitHub comments on the commit. This
// CommentCount is the number of GitHub comments on the commit. This
// is only populated for requests that fetch GitHub data like
// Pulls.ListCommits, Repositories.ListCommits, etc.
CommentCount *int `json:"comment_count,omitempty"`
@ -40,7 +40,7 @@ func (c Commit) String() string {
return Stringify(c)
}
// CommitAuthor represents the author or committer of a commit. The commit
// CommitAuthor represents the author or committer of a commit. The commit
// author may not correspond to a GitHub User.
type CommitAuthor struct {
Date *time.Time `json:"date,omitempty"`
@ -74,7 +74,7 @@ func (s *GitService) GetCommit(owner string, repo string, sha string) (*Commit,
return nil, resp, err
}
return c, resp, err
return c, resp, nil
}
// createCommit represents the body of a CreateCommit request.
@ -123,5 +123,5 @@ func (s *GitService) CreateCommit(owner string, repo string, commit *Commit) (*C
return nil, resp, err
}
return c, resp, err
return c, resp, nil
}

View File

@ -61,7 +61,7 @@ func (s *GitService) GetRef(owner string, repo string, ref string) (*Reference,
return nil, resp, err
}
return r, resp, err
return r, resp, nil
}
// ReferenceListOptions specifies optional parameters to the
@ -98,7 +98,7 @@ func (s *GitService) ListRefs(owner, repo string, opt *ReferenceListOptions) ([]
return nil, resp, err
}
return rs, resp, err
return rs, resp, nil
}
// CreateRef creates a new ref in a repository.
@ -121,7 +121,7 @@ func (s *GitService) CreateRef(owner string, repo string, ref *Reference) (*Refe
return nil, resp, err
}
return r, resp, err
return r, resp, nil
}
// UpdateRef updates an existing ref in a repository.
@ -144,7 +144,7 @@ func (s *GitService) UpdateRef(owner string, repo string, ref *Reference, force
return nil, resp, err
}
return r, resp, err
return r, resp, nil
}
// DeleteRef deletes a ref from a repository.

View File

@ -20,7 +20,7 @@ type Tag struct {
Verification *SignatureVerification `json:"verification,omitempty"`
}
// createTagRequest represents the body of a CreateTag request. This is mostly
// createTagRequest represents the body of a CreateTag request. This is mostly
// identical to Tag with the exception that the object SHA and Type are
// top-level fields, rather than being nested inside a JSON object.
type createTagRequest struct {

View File

@ -17,7 +17,7 @@ func (t Tree) String() string {
return Stringify(t)
}
// TreeEntry represents the contents of a tree structure. TreeEntry can
// TreeEntry represents the contents of a tree structure. TreeEntry can
// represent either a blob, a commit (in the case of a submodule), or another
// tree.
type TreeEntry struct {
@ -53,7 +53,7 @@ func (s *GitService) GetTree(owner string, repo string, sha string, recursive bo
return nil, resp, err
}
return t, resp, err
return t, resp, nil
}
// createTree represents the body of a CreateTree request.
@ -62,7 +62,7 @@ type createTree struct {
Entries []TreeEntry `json:"tree"`
}
// CreateTree creates a new tree in a repository. If both a tree and a nested
// CreateTree creates a new tree in a repository. If both a tree and a nested
// path modifying that tree are specified, it will overwrite the contents of
// that tree with the new path contents and write a new tree out.
//
@ -85,5 +85,5 @@ func (s *GitService) CreateTree(owner string, repo string, baseTree string, entr
return nil, resp, err
}
return t, resp, err
return t, resp, nil
}

View File

@ -106,8 +106,8 @@ type Client struct {
clientMu sync.Mutex // clientMu protects the client during calls that modify the CheckRedirect func.
client *http.Client // HTTP client used to communicate with the API.
// Base URL for API requests. Defaults to the public GitHub API, but can be
// set to a domain endpoint to use with GitHub Enterprise. BaseURL should
// Base URL for API requests. Defaults to the public GitHub API, but can be
// set to a domain endpoint to use with GitHub Enterprise. BaseURL should
// always be specified with a trailing slash.
BaseURL *url.URL
@ -178,7 +178,7 @@ type RawOptions struct {
Type RawType
}
// addOptions adds the parameters in opt as URL query parameters to s. opt
// addOptions adds the parameters in opt as URL query parameters to s. opt
// must be a struct whose fields may contain "url" tags.
func addOptions(s string, opt interface{}) (string, error) {
v := reflect.ValueOf(opt)
@ -200,8 +200,8 @@ func addOptions(s string, opt interface{}) (string, error) {
return u.String(), nil
}
// NewClient returns a new GitHub API client. If a nil httpClient is
// provided, http.DefaultClient will be used. To use API methods which require
// NewClient returns a new GitHub API client. If a nil httpClient is
// provided, http.DefaultClient will be used. To use API methods which require
// authentication, provide an http.Client that will perform the authentication
// for you (such as that provided by the golang.org/x/oauth2 library).
func NewClient(httpClient *http.Client) *Client {
@ -235,7 +235,7 @@ func NewClient(httpClient *http.Client) *Client {
// NewRequest creates an API request. A relative URL can be provided in urlStr,
// in which case it is resolved relative to the BaseURL of the Client.
// Relative URLs should always be specified without a preceding slash. If
// Relative URLs should always be specified without a preceding slash. If
// specified, the value pointed to by body is JSON encoded and included as the
// request body.
func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error) {
@ -295,14 +295,14 @@ func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, size int64, m
return req, nil
}
// Response is a GitHub API response. This wraps the standard http.Response
// Response is a GitHub API response. This wraps the standard http.Response
// returned from GitHub and provides convenient access to things like
// pagination links.
type Response struct {
*http.Response
// These fields provide the page values for paginating through a set of
// results. Any or all of these may be set to the zero value for
// results. Any or all of these may be set to the zero value for
// responses that are not part of a paginated set, or for which there
// are no additional pages.
@ -384,7 +384,7 @@ func parseRate(r *http.Response) Rate {
}
// Rate specifies the current rate limit for the client as determined by the
// most recent API call. If the client is used in a multi-user application,
// most recent API call. If the client is used in a multi-user application,
// this rate may not always be up-to-date.
//
// Deprecated: Use the Response.Rate returned from most recent API call instead.
@ -396,11 +396,11 @@ func (c *Client) Rate() Rate {
return rate
}
// Do sends an API request and returns the API response. The API response is
// Do sends an API request and returns the API response. The API response is
// JSON decoded and stored in the value pointed to by v, or returned as an
// error if an API error has occurred. If v implements the io.Writer
// error if an API error has occurred. If v implements the io.Writer
// interface, the raw response body will be written to v, without attempting to
// first decode it. If rate limit is exceeded and reset time is in the future,
// first decode it. If rate limit is exceeded and reset time is in the future,
// Do returns *RateLimitError immediately without making a network API call.
func (c *Client) Do(req *http.Request, v interface{}) (*Response, error) {
rateLimitCategory := category(req.URL.Path)
@ -511,7 +511,7 @@ func (r *ErrorResponse) Error() string {
}
// TwoFactorAuthError occurs when using HTTP Basic Authentication for a user
// that has two-factor authentication enabled. The request can be reattempted
// that has two-factor authentication enabled. The request can be reattempted
// by providing a one-time password in the request.
type TwoFactorAuthError ErrorResponse
@ -609,7 +609,7 @@ func (e *Error) Error() string {
// present. A response is considered an error if it has a status code outside
// the 200 range or equal to 202 Accepted.
// API error responses are expected to have either no response
// body, or a JSON response body that maps to ErrorResponse. Any other
// body, or a JSON response body that maps to ErrorResponse. Any other
// response body will be silently ignored.
//
// The error type will be *RateLimitError for rate limit exceeded errors,
@ -658,15 +658,15 @@ func CheckResponse(r *http.Response) error {
// parseBoolResponse determines the boolean result from a GitHub API response.
// Several GitHub API methods return boolean responses indicated by the HTTP
// status code in the response (true indicated by a 204, false indicated by a
// 404). This helper function will determine that result and hide the 404
// error if present. Any other error will be returned through as-is.
// 404). This helper function will determine that result and hide the 404
// error if present. Any other error will be returned through as-is.
func parseBoolResponse(err error) (bool, error) {
if err == nil {
return true, nil
}
if err, ok := err.(*ErrorResponse); ok && err.Response.StatusCode == http.StatusNotFound {
// Simply false. In this one case, we do not pass the error through.
// Simply false. In this one case, we do not pass the error through.
return false, nil
}
@ -692,15 +692,15 @@ func (r Rate) String() string {
// RateLimits represents the rate limits for the current client.
type RateLimits struct {
// The rate limit for non-search API requests. Unauthenticated
// requests are limited to 60 per hour. Authenticated requests are
// The rate limit for non-search API requests. Unauthenticated
// requests are limited to 60 per hour. Authenticated requests are
// limited to 5,000 per hour.
//
// GitHub API docs: https://developer.github.com/v3/#rate-limiting
Core *Rate `json:"core"`
// The rate limit for search API requests. Unauthenticated requests
// are limited to 10 requests per minutes. Authenticated requests are
// The rate limit for search API requests. Unauthenticated requests
// are limited to 10 requests per minutes. Authenticated requests are
// limited to 30 per minute.
//
// GitHub API docs: https://developer.github.com/v3/search/#rate-limit
@ -735,11 +735,13 @@ func category(path string) rateLimitCategory {
// Deprecated: RateLimit is deprecated, use RateLimits instead.
func (c *Client) RateLimit() (*Rate, *Response, error) {
limits, resp, err := c.RateLimits()
if limits == nil {
return nil, nil, err
if err != nil {
return nil, resp, err
}
return limits.Core, resp, err
if limits == nil {
return nil, resp, errors.New("RateLimits returned nil limits and error; unable to extract Core rate limit")
}
return limits.Core, resp, nil
}
// RateLimits returns the rate limits for the current client.
@ -768,7 +770,7 @@ func (c *Client) RateLimits() (*RateLimits, *Response, error) {
c.rateMu.Unlock()
}
return response.Resources, resp, err
return response.Resources, resp, nil
}
/*
@ -838,7 +840,7 @@ func (t *UnauthenticatedRateLimitedTransport) transport() http.RoundTripper {
}
// BasicAuthTransport is an http.RoundTripper that authenticates all requests
// using HTTP Basic Authentication with the provided username and password. It
// using HTTP Basic Authentication with the provided username and password. It
// additionally supports users who have two-factor authentication enabled on
// their GitHub account.
type BasicAuthTransport struct {

View File

@ -57,5 +57,5 @@ func (s GitignoresService) Get(name string) (*Gitignore, *Response, error) {
return nil, resp, err
}
return gitignore, resp, err
return gitignore, resp, nil
}

View File

@ -42,5 +42,5 @@ func (s *IntegrationsService) ListRepos(opt *ListOptions) ([]*Repository, *Respo
return nil, resp, err
}
return r.Repositories, resp, err
return r.Repositories, resp, nil
}

View File

@ -68,22 +68,22 @@ type IssueRequest struct {
// IssueListOptions specifies the optional parameters to the IssuesService.List
// and IssuesService.ListByOrg methods.
type IssueListOptions struct {
// Filter specifies which issues to list. Possible values are: assigned,
// created, mentioned, subscribed, all. Default is "assigned".
// Filter specifies which issues to list. Possible values are: assigned,
// created, mentioned, subscribed, all. Default is "assigned".
Filter string `url:"filter,omitempty"`
// State filters issues based on their state. Possible values are: open,
// closed, all. Default is "open".
// State filters issues based on their state. Possible values are: open,
// closed, all. Default is "open".
State string `url:"state,omitempty"`
// Labels filters issues based on their label.
Labels []string `url:"labels,comma,omitempty"`
// Sort specifies how to sort issues. Possible values are: created, updated,
// and comments. Default value is "created".
// Sort specifies how to sort issues. Possible values are: created, updated,
// and comments. Default value is "created".
Sort string `url:"sort,omitempty"`
// Direction in which to sort issues. Possible values are: asc, desc.
// Direction in which to sort issues. Possible values are: asc, desc.
// Default is "desc".
Direction string `url:"direction,omitempty"`
@ -102,7 +102,7 @@ type PullRequestLinks struct {
PatchURL *string `json:"patch_url,omitempty"`
}
// List the issues for the authenticated user. If all is true, list issues
// List the issues for the authenticated user. If all is true, list issues
// across all the user's visible repositories including owned, member, and
// organization repositories; if false, list only owned and member
// repositories.
@ -153,16 +153,16 @@ func (s *IssuesService) listIssues(u string, opt *IssueListOptions) ([]*Issue, *
// IssueListByRepoOptions specifies the optional parameters to the
// IssuesService.ListByRepo method.
type IssueListByRepoOptions struct {
// Milestone limits issues for the specified milestone. Possible values are
// Milestone limits issues for the specified milestone. Possible values are
// a milestone number, "none" for issues with no milestone, "*" for issues
// with any milestone.
Milestone string `url:"milestone,omitempty"`
// State filters issues based on their state. Possible values are: open,
// closed, all. Default is "open".
// State filters issues based on their state. Possible values are: open,
// closed, all. Default is "open".
State string `url:"state,omitempty"`
// Assignee filters issues based on their assignee. Possible values are a
// Assignee filters issues based on their assignee. Possible values are a
// user name, "none" for issues that are not assigned, "*" for issues with
// any assigned user.
Assignee string `url:"assignee,omitempty"`
@ -176,11 +176,11 @@ type IssueListByRepoOptions struct {
// Labels filters issues based on their label.
Labels []string `url:"labels,omitempty,comma"`
// Sort specifies how to sort issues. Possible values are: created, updated,
// and comments. Default value is "created".
// Sort specifies how to sort issues. Possible values are: created, updated,
// and comments. Default value is "created".
Sort string `url:"sort,omitempty"`
// Direction in which to sort issues. Possible values are: asc, desc.
// Direction in which to sort issues. Possible values are: asc, desc.
// Default is "desc".
Direction string `url:"direction,omitempty"`

View File

@ -30,10 +30,10 @@ func (i IssueComment) String() string {
// IssueListCommentsOptions specifies the optional parameters to the
// IssuesService.ListComments method.
type IssueListCommentsOptions struct {
// Sort specifies how to sort comments. Possible values are: created, updated.
// Sort specifies how to sort comments. Possible values are: created, updated.
Sort string `url:"sort,omitempty"`
// Direction in which to sort comments. Possible values are: asc, desc.
// Direction in which to sort comments. Possible values are: asc, desc.
Direction string `url:"direction,omitempty"`
// Since filters comments by time.
@ -42,7 +42,7 @@ type IssueListCommentsOptions struct {
ListOptions
}
// ListComments lists all comments on the specified issue. Specifying an issue
// ListComments lists all comments on the specified issue. Specifying an issue
// number of 0 will return all comments on all issues for the repository.
//
// GitHub API docs: http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue

View File

@ -18,7 +18,7 @@ type IssueEvent struct {
// The User that generated this event.
Actor *User `json:"actor,omitempty"`
// Event identifies the actual type of Event that occurred. Possible
// Event identifies the actual type of Event that occurred. Possible
// values are:
//
// closed
@ -91,7 +91,7 @@ func (s *IssuesService) ListIssueEvents(owner, repo string, number int, opt *Lis
return nil, resp, err
}
return events, resp, err
return events, resp, nil
}
// ListRepositoryEvents lists events for the specified repository.
@ -115,7 +115,7 @@ func (s *IssuesService) ListRepositoryEvents(owner, repo string, opt *ListOption
return nil, resp, err
}
return events, resp, err
return events, resp, nil
}
// GetEvent returns the specified issue event.
@ -135,7 +135,7 @@ func (s *IssuesService) GetEvent(owner, repo string, id int) (*IssueEvent, *Resp
return nil, resp, err
}
return event, resp, err
return event, resp, nil
}
// Rename contains details for 'renamed' events.

View File

@ -113,7 +113,7 @@ func (s *IssuesService) DeleteLabel(owner string, repo string, name string) (*Re
// ListLabelsByIssue lists all labels for an issue.
//
// GitHub API docs: http://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
// GitHub API docs: https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue
func (s *IssuesService) ListLabelsByIssue(owner string, repo string, number int, opt *ListOptions) ([]*Label, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
u, err := addOptions(u, opt)
@ -137,7 +137,7 @@ func (s *IssuesService) ListLabelsByIssue(owner string, repo string, number int,
// AddLabelsToIssue adds labels to an issue.
//
// GitHub API docs: http://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
// GitHub API docs: https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue
func (s *IssuesService) AddLabelsToIssue(owner string, repo string, number int, labels []string) ([]*Label, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/issues/%d/labels", owner, repo, number)
req, err := s.client.NewRequest("POST", u, labels)

View File

@ -96,5 +96,5 @@ func (s *LicensesService) Get(licenseName string) (*License, *Response, error) {
return nil, resp, err
}
return license, resp, err
return license, resp, nil
}

View File

@ -39,7 +39,7 @@ type Import struct {
// repository. To see a list of these files, call LargeFiles.
LargeFilesCount *int `json:"large_files_count,omitempty"`
// Identifies the current status of an import. An import that does not
// Identifies the current status of an import. An import that does not
// have errors will progress through these steps:
//
// detecting - the "detection" step of the import is in progress
@ -101,7 +101,7 @@ type Import struct {
HumanName *string `json:"human_name,omitempty"`
// When the importer finds several projects or repositories at the
// provided URLs, this will identify the available choices. Call
// provided URLs, this will identify the available choices. Call
// UpdateImport with the selected Import value.
ProjectChoices []Import `json:"project_choices,omitempty"`
}
@ -160,7 +160,7 @@ func (s *MigrationService) StartImport(owner, repo string, in *Import) (*Import,
return nil, resp, err
}
return out, resp, err
return out, resp, nil
}
// ImportProgress queries for the status and progress of an ongoing repository import.
@ -182,7 +182,7 @@ func (s *MigrationService) ImportProgress(owner, repo string) (*Import, *Respons
return nil, resp, err
}
return out, resp, err
return out, resp, nil
}
// UpdateImport initiates a repository import.
@ -204,7 +204,7 @@ func (s *MigrationService) UpdateImport(owner, repo string, in *Import) (*Import
return nil, resp, err
}
return out, resp, err
return out, resp, nil
}
// CommitAuthors gets the authors mapped from the original repository.
@ -260,11 +260,11 @@ func (s *MigrationService) MapCommitAuthor(owner, repo string, id int, author *S
return nil, resp, err
}
return out, resp, err
return out, resp, nil
}
// SetLFSPreference sets whether imported repositories should use Git LFS for
// files larger than 100MB. Only the UseLFS field on the provided Import is
// files larger than 100MB. Only the UseLFS field on the provided Import is
// used.
//
// GitHub API docs: https://developer.github.com/v3/migration/source_imports/#set-git-lfs-preference
@ -284,7 +284,7 @@ func (s *MigrationService) SetLFSPreference(owner, repo string, in *Import) (*Im
return nil, resp, err
}
return out, resp, err
return out, resp, nil
}
// LargeFiles lists files larger than 100MB found during the import.

View File

@ -13,7 +13,7 @@ import (
// MarkdownOptions specifies optional parameters to the Markdown method.
type MarkdownOptions struct {
// Mode identifies the rendering mode. Possible values are:
// Mode identifies the rendering mode. Possible values are:
// markdown - render a document as plain Markdown, just like
// README files are rendered.
//
@ -25,7 +25,7 @@ type MarkdownOptions struct {
// Default is "markdown".
Mode string
// Context identifies the repository context. Only taken into account
// Context identifies the repository context. Only taken into account
// when rendering as "gfm".
Context string
}
@ -125,7 +125,7 @@ func (c *Client) APIMeta() (*APIMeta, *Response, error) {
}
// Octocat returns an ASCII art octocat with the specified message in a speech
// bubble. If message is empty, a random zen phrase is used.
// bubble. If message is empty, a random zen phrase is used.
func (c *Client) Octocat(message string) (string, *Response, error) {
u := "octocat"
if message != "" {

View File

@ -57,7 +57,7 @@ func (o Organization) String() string {
return Stringify(o)
}
// Plan represents the payment plan for an account. See plans at https://github.com/plans.
// Plan represents the payment plan for an account. See plans at https://github.com/plans.
type Plan struct {
Name *string `json:"name,omitempty"`
Space *int `json:"space,omitempty"`
@ -101,10 +101,10 @@ func (s *OrganizationsService) ListAll(opt *OrganizationsListOptions) ([]*Organi
if err != nil {
return nil, resp, err
}
return orgs, resp, err
return orgs, resp, nil
}
// List the organizations for a user. Passing the empty string will list
// List the organizations for a user. Passing the empty string will list
// organizations for the authenticated user.
//
// GitHub API docs: http://developer.github.com/v3/orgs/#list-user-organizations
@ -150,7 +150,7 @@ func (s *OrganizationsService) Get(org string) (*Organization, *Response, error)
return nil, resp, err
}
return organization, resp, err
return organization, resp, nil
}
// Edit an organization.
@ -169,5 +169,5 @@ func (s *OrganizationsService) Edit(name string, org *Organization) (*Organizati
return nil, resp, err
}
return o, resp, err
return o, resp, nil
}

View File

@ -62,7 +62,7 @@ func (s *OrganizationsService) CreateHook(org string, hook *Hook) (*Hook, *Respo
return nil, resp, err
}
return h, resp, err
return h, resp, nil
}
// EditHook updates a specified Hook.

View File

@ -48,8 +48,8 @@ type ListMembersOptions struct {
// organization), list only publicly visible members.
PublicOnly bool `url:"-"`
// Filter members returned in the list. Possible values are:
// 2fa_disabled, all. Default is "all".
// Filter members returned in the list. Possible values are:
// 2fa_disabled, all. Default is "all".
Filter string `url:"filter,omitempty"`
// Role filters members returned by their role in the organization.
@ -64,7 +64,7 @@ type ListMembersOptions struct {
ListOptions
}
// ListMembers lists the members for an organization. If the authenticated
// ListMembers lists the members for an organization. If the authenticated
// user is an owner of the organization, this will return both concealed and
// public members, otherwise it will only return public members.
//
@ -196,7 +196,7 @@ func (s *OrganizationsService) ListOrgMemberships(opt *ListOrgMembershipsOptions
return nil, resp, err
}
return memberships, resp, err
return memberships, resp, nil
}
// GetOrgMembership gets the membership for a user in a specified organization.
@ -224,7 +224,7 @@ func (s *OrganizationsService) GetOrgMembership(user, org string) (*Membership,
return nil, resp, err
}
return membership, resp, err
return membership, resp, nil
}
// EditOrgMembership edits the membership for user in specified organization.
@ -254,10 +254,10 @@ func (s *OrganizationsService) EditOrgMembership(user, org string, membership *M
return nil, resp, err
}
return m, resp, err
return m, resp, nil
}
// RemoveOrgMembership removes user from the specified organization. If the
// RemoveOrgMembership removes user from the specified organization. If the
// user has been invited to the organization, this will cancel their invitation.
//
// GitHub API docs: https://developer.github.com/v3/orgs/members/#remove-organization-membership

View File

@ -10,7 +10,7 @@ import (
"time"
)
// Team represents a team within a GitHub organization. Teams are used to
// Team represents a team within a GitHub organization. Teams are used to
// manage access to an organization's repositories.
type Team struct {
ID *int `json:"id,omitempty"`
@ -20,9 +20,9 @@ type Team struct {
Slug *string `json:"slug,omitempty"`
// Permission is deprecated when creating or editing a team in an org
// using the new GitHub permission model. It no longer identifies the
// using the new GitHub permission model. It no longer identifies the
// permission a team has on its repos, but only specifies the default
// permission a repo is initially added with. Avoid confusion by
// permission a repo is initially added with. Avoid confusion by
// specifying a permission value when calling AddTeamRepo.
Permission *string `json:"permission,omitempty"`
@ -99,7 +99,7 @@ func (s *OrganizationsService) GetTeam(team int) (*Team, *Response, error) {
return nil, resp, err
}
return t, resp, err
return t, resp, nil
}
// CreateTeam creates a new team within an organization.
@ -118,7 +118,7 @@ func (s *OrganizationsService) CreateTeam(org string, team *Team) (*Team, *Respo
return nil, resp, err
}
return t, resp, err
return t, resp, nil
}
// EditTeam edits a team.
@ -137,7 +137,7 @@ func (s *OrganizationsService) EditTeam(id int, team *Team) (*Team, *Response, e
return nil, resp, err
}
return t, resp, err
return t, resp, nil
}
// DeleteTeam deletes a team.
@ -156,8 +156,8 @@ func (s *OrganizationsService) DeleteTeam(team int) (*Response, error) {
// OrganizationListTeamMembersOptions specifies the optional parameters to the
// OrganizationsService.ListTeamMembers method.
type OrganizationListTeamMembersOptions struct {
// Role filters members returned by their role in the team. Possible
// values are "all", "member", "maintainer". Default is "all".
// Role filters members returned by their role in the team. Possible
// values are "all", "member", "maintainer". Default is "all".
Role string `url:"role,omitempty"`
ListOptions
@ -227,7 +227,7 @@ func (s *OrganizationsService) ListTeamRepos(team int, opt *ListOptions) ([]*Rep
return repos, resp, nil
}
// IsTeamRepo checks if a team manages the specified repository. If the
// IsTeamRepo checks if a team manages the specified repository. If the
// repository is managed by team, a Repository is returned which includes the
// permissions team has for that repo.
//
@ -247,7 +247,7 @@ func (s *OrganizationsService) IsTeamRepo(team int, owner string, repo string) (
return nil, resp, err
}
return repository, resp, err
return repository, resp, nil
}
// OrganizationAddTeamRepoOptions specifies the optional parameters to the
@ -263,7 +263,7 @@ type OrganizationAddTeamRepoOptions struct {
Permission string `json:"permission,omitempty"`
}
// AddTeamRepo adds a repository to be managed by the specified team. The
// AddTeamRepo adds a repository to be managed by the specified team. The
// specified repository must be owned by the organization to which the team
// belongs, or a direct fork of a repository owned by the organization.
//
@ -279,7 +279,7 @@ func (s *OrganizationsService) AddTeamRepo(team int, owner string, repo string,
}
// RemoveTeamRepo removes a repository from being managed by the specified
// team. Note that this does not delete the repository, it just removes it
// team. Note that this does not delete the repository, it just removes it
// from the team.
//
// GitHub API docs: http://developer.github.com/v3/orgs/teams/#remove-team-repo
@ -332,13 +332,13 @@ func (s *OrganizationsService) GetTeamMembership(team int, user string) (*Member
return nil, resp, err
}
return t, resp, err
return t, resp, nil
}
// OrganizationAddTeamMembershipOptions does stuff specifies the optional
// parameters to the OrganizationsService.AddTeamMembership method.
type OrganizationAddTeamMembershipOptions struct {
// Role specifies the role the user should have in the team. Possible
// Role specifies the role the user should have in the team. Possible
// values are:
// member - a normal member of the team
// maintainer - a team maintainer. Able to add/remove other team
@ -380,7 +380,7 @@ func (s *OrganizationsService) AddTeamMembership(team int, user string, opt *Org
return nil, resp, err
}
return t, resp, err
return t, resp, nil
}
// RemoveTeamMembership removes a user from a team.

View File

@ -51,7 +51,7 @@ func (s *ProjectsService) GetProject(id int) (*Project, *Response, error) {
return nil, resp, err
}
return project, resp, err
return project, resp, nil
}
// ProjectOptions specifies the parameters to the
@ -83,7 +83,7 @@ func (s *ProjectsService) UpdateProject(id int, opt *ProjectOptions) (*Project,
return nil, resp, err
}
return project, resp, err
return project, resp, nil
}
// DeleteProject deletes a GitHub Project from a repository.
@ -137,7 +137,7 @@ func (s *ProjectsService) ListProjectColumns(projectID int, opt *ListOptions) ([
return nil, resp, err
}
return columns, resp, err
return columns, resp, nil
}
// GetProjectColumn gets a column of a GitHub Project for a repo.
@ -159,7 +159,7 @@ func (s *ProjectsService) GetProjectColumn(id int) (*ProjectColumn, *Response, e
return nil, resp, err
}
return column, resp, err
return column, resp, nil
}
// ProjectColumnOptions specifies the parameters to the
@ -189,7 +189,7 @@ func (s *ProjectsService) CreateProjectColumn(projectID int, opt *ProjectColumnO
return nil, resp, err
}
return column, resp, err
return column, resp, nil
}
// UpdateProjectColumn updates a column of a GitHub Project.
@ -211,7 +211,7 @@ func (s *ProjectsService) UpdateProjectColumn(columnID int, opt *ProjectColumnOp
return nil, resp, err
}
return column, resp, err
return column, resp, nil
}
// DeleteProjectColumn deletes a column from a GitHub Project.
@ -290,7 +290,7 @@ func (s *ProjectsService) ListProjectCards(columnID int, opt *ListOptions) ([]*P
return nil, resp, err
}
return cards, resp, err
return cards, resp, nil
}
// GetProjectCard gets a card in a column of a GitHub Project.
@ -312,7 +312,7 @@ func (s *ProjectsService) GetProjectCard(columnID int) (*ProjectCard, *Response,
return nil, resp, err
}
return card, resp, err
return card, resp, nil
}
// ProjectCardOptions specifies the parameters to the
@ -347,7 +347,7 @@ func (s *ProjectsService) CreateProjectCard(columnID int, opt *ProjectCardOption
return nil, resp, err
}
return card, resp, err
return card, resp, nil
}
// UpdateProjectCard updates a card of a GitHub Project.
@ -369,7 +369,7 @@ func (s *ProjectsService) UpdateProjectCard(cardID int, opt *ProjectCardOptions)
return nil, resp, err
}
return card, resp, err
return card, resp, nil
}
// DeleteProjectCard deletes a card from a GitHub Project.

View File

@ -69,8 +69,8 @@ type PullRequestBranch struct {
// PullRequestListOptions specifies the optional parameters to the
// PullRequestsService.List method.
type PullRequestListOptions struct {
// State filters pull requests based on their state. Possible values are:
// open, closed. Default is "open".
// State filters pull requests based on their state. Possible values are:
// open, closed. Default is "open".
State string `url:"state,omitempty"`
// Head filters pull requests by head user and branch name in the format of:

View File

@ -37,10 +37,10 @@ func (p PullRequestComment) String() string {
// PullRequestListCommentsOptions specifies the optional parameters to the
// PullRequestsService.ListComments method.
type PullRequestListCommentsOptions struct {
// Sort specifies how to sort comments. Possible values are: created, updated.
// Sort specifies how to sort comments. Possible values are: created, updated.
Sort string `url:"sort,omitempty"`
// Direction in which to sort comments. Possible values are: asc, desc.
// Direction in which to sort comments. Possible values are: asc, desc.
Direction string `url:"direction,omitempty"`
// Since filters comments by time.
@ -49,7 +49,7 @@ type PullRequestListCommentsOptions struct {
ListOptions
}
// ListComments lists all comments on the specified pull request. Specifying a
// ListComments lists all comments on the specified pull request. Specifying a
// pull request number of 0 will return all comments on all pull requests for
// the repository.
//

View File

@ -151,7 +151,7 @@ type RepositoryListOptions struct {
ListOptions
}
// List the repositories for a user. Passing the empty string will list
// List the repositories for a user. Passing the empty string will list
// repositories for the authenticated user.
//
// GitHub API docs: http://developer.github.com/v3/repos/#list-user-repositories
@ -187,8 +187,8 @@ func (s *RepositoriesService) List(user string, opt *RepositoryListOptions) ([]*
// RepositoryListByOrgOptions specifies the optional parameters to the
// RepositoriesService.ListByOrg method.
type RepositoryListByOrgOptions struct {
// Type of repositories to list. Possible values are: all, public, private,
// forks, sources, member. Default is "all".
// Type of repositories to list. Possible values are: all, public, private,
// forks, sources, member. Default is "all".
Type string `url:"type,omitempty"`
ListOptions
@ -253,8 +253,8 @@ func (s *RepositoriesService) ListAll(opt *RepositoryListAllOptions) ([]*Reposit
return repos, resp, nil
}
// Create a new repository. If an organization is specified, the new
// repository will be created under that org. If the empty string is
// Create a new repository. If an organization is specified, the new
// repository will be created under that org. If the empty string is
// specified, it will be created for the authenticated user.
//
// GitHub API docs: http://developer.github.com/v3/repos/#create

View File

@ -87,7 +87,7 @@ type RepositoryAddCollaboratorOptions struct {
// push - team members can pull and push, but not administer this repository
// admin - team members can pull, push and administer this repository
//
// Default value is "push". This option is only valid for organization-owned repositories.
// Default value is "push". This option is only valid for organization-owned repositories.
Permission string `json:"permission,omitempty"`
}

View File

@ -103,7 +103,7 @@ func (s *RepositoriesService) CreateComment(owner, repo, sha string, comment *Re
return nil, resp, err
}
return c, resp, err
return c, resp, nil
}
// GetComment gets a single comment from a repository.
@ -125,7 +125,7 @@ func (s *RepositoriesService) GetComment(owner, repo string, id int) (*Repositor
return nil, resp, err
}
return c, resp, err
return c, resp, nil
}
// UpdateComment updates the body of a single comment.
@ -144,7 +144,7 @@ func (s *RepositoriesService) UpdateComment(owner, repo string, id int, comment
return nil, resp, err
}
return c, resp, err
return c, resp, nil
}
// DeleteComment deletes a single comment from a repository.

View File

@ -151,10 +151,10 @@ func (s *RepositoriesService) GetCommit(owner, repo, sha string) (*RepositoryCom
return nil, resp, err
}
return commit, resp, err
return commit, resp, nil
}
// GetCommitSHA1 gets the SHA-1 of a commit reference. If a last-known SHA1 is
// GetCommitSHA1 gets the SHA-1 of a commit reference. If a last-known SHA1 is
// supplied and no new commits have occurred, a 304 Unmodified response is returned.
//
// GitHub API docs: https://developer.github.com/v3/repos/commits/#get-the-sha-1-of-a-commit-reference
@ -177,7 +177,7 @@ func (s *RepositoriesService) GetCommitSHA1(owner, repo, ref, lastSHA string) (s
return "", resp, err
}
return buf.String(), resp, err
return buf.String(), resp, nil
}
// CompareCommits compares a range of commits with each other.
@ -198,5 +198,5 @@ func (s *RepositoriesService) CompareCommits(owner, repo string, base, head stri
return nil, resp, err
}
return comp, resp, err
return comp, resp, nil
}

View File

@ -117,7 +117,7 @@ func (s *RepositoriesService) GetReadme(owner, repo string, opt *RepositoryConte
if err != nil {
return nil, resp, err
}
return readme, resp, err
return readme, resp, nil
}
// DownloadContents returns an io.ReadCloser that reads the contents of the
@ -196,7 +196,7 @@ func (s *RepositoriesService) CreateFile(owner, repo, path string, opt *Reposito
if err != nil {
return nil, resp, err
}
return createResponse, resp, err
return createResponse, resp, nil
}
// UpdateFile updates a file in a repository at the given path and returns the
@ -214,7 +214,7 @@ func (s *RepositoriesService) UpdateFile(owner, repo, path string, opt *Reposito
if err != nil {
return nil, resp, err
}
return updateResponse, resp, err
return updateResponse, resp, nil
}
// DeleteFile deletes a file from a repository and returns the commit.
@ -232,7 +232,7 @@ func (s *RepositoriesService) DeleteFile(owner, repo, path string, opt *Reposito
if err != nil {
return nil, resp, err
}
return deleteResponse, resp, err
return deleteResponse, resp, nil
}
// archiveFormat is used to define the archive type when calling GetArchiveLink.

View File

@ -99,7 +99,7 @@ func (s *RepositoriesService) GetDeployment(owner, repo string, deploymentID int
return nil, resp, err
}
return deployment, resp, err
return deployment, resp, nil
}
// CreateDeployment creates a new deployment for a repository.
@ -122,7 +122,7 @@ func (s *RepositoriesService) CreateDeployment(owner, repo string, request *Depl
return nil, resp, err
}
return d, resp, err
return d, resp, nil
}
// DeploymentStatus represents the status of a
@ -195,7 +195,7 @@ func (s *RepositoriesService) GetDeploymentStatus(owner, repo string, deployment
return nil, resp, err
}
return d, resp, err
return d, resp, nil
}
// CreateDeploymentStatus creates a new status for a deployment.
@ -218,5 +218,5 @@ func (s *RepositoriesService) CreateDeploymentStatus(owner, repo string, deploym
return nil, resp, err
}
return d, resp, err
return d, resp, nil
}

View File

@ -10,8 +10,8 @@ import "fmt"
// RepositoryListForksOptions specifies the optional parameters to the
// RepositoriesService.ListForks method.
type RepositoryListForksOptions struct {
// How to sort the forks list. Possible values are: newest, oldest,
// watchers. Default is "newest".
// How to sort the forks list. Possible values are: newest, oldest,
// watchers. Default is "newest".
Sort string `url:"sort,omitempty"`
ListOptions
@ -75,5 +75,5 @@ func (s *RepositoriesService) CreateFork(owner, repo string, opt *RepositoryCrea
return nil, resp, err
}
return fork, resp, err
return fork, resp, nil
}

View File

@ -11,9 +11,9 @@ import (
)
// WebHookPayload represents the data that is received from GitHub when a push
// event hook is triggered. The format of these payloads pre-date most of the
// event hook is triggered. The format of these payloads pre-date most of the
// GitHub v3 API, so there are lots of minor incompatibilities with the types
// defined in the rest of the API. Therefore, several types are duplicated
// defined in the rest of the API. Therefore, several types are duplicated
// here to account for these differences.
//
// GitHub API docs: https://help.github.com/articles/post-receive-hooks
@ -55,7 +55,7 @@ func (w WebHookCommit) String() string {
}
// WebHookAuthor represents the author or committer of a commit, as specified
// in a WebHookCommit. The commit author may not correspond to a GitHub User.
// in a WebHookCommit. The commit author may not correspond to a GitHub User.
type WebHookAuthor struct {
Email *string `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
@ -99,7 +99,7 @@ func (s *RepositoriesService) CreateHook(owner, repo string, hook *Hook) (*Hook,
return nil, resp, err
}
return h, resp, err
return h, resp, nil
}
// ListHooks lists all Hooks for the specified repository.
@ -190,7 +190,7 @@ func (s *RepositoriesService) TestHook(owner, repo string, id int) (*Response, e
return s.client.Do(req, nil)
}
// ListServiceHooks is deprecated. Use Client.ListServiceHooks instead.
// ListServiceHooks is deprecated. Use Client.ListServiceHooks instead.
func (s *RepositoriesService) ListServiceHooks() ([]*ServiceHook, *Response, error) {
return s.client.ListServiceHooks()
}

View File

@ -46,7 +46,7 @@ func (s *RepositoriesService) ListInvitations(repoID int, opt *ListOptions) ([]*
return nil, resp, err
}
return invites, resp, err
return invites, resp, nil
}
// DeleteInvitation deletes a repository invitation.

View File

@ -50,7 +50,7 @@ func (s *RepositoriesService) GetKey(owner string, repo string, id int) (*Key, *
return nil, resp, err
}
return key, resp, err
return key, resp, nil
}
// CreateKey adds a deploy key for a repository.
@ -70,7 +70,7 @@ func (s *RepositoriesService) CreateKey(owner string, repo string, key *Key) (*K
return nil, resp, err
}
return k, resp, err
return k, resp, nil
}
// EditKey edits a deploy key.
@ -90,7 +90,7 @@ func (s *RepositoriesService) EditKey(owner string, repo string, id int, key *Ke
return nil, resp, err
}
return k, resp, err
return k, resp, nil
}
// DeleteKey deletes a deploy key.

View File

@ -33,5 +33,5 @@ func (s *RepositoriesService) Merge(owner, repo string, request *RepositoryMerge
return nil, resp, err
}
return commit, resp, err
return commit, resp, nil
}

View File

@ -52,7 +52,7 @@ func (s *RepositoriesService) GetPagesInfo(owner, repo string) (*Pages, *Respons
return nil, resp, err
}
return site, resp, err
return site, resp, nil
}
// ListPagesBuilds lists the builds for a GitHub Pages site.
@ -71,7 +71,7 @@ func (s *RepositoriesService) ListPagesBuilds(owner, repo string) ([]*PagesBuild
return nil, resp, err
}
return pages, resp, err
return pages, resp, nil
}
// GetLatestPagesBuild fetches the latest build information for a GitHub pages site.
@ -90,7 +90,7 @@ func (s *RepositoriesService) GetLatestPagesBuild(owner, repo string) (*PagesBui
return nil, resp, err
}
return build, resp, err
return build, resp, nil
}
// GetPageBuild fetches the specific build information for a GitHub pages site.
@ -109,7 +109,7 @@ func (s *RepositoriesService) GetPageBuild(owner, repo string, id int) (*PagesBu
return nil, resp, err
}
return build, resp, err
return build, resp, nil
}
// RequestPageBuild requests a build of a GitHub Pages site without needing to push new commit.
@ -131,5 +131,5 @@ func (s *RepositoriesService) RequestPageBuild(owner, repo string) (*PagesBuild,
return nil, resp, err
}
return build, resp, err
return build, resp, nil
}

View File

@ -31,7 +31,7 @@ func (s *RepositoriesService) ListProjects(owner, repo string, opt *ListOptions)
return nil, resp, err
}
return projects, resp, err
return projects, resp, nil
}
// CreateProject creates a GitHub Project for the specified repository.
@ -53,5 +53,5 @@ func (s *RepositoriesService) CreateProject(owner, repo string, opt *ProjectOpti
return nil, resp, err
}
return project, resp, err
return project, resp, nil
}

View File

@ -119,7 +119,7 @@ func (s *RepositoriesService) getSingleRelease(url string) (*RepositoryRelease,
if err != nil {
return nil, resp, err
}
return release, resp, err
return release, resp, nil
}
// CreateRelease adds a new release for a repository.
@ -138,7 +138,7 @@ func (s *RepositoriesService) CreateRelease(owner, repo string, release *Reposit
if err != nil {
return nil, resp, err
}
return r, resp, err
return r, resp, nil
}
// EditRelease edits a repository release.
@ -157,7 +157,7 @@ func (s *RepositoriesService) EditRelease(owner, repo string, id int, release *R
if err != nil {
return nil, resp, err
}
return r, resp, err
return r, resp, nil
}
// DeleteRelease delete a single release from a repository.
@ -212,7 +212,7 @@ func (s *RepositoriesService) GetReleaseAsset(owner, repo string, id int) (*Rele
if err != nil {
return nil, resp, err
}
return asset, resp, err
return asset, resp, nil
}
// DownloadReleaseAsset downloads a release asset or returns a redirect URL.
@ -275,7 +275,7 @@ func (s *RepositoriesService) EditReleaseAsset(owner, repo string, id int, relea
if err != nil {
return nil, resp, err
}
return asset, resp, err
return asset, resp, nil
}
// DeleteReleaseAsset delete a single release asset from a repository.
@ -321,5 +321,5 @@ func (s *RepositoriesService) UploadReleaseAsset(owner, repo string, id int, opt
if err != nil {
return nil, resp, err
}
return asset, resp, err
return asset, resp, nil
}

View File

@ -58,7 +58,7 @@ func (s *RepositoriesService) ListContributorsStats(owner, repo string) ([]*Cont
return nil, resp, err
}
return contributorStats, resp, err
return contributorStats, resp, nil
}
// WeeklyCommitActivity represents the weekly commit activity for a repository.
@ -97,11 +97,11 @@ func (s *RepositoriesService) ListCommitActivity(owner, repo string) ([]*WeeklyC
return nil, resp, err
}
return weeklyCommitActivity, resp, err
return weeklyCommitActivity, resp, nil
}
// ListCodeFrequency returns a weekly aggregate of the number of additions and
// deletions pushed to a repository. Returned WeeklyStats will contain
// deletions pushed to a repository. Returned WeeklyStats will contain
// additions and deletions, but not total commits.
//
// If this is the first time these statistics are requested for the given
@ -177,7 +177,7 @@ func (s *RepositoriesService) ListParticipation(owner, repo string) (*Repository
return nil, resp, err
}
return participation, resp, err
return participation, resp, nil
}
// PunchCard represents the number of commits made during a given hour of a

View File

@ -15,11 +15,11 @@ type RepoStatus struct {
ID *int `json:"id,omitempty"`
URL *string `json:"url,omitempty"`
// State is the current state of the repository. Possible values are:
// State is the current state of the repository. Possible values are:
// pending, success, error, or failure.
State *string `json:"state,omitempty"`
// TargetURL is the URL of the page representing this status. It will be
// TargetURL is the URL of the page representing this status. It will be
// linked from the GitHub UI to allow users to see the source of the status.
TargetURL *string `json:"target_url,omitempty"`
@ -39,7 +39,7 @@ func (r RepoStatus) String() string {
}
// ListStatuses lists the statuses of a repository at the specified
// reference. ref can be a SHA, a branch name, or a tag name.
// reference. ref can be a SHA, a branch name, or a tag name.
//
// GitHub API docs: http://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref
func (s *RepositoriesService) ListStatuses(owner, repo, ref string, opt *ListOptions) ([]*RepoStatus, *Response, error) {
@ -64,7 +64,7 @@ func (s *RepositoriesService) ListStatuses(owner, repo, ref string, opt *ListOpt
}
// CreateStatus creates a new status for a repository at the specified
// reference. Ref can be a SHA, a branch name, or a tag name.
// reference. Ref can be a SHA, a branch name, or a tag name.
//
// GitHub API docs: http://developer.github.com/v3/repos/statuses/#create-a-status
func (s *RepositoriesService) CreateStatus(owner, repo, ref string, status *RepoStatus) (*RepoStatus, *Response, error) {
@ -80,12 +80,12 @@ func (s *RepositoriesService) CreateStatus(owner, repo, ref string, status *Repo
return nil, resp, err
}
return repoStatus, resp, err
return repoStatus, resp, nil
}
// CombinedStatus represents the combined status of a repository at a particular reference.
type CombinedStatus struct {
// State is the combined state of the repository. Possible values are:
// State is the combined state of the repository. Possible values are:
// failure, pending, or success.
State *string `json:"state,omitempty"`
@ -103,7 +103,7 @@ func (s CombinedStatus) String() string {
}
// GetCombinedStatus returns the combined status of a repository at the specified
// reference. ref can be a SHA, a branch name, or a tag name.
// reference. ref can be a SHA, a branch name, or a tag name.
//
// GitHub API docs: https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
func (s *RepositoriesService) GetCombinedStatus(owner, repo, ref string, opt *ListOptions) (*CombinedStatus, *Response, error) {
@ -124,5 +124,5 @@ func (s *RepositoriesService) GetCombinedStatus(owner, repo, ref string, opt *Li
return nil, resp, err
}
return status, resp, err
return status, resp, nil
}

View File

@ -110,7 +110,7 @@ func (s *RepositoriesService) ListTrafficViews(owner, repo string, opt *TrafficB
return nil, resp, err
}
return trafficViews, resp, err
return trafficViews, resp, nil
}
// ListTrafficClones get total number of clones for the last 14 days and breaks it down either per day or week for the last 14 days.
@ -134,5 +134,5 @@ func (s *RepositoriesService) ListTrafficClones(owner, repo string, opt *Traffic
return nil, resp, err
}
return trafficClones, resp, err
return trafficClones, resp, nil
}

View File

@ -19,7 +19,7 @@ type SearchService service
// SearchOptions specifies optional parameters to the SearchService methods.
type SearchOptions struct {
// How to sort the search results. Possible values are:
// How to sort the search results. Possible values are:
// - for repositories: stars, fork, updated
// - for commits: author-date, committer-date
// - for code: indexed

View File

@ -16,7 +16,7 @@ import (
var timestampType = reflect.TypeOf(Timestamp{})
// Stringify attempts to create a reasonable string representation of types in
// the GitHub library. It does things like resolve pointers to their values
// the GitHub library. It does things like resolve pointers to their values
// and omits struct fields with nil values.
func Stringify(message interface{}) string {
var buf bytes.Buffer

View File

@ -68,7 +68,7 @@ func (u User) String() string {
return Stringify(u)
}
// Get fetches a user. Passing the empty string will fetch the authenticated
// Get fetches a user. Passing the empty string will fetch the authenticated
// user.
//
// GitHub API docs: http://developer.github.com/v3/users/#get-a-single-user
@ -90,7 +90,7 @@ func (s *UsersService) Get(user string) (*User, *Response, error) {
return nil, resp, err
}
return uResp, resp, err
return uResp, resp, nil
}
// GetByID fetches a user.
@ -109,7 +109,7 @@ func (s *UsersService) GetByID(id int) (*User, *Response, error) {
return nil, resp, err
}
return user, resp, err
return user, resp, nil
}
// Edit the authenticated user.
@ -128,7 +128,7 @@ func (s *UsersService) Edit(user *User) (*User, *Response, error) {
return nil, resp, err
}
return uResp, resp, err
return uResp, resp, nil
}
// UserListOptions specifies optional parameters to the UsersService.ListAll
@ -184,7 +184,7 @@ func (s *UsersService) ListInvitations() ([]*RepositoryInvitation, *Response, er
return nil, resp, err
}
return invites, resp, err
return invites, resp, nil
}
// AcceptInvitation accepts the currently-open repository invitation for the

View File

@ -7,7 +7,7 @@ package github
import "fmt"
// ListFollowers lists the followers for a user. Passing the empty string will
// ListFollowers lists the followers for a user. Passing the empty string will
// fetch followers for the authenticated user.
//
// GitHub API docs: http://developer.github.com/v3/users/followers/#list-followers-of-a-user
@ -37,7 +37,7 @@ func (s *UsersService) ListFollowers(user string, opt *ListOptions) ([]*User, *R
return users, resp, nil
}
// ListFollowing lists the people that a user is following. Passing the empty
// ListFollowing lists the people that a user is following. Passing the empty
// string will list people the authenticated user is following.
//
// GitHub API docs: http://developer.github.com/v3/users/followers/#list-users-followed-by-another-user
@ -67,7 +67,7 @@ func (s *UsersService) ListFollowing(user string, opt *ListOptions) ([]*User, *R
return users, resp, nil
}
// IsFollowing checks if "user" is following "target". Passing the empty
// IsFollowing checks if "user" is following "target". Passing the empty
// string for "user" will check if the authenticated user is following "target".
//
// GitHub API docs: http://developer.github.com/v3/users/followers/#check-if-you-are-following-a-user

View File

@ -58,7 +58,7 @@ func (s *UsersService) ListGPGKeys() ([]*GPGKey, *Response, error) {
return nil, resp, err
}
return keys, resp, err
return keys, resp, nil
}
// GetGPGKey gets extended details for a single GPG key. It requires authentication
@ -81,7 +81,7 @@ func (s *UsersService) GetGPGKey(id int) (*GPGKey, *Response, error) {
return nil, resp, err
}
return key, resp, err
return key, resp, nil
}
// CreateGPGKey creates a GPG key. It requires authenticatation via Basic Auth
@ -106,7 +106,7 @@ func (s *UsersService) CreateGPGKey(armoredPublicKey string) (*GPGKey, *Response
return nil, resp, err
}
return key, resp, err
return key, resp, nil
}
// DeleteGPGKey deletes a GPG key. It requires authentication via Basic Auth or

View File

@ -20,7 +20,7 @@ func (k Key) String() string {
return Stringify(k)
}
// ListKeys lists the verified public keys for a user. Passing the empty
// ListKeys lists the verified public keys for a user. Passing the empty
// string will fetch keys for the authenticated user.
//
// GitHub API docs: http://developer.github.com/v3/users/keys/#list-public-keys-for-a-user
@ -67,7 +67,7 @@ func (s *UsersService) GetKey(id int) (*Key, *Response, error) {
return nil, resp, err
}
return key, resp, err
return key, resp, nil
}
// CreateKey adds a public key for the authenticated user.
@ -87,7 +87,7 @@ func (s *UsersService) CreateKey(key *Key) (*Key, *Response, error) {
return nil, resp, err
}
return k, resp, err
return k, resp, nil
}
// DeleteKey deletes a public key.

View File

@ -2,6 +2,7 @@ package api
import (
"bytes"
"context"
"crypto/tls"
"crypto/x509"
"encoding/json"
@ -79,6 +80,11 @@ type QueryOptions struct {
// metadata key/value pairs. Currently, only one key/value pair can
// be provided for filtering.
NodeMeta map[string]string
// RelayFactor is used in keyring operations to cause reponses to be
// relayed back to the sender through N other random nodes. Must be
// a value from 0 to 5 (inclusive).
RelayFactor uint8
}
// WriteOptions are used to parameterize a write
@ -90,6 +96,11 @@ type WriteOptions struct {
// Token is used to provide a per-request ACL token
// which overrides the agent's default token.
Token string
// RelayFactor is used in keyring operations to cause reponses to be
// relayed back to the sender through N other random nodes. Must be
// a value from 0 to 5 (inclusive).
RelayFactor uint8
}
// QueryMeta is used to return meta data about a query
@ -336,13 +347,22 @@ func NewClient(config *Config) (*Client, error) {
config.HttpClient = defConfig.HttpClient
}
if parts := strings.SplitN(config.Address, "unix://", 2); len(parts) == 2 {
trans := cleanhttp.DefaultTransport()
trans.Dial = func(_, _ string) (net.Conn, error) {
return net.Dial("unix", parts[1])
}
config.HttpClient = &http.Client{
Transport: trans,
parts := strings.SplitN(config.Address, "://", 2)
if len(parts) == 2 {
switch parts[0] {
case "http":
case "https":
config.Scheme = "https"
case "unix":
trans := cleanhttp.DefaultTransport()
trans.DialContext = func(_ context.Context, _, _ string) (net.Conn, error) {
return net.Dial("unix", parts[1])
}
config.HttpClient = &http.Client{
Transport: trans,
}
default:
return nil, fmt.Errorf("Unknown protocol scheme: %s", parts[0])
}
config.Address = parts[1]
}
@ -396,6 +416,9 @@ func (r *request) setQueryOptions(q *QueryOptions) {
r.params.Add("node-meta", key+":"+value)
}
}
if q.RelayFactor != 0 {
r.params.Set("relay-factor", strconv.Itoa(int(q.RelayFactor)))
}
}
// durToMsec converts a duration to a millisecond specified string. If the
@ -437,6 +460,9 @@ func (r *request) setWriteOptions(q *WriteOptions) {
if q.Token != "" {
r.header.Set("X-Consul-Token", q.Token)
}
if q.RelayFactor != 0 {
r.params.Set("relay-factor", strconv.Itoa(int(q.RelayFactor)))
}
}
// toHTTP converts the request to an HTTP request

View File

@ -7,8 +7,8 @@ import (
"time"
)
// DefaultTransport returns a new http.Transport with the same default values
// as http.DefaultTransport, but with idle connections and keepalives disabled.
// DefaultTransport returns a new http.Transport with similar default values to
// http.DefaultTransport, but with idle connections and keepalives disabled.
func DefaultTransport() *http.Transport {
transport := DefaultPooledTransport()
transport.DisableKeepAlives = true
@ -45,10 +45,10 @@ func DefaultClient() *http.Client {
}
}
// DefaultPooledClient returns a new http.Client with the same default values
// as http.Client, but with a shared Transport. Do not use this function
// for transient clients as it can leak file descriptors over time. Only use
// this for clients that will be re-used for the same host(s).
// DefaultPooledClient returns a new http.Client with similar default values to
// http.Client, but with a shared Transport. Do not use this function for
// transient clients as it can leak file descriptors over time. Only use this
// for clients that will be re-used for the same host(s).
func DefaultPooledClient() *http.Client {
return &http.Client{
Transport: DefaultPooledTransport(),

9
vendor/github.com/lib/pq/conn.go generated vendored
View File

@ -664,9 +664,12 @@ func (cn *conn) simpleQuery(q string) (res *rows, err error) {
res = &rows{
cn: cn,
}
if t == 'C' {
res.result, res.tag = cn.parseComplete(r.string())
}
}
// Set the result and tag to the last command complete if there wasn't a
// query already run. Although queries usually return from here and cede
// control to Next, a query with zero results does not.
if t == 'C' && res.colNames == nil {
res.result, res.tag = cn.parseComplete(r.string())
}
res.done = true
case 'Z':

View File

@ -1,5 +1,7 @@
# go-isatty
[![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty) [![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master)
isatty for golang
## Usage
@ -16,6 +18,8 @@ import (
func main() {
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Println("Is Terminal")
} else if isatty.IsCygwinTerminal(os.Stdout.Fd()) {
fmt.Println("Is Cygwin/MSYS2 Terminal")
} else {
fmt.Println("Is Not Terminal")
}
@ -28,10 +32,16 @@ func main() {
$ go get github.com/mattn/go-isatty
```
# License
## License
MIT
# Author
## Author
Yasuhiro Matsumoto (a.k.a mattn)
## Thanks
* k-takata: base idea for IsCygwinTerminal
https://github.com/k-takata/go-iscygpty

9
vendor/github.com/mattn/go-isatty/isatty_others.go generated vendored Normal file
View File

@ -0,0 +1,9 @@
// +build !windows appengine
package isatty
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
// terminal. This is also always false on this environment.
func IsCygwinTerminal(fd uintptr) bool {
return false
}

View File

@ -4,12 +4,30 @@
package isatty
import (
"strings"
"syscall"
"unicode/utf16"
"unsafe"
)
var kernel32 = syscall.NewLazyDLL("kernel32.dll")
var procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
const (
fileNameInfo uintptr = 2
fileTypePipe = 3
)
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
procGetFileType = kernel32.NewProc("GetFileType")
)
func init() {
// Check if GetFileInformationByHandleEx is available.
if procGetFileInformationByHandleEx.Find() != nil {
procGetFileInformationByHandleEx = nil
}
}
// IsTerminal return true if the file descriptor is terminal.
func IsTerminal(fd uintptr) bool {
@ -17,3 +35,60 @@ func IsTerminal(fd uintptr) bool {
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
return r != 0 && e == 0
}
// Check pipe name is used for cygwin/msys2 pty.
// Cygwin/MSYS2 PTY has a name like:
// \{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master
func isCygwinPipeName(name string) bool {
token := strings.Split(name, "-")
if len(token) < 5 {
return false
}
if token[0] != `\msys` && token[0] != `\cygwin` {
return false
}
if token[1] == "" {
return false
}
if !strings.HasPrefix(token[2], "pty") {
return false
}
if token[3] != `from` && token[3] != `to` {
return false
}
if token[4] != "master" {
return false
}
return true
}
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
// terminal.
func IsCygwinTerminal(fd uintptr) bool {
if procGetFileInformationByHandleEx == nil {
return false
}
// Cygwin/msys's pty is a pipe.
ft, _, e := syscall.Syscall(procGetFileType.Addr(), 1, fd, 0, 0)
if ft != fileTypePipe || e != 0 {
return false
}
var buf [2 + syscall.MAX_PATH]uint16
r, _, e := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(),
4, fd, fileNameInfo, uintptr(unsafe.Pointer(&buf)),
uintptr(len(buf)*2), 0, 0)
if r == 0 || e != 0 {
return false
}
l := *(*uint32)(unsafe.Pointer(&buf))
return isCygwinPipeName(string(utf16.Decode(buf[2 : 2+l/2])))
}

View File

@ -25,7 +25,7 @@ import (
//
// * We use longest prefix matching to find a matching subcommand. This
// means if you register "foo bar" and the user executes "cli foo qux",
// the "foo" commmand will be executed with the arg "qux". It is up to
// the "foo" command will be executed with the arg "qux". It is up to
// you to handle these args. One option is to just return the special
// help return code `RunResultHelp` to display help and exit.
//

View File

@ -83,9 +83,9 @@ func stringFormat(c *Config, widths []int, columns int) string {
// elementsFromLine returns a list of elements, each representing a single
// item which will belong to a column of output.
func elementsFromLine(config *Config, line string) []interface{} {
seperated := strings.Split(line, config.Delim)
elements := make([]interface{}, len(seperated))
for i, field := range seperated {
separated := strings.Split(line, config.Delim)
elements := make([]interface{}, len(separated))
for i, field := range separated {
value := strings.TrimSpace(field)
// Apply the empty value, if configured.

View File

@ -310,6 +310,8 @@ func (e *jsonEncDriver) quoteStr(s string) {
w.writen1('"')
start := 0
for i := 0; i < len(s); {
// encode all bytes < 0x20 (except \r, \n).
// also encode < > & to prevent security holes when served to some browsers.
if b := s[i]; b < utf8.RuneSelf {
if 0x20 <= b && b != '\\' && b != '"' && b != '<' && b != '>' && b != '&' {
i++
@ -331,9 +333,14 @@ func (e *jsonEncDriver) quoteStr(s string) {
w.writen2('\\', 'f')
case '\t':
w.writen2('\\', 't')
case '<', '>', '&':
if e.h.HTMLCharsAsIs {
w.writen1(b)
} else {
w.writestr(`\u00`)
w.writen2(hex[b>>4], hex[b&0xF])
}
default:
// encode all bytes < 0x20 (except \r, \n).
// also encode < > & to prevent security holes when served to some browsers.
w.writestr(`\u00`)
w.writen2(hex[b>>4], hex[b&0xF])
}
@ -352,7 +359,7 @@ func (e *jsonEncDriver) quoteStr(s string) {
continue
}
// U+2028 is LINE SEPARATOR. U+2029 is PARAGRAPH SEPARATOR.
// Both technically valid JSON, but bomb on JSONP, so fix here.
// Both technically valid JSON, but bomb on JSONP, so fix here unconditionally.
if c == '\u2028' || c == '\u2029' {
if start < i {
w.writestr(s[start:i])
@ -1173,6 +1180,12 @@ type JsonHandle struct {
// containing the exact integer representation as a decimal.
// - else encode all integers as a json number (default)
IntegerAsString uint8
// HTMLCharsAsIs controls how to encode some special characters to html: < > &
//
// By default, we encode them as \uXXX
// to prevent security holes when served from some browsers.
HTMLCharsAsIs bool
}
func (h *JsonHandle) SetInterfaceExt(rt reflect.Type, tag uint64, ext InterfaceExt) (err error) {

View File

@ -34,7 +34,7 @@ def get_test_data_list():
True,
u"null",
None,
u"someday",
u"some&day>some<day",
1328176922000002000,
u"",
-2206187877999998000,

View File

@ -135,6 +135,7 @@ const prefixLen = 5
type streamPacketCipher struct {
mac hash.Hash
cipher cipher.Stream
etm bool
// The following members are to avoid per-packet allocations.
prefix [prefixLen]byte
@ -150,7 +151,14 @@ func (s *streamPacketCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, err
return nil, err
}
s.cipher.XORKeyStream(s.prefix[:], s.prefix[:])
var encryptedPaddingLength [1]byte
if s.mac != nil && s.etm {
copy(encryptedPaddingLength[:], s.prefix[4:5])
s.cipher.XORKeyStream(s.prefix[4:5], s.prefix[4:5])
} else {
s.cipher.XORKeyStream(s.prefix[:], s.prefix[:])
}
length := binary.BigEndian.Uint32(s.prefix[0:4])
paddingLength := uint32(s.prefix[4])
@ -159,7 +167,12 @@ func (s *streamPacketCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, err
s.mac.Reset()
binary.BigEndian.PutUint32(s.seqNumBytes[:], seqNum)
s.mac.Write(s.seqNumBytes[:])
s.mac.Write(s.prefix[:])
if s.etm {
s.mac.Write(s.prefix[:4])
s.mac.Write(encryptedPaddingLength[:])
} else {
s.mac.Write(s.prefix[:])
}
macSize = uint32(s.mac.Size())
}
@ -184,10 +197,17 @@ func (s *streamPacketCipher) readPacket(seqNum uint32, r io.Reader) ([]byte, err
}
mac := s.packetData[length-1:]
data := s.packetData[:length-1]
if s.mac != nil && s.etm {
s.mac.Write(data)
}
s.cipher.XORKeyStream(data, data)
if s.mac != nil {
s.mac.Write(data)
if !s.etm {
s.mac.Write(data)
}
s.macResult = s.mac.Sum(s.macResult[:0])
if subtle.ConstantTimeCompare(s.macResult, mac) != 1 {
return nil, errors.New("ssh: MAC failure")
@ -203,7 +223,13 @@ func (s *streamPacketCipher) writePacket(seqNum uint32, w io.Writer, rand io.Rea
return errors.New("ssh: packet too large")
}
paddingLength := packetSizeMultiple - (prefixLen+len(packet))%packetSizeMultiple
aadlen := 0
if s.mac != nil && s.etm {
// packet length is not encrypted for EtM modes
aadlen = 4
}
paddingLength := packetSizeMultiple - (prefixLen+len(packet)-aadlen)%packetSizeMultiple
if paddingLength < 4 {
paddingLength += packetSizeMultiple
}
@ -220,15 +246,37 @@ func (s *streamPacketCipher) writePacket(seqNum uint32, w io.Writer, rand io.Rea
s.mac.Reset()
binary.BigEndian.PutUint32(s.seqNumBytes[:], seqNum)
s.mac.Write(s.seqNumBytes[:])
if s.etm {
// For EtM algorithms, the packet length must stay unencrypted,
// but the following data (padding length) must be encrypted
s.cipher.XORKeyStream(s.prefix[4:5], s.prefix[4:5])
}
s.mac.Write(s.prefix[:])
if !s.etm {
// For non-EtM algorithms, the algorithm is applied on unencrypted data
s.mac.Write(packet)
s.mac.Write(padding)
}
}
if !(s.mac != nil && s.etm) {
// For EtM algorithms, the padding length has already been encrypted
// and the packet length must remain unencrypted
s.cipher.XORKeyStream(s.prefix[:], s.prefix[:])
}
s.cipher.XORKeyStream(packet, packet)
s.cipher.XORKeyStream(padding, padding)
if s.mac != nil && s.etm {
// For EtM algorithms, packet and padding must be encrypted
s.mac.Write(packet)
s.mac.Write(padding)
}
s.cipher.XORKeyStream(s.prefix[:], s.prefix[:])
s.cipher.XORKeyStream(packet, packet)
s.cipher.XORKeyStream(padding, padding)
if _, err := w.Write(s.prefix[:]); err != nil {
return err
}

View File

@ -56,7 +56,7 @@ var supportedHostKeyAlgos = []string{
// This is based on RFC 4253, section 6.4, but with hmac-md5 variants removed
// because they have reached the end of their useful life.
var supportedMACs = []string{
"hmac-sha2-256", "hmac-sha1", "hmac-sha1-96",
"hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha1", "hmac-sha1-96",
}
var supportedCompressions = []string{compressionNone}

View File

@ -15,6 +15,7 @@ import (
type macMode struct {
keySize int
etm bool
new func(key []byte) hash.Hash
}
@ -45,13 +46,16 @@ func (t truncatingMAC) Size() int {
func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() }
var macModes = map[string]*macMode{
"hmac-sha2-256": {32, func(key []byte) hash.Hash {
"hmac-sha2-256-etm@openssh.com": {32, true, func(key []byte) hash.Hash {
return hmac.New(sha256.New, key)
}},
"hmac-sha1": {20, func(key []byte) hash.Hash {
"hmac-sha2-256": {32, false, func(key []byte) hash.Hash {
return hmac.New(sha256.New, key)
}},
"hmac-sha1": {20, false, func(key []byte) hash.Hash {
return hmac.New(sha1.New, key)
}},
"hmac-sha1-96": {20, func(key []byte) hash.Hash {
"hmac-sha1-96": {20, false, func(key []byte) hash.Hash {
return truncatingMAC{12, hmac.New(sha1.New, key)}
}},
}

View File

@ -267,6 +267,7 @@ func newPacketCipher(d direction, algs directionAlgorithms, kex *kexResult) (pac
c := &streamPacketCipher{
mac: macModes[algs.MAC].new(macKey),
etm: macModes[algs.MAC].etm,
}
c.macResult = make([]byte, c.mac.Size())

View File

@ -42,7 +42,7 @@ func ParseKey(key []byte) (*rsa.PrivateKey, error) {
func ParseINI(ini io.Reader) (map[string]map[string]string, error) {
result := map[string]map[string]string{
"": map[string]string{}, // root section
"": {}, // root section
}
scanner := bufio.NewScanner(ini)
currentSection := ""

View File

@ -91,6 +91,7 @@ func (e *expirationTime) UnmarshalJSON(b []byte) error {
var brokenAuthHeaderProviders = []string{
"https://accounts.google.com/",
"https://api.codeswholesale.com/oauth/token",
"https://api.dropbox.com/",
"https://api.dropboxapi.com/",
"https://api.instagram.com/",
@ -101,6 +102,7 @@ var brokenAuthHeaderProviders = []string{
"https://api.twitch.tv/",
"https://app.box.com/",
"https://connect.stripe.com/",
"https://graph.facebook.com", // see https://github.com/golang/oauth2/issues/214
"https://login.microsoftonline.com/",
"https://login.salesforce.com/",
"https://oauth.sandbox.trainingpeaks.com/",
@ -118,7 +120,6 @@ var brokenAuthHeaderProviders = []string{
"https://www.wunderlist.com/oauth/",
"https://api.patreon.com/",
"https://sandbox.codeswholesale.com/oauth/token",
"https://api.codeswholesale.com/oauth/token",
}
func RegisterBrokenAuthHeaderProvider(tokenURL string) {

10
vendor/golang.org/x/sys/unix/asm.s generated vendored
View File

@ -1,10 +0,0 @@
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !gccgo
#include "textflag.h"
TEXT ·use(SB),NOSPLIT,$0
RET

View File

@ -89,6 +89,8 @@ case "$1" in
-syscalls)
for i in zsyscall*go
do
# Run the command line that appears in the first line
# of the generated file to regenerate it.
sed 1q $i | sed 's;^// ;;' | sh > _$i && gofmt < _$i > $i
rm _$i
done
@ -280,7 +282,7 @@ esac
syscall_goos="syscall_bsd.go $syscall_goos"
;;
esac
if [ -n "$mksyscall" ]; then echo "$mksyscall $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; fi
if [ -n "$mksyscall" ]; then echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go"; fi
;;
esac
if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi

View File

@ -114,11 +114,13 @@ includes_Linux='
#include <sys/time.h>
#include <sys/socket.h>
#include <linux/if.h>
#include <linux/if_alg.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/if_tun.h>
#include <linux/if_packet.h>
#include <linux/if_addr.h>
#include <linux/falloc.h>
#include <linux/filter.h>
#include <linux/netlink.h>
#include <linux/reboot.h>
@ -312,6 +314,7 @@ ccflags="$@"
$2 ~ /^IN_/ ||
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
$2 ~ /^FALLOC_/ ||
$2 == "ICMPV6_FILTER" ||
$2 == "SOMAXCONN" ||
$2 == "NAME_MAX" ||
@ -341,6 +344,8 @@ ccflags="$@"
$2 ~ /^(BPF|DLT)_/ ||
$2 ~ /^CLOCK_/ ||
$2 ~ /^CAN_/ ||
$2 ~ /^ALG_/ ||
$2 ~ /^SPLICE_/ ||
$2 !~ "WMESGLEN" &&
$2 ~ /^W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", $2, $2)}
$2 ~ /^__WCOREFLAG$/ {next}
@ -456,7 +461,7 @@ main(void)
printf("\t%d: \"%s\",\n", e, buf);
}
printf("}\n\n");
printf("\n\n// Signal table\n");
printf("var signals = [...]string {\n");
qsort(signals, nelem(signals), sizeof signals[0], intcmp);

View File

@ -29,6 +29,7 @@ my $openbsd = 0;
my $netbsd = 0;
my $dragonfly = 0;
my $arm = 0; # 64-bit value should use (even, odd)-pair
my $tags = ""; # build tags
if($ARGV[0] eq "-b32") {
$_32bit = "big-endian";
@ -57,14 +58,14 @@ if($ARGV[0] eq "-arm") {
$arm = 1;
shift;
}
if($ARGV[0] =~ /^-/) {
print STDERR "usage: mksyscall.pl [-b32 | -l32] [file ...]\n";
exit 1;
if($ARGV[0] eq "-tags") {
shift;
$tags = $ARGV[0];
shift;
}
if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") {
print STDERR "GOARCH or GOOS not defined in environment\n";
if($ARGV[0] =~ /^-/) {
print STDERR "usage: mksyscall.pl [-b32 | -l32] [-tags x,y] [file ...]\n";
exit 1;
}
@ -132,7 +133,6 @@ while(<>) {
# Prepare arguments to Syscall.
my @args = ();
my @uses = ();
my $n = 0;
foreach my $p (@in) {
my ($name, $type) = parseparam($p);
@ -143,14 +143,12 @@ while(<>) {
$text .= "\t_p$n, $errvar = BytePtrFromString($name)\n";
$text .= "\tif $errvar != nil {\n\t\treturn\n\t}\n";
push @args, "uintptr(unsafe.Pointer(_p$n))";
push @uses, "use(unsafe.Pointer(_p$n))";
$n++;
} elsif($type eq "string") {
print STDERR "$ARGV:$.: $func uses string arguments, but has no error return\n";
$text .= "\tvar _p$n *byte\n";
$text .= "\t_p$n, _ = BytePtrFromString($name)\n";
push @args, "uintptr(unsafe.Pointer(_p$n))";
push @uses, "use(unsafe.Pointer(_p$n))";
$n++;
} elsif($type =~ /^\[\](.*)/) {
# Convert slice into pointer, length.
@ -185,7 +183,7 @@ while(<>) {
}
} elsif($type eq "int64" && $_32bit ne "") {
if(@args % 2 && $arm) {
# arm abi specifies 64-bit argument uses
# arm abi specifies 64-bit argument uses
# (even, odd) pair
push @args, "0"
}
@ -278,11 +276,8 @@ while(<>) {
} else {
$text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
}
foreach my $use (@uses) {
$text .= "\t$use\n";
}
$text .= $body;
if ($plan9 && $ret[2] eq "e1") {
$text .= "\tif int32(r0) == -1 {\n";
$text .= "\t\terr = e1\n";
@ -307,7 +302,7 @@ print <<EOF;
// $cmdline
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// +build $ENV{'GOARCH'},$ENV{'GOOS'}
// +build $tags
package unix

Some files were not shown because too many files have changed in this diff Show More