vendor: update all dependencies
This commit is contained in:
+6
@@ -1,3 +1,9 @@
|
||||
// Copyright 2018 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated file. DO NOT EDIT.
|
||||
|
||||
// Package drive provides access to the Drive API.
|
||||
//
|
||||
// See https://developers.google.com/drive/
|
||||
|
||||
+18
-2
@@ -35,7 +35,7 @@
|
||||
"description": "Manages files in Drive including uploading, downloading, searching, detecting changes, and updating sharing permissions.",
|
||||
"discoveryVersion": "v1",
|
||||
"documentationLink": "https://developers.google.com/drive/",
|
||||
"etag": "\"J3WqvAcMk4eQjJXvfSI4Yr8VouA/ESklhHtjidCDMugyP9gJKRCO-YM\"",
|
||||
"etag": "\"J3WqvAcMk4eQjJXvfSI4Yr8VouA/DmsVwHXLUfZJqrDE1d-9tgSUvKk\"",
|
||||
"icons": {
|
||||
"x16": "https://ssl.gstatic.com/docs/doclist/images/drive_icon_16.png",
|
||||
"x32": "https://ssl.gstatic.com/docs/doclist/images/drive_icon_32.png"
|
||||
@@ -1770,7 +1770,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"revision": "20181025",
|
||||
"revision": "20181213",
|
||||
"rootUrl": "https://www.googleapis.com/",
|
||||
"schemas": {
|
||||
"About": {
|
||||
@@ -2260,6 +2260,14 @@
|
||||
"description": "Whether the file has been explicitly trashed, as opposed to recursively trashed from a parent folder.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"exportLinks": {
|
||||
"additionalProperties": {
|
||||
"description": "A mapping from export format to URL",
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Links for exporting Google Docs to specific formats.",
|
||||
"type": "object"
|
||||
},
|
||||
"fileExtension": {
|
||||
"description": "The final component of fullFileExtension. This is only available for files with binary content in Drive.",
|
||||
"type": "string"
|
||||
@@ -2844,6 +2852,14 @@
|
||||
"description": "The metadata for a revision to a file.",
|
||||
"id": "Revision",
|
||||
"properties": {
|
||||
"exportLinks": {
|
||||
"additionalProperties": {
|
||||
"description": "A mapping from export format to URL",
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Links for exporting Google Docs to specific formats.",
|
||||
"type": "object"
|
||||
},
|
||||
"id": {
|
||||
"description": "The ID of the revision.",
|
||||
"type": "string"
|
||||
|
||||
+17
-5
@@ -1,3 +1,9 @@
|
||||
// Copyright 2018 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated file. DO NOT EDIT.
|
||||
|
||||
// Package drive provides access to the Drive API.
|
||||
//
|
||||
// See https://developers.google.com/drive/
|
||||
@@ -696,6 +702,9 @@ type File struct {
|
||||
// opposed to recursively trashed from a parent folder.
|
||||
ExplicitlyTrashed bool `json:"explicitlyTrashed,omitempty"`
|
||||
|
||||
// ExportLinks: Links for exporting Google Docs to specific formats.
|
||||
ExportLinks map[string]string `json:"exportLinks,omitempty"`
|
||||
|
||||
// FileExtension: The final component of fullFileExtension. This is only
|
||||
// available for files with binary content in Drive.
|
||||
FileExtension string `json:"fileExtension,omitempty"`
|
||||
@@ -1721,6 +1730,9 @@ func (s *ReplyList) MarshalJSON() ([]byte, error) {
|
||||
|
||||
// Revision: The metadata for a revision to a file.
|
||||
type Revision struct {
|
||||
// ExportLinks: Links for exporting Google Docs to specific formats.
|
||||
ExportLinks map[string]string `json:"exportLinks,omitempty"`
|
||||
|
||||
// Id: The ID of the revision.
|
||||
Id string `json:"id,omitempty"`
|
||||
|
||||
@@ -1773,7 +1785,7 @@ type Revision struct {
|
||||
// server.
|
||||
googleapi.ServerResponse `json:"-"`
|
||||
|
||||
// ForceSendFields is a list of field names (e.g. "Id") to
|
||||
// ForceSendFields is a list of field names (e.g. "ExportLinks") to
|
||||
// unconditionally include in API requests. By default, fields with
|
||||
// empty values are omitted from API requests. However, any non-pointer,
|
||||
// non-interface field appearing in ForceSendFields will be sent to the
|
||||
@@ -1781,10 +1793,10 @@ type Revision struct {
|
||||
// used to include empty fields in Patch requests.
|
||||
ForceSendFields []string `json:"-"`
|
||||
|
||||
// NullFields is a list of field names (e.g. "Id") to include in API
|
||||
// requests with the JSON null value. By default, fields with empty
|
||||
// values are omitted from API requests. However, any field with an
|
||||
// empty value appearing in NullFields will be sent to the server as
|
||||
// NullFields is a list of field names (e.g. "ExportLinks") to include
|
||||
// in API requests with the JSON null value. By default, fields with
|
||||
// empty values are omitted from API requests. However, any field with
|
||||
// an empty value appearing in NullFields will be sent to the server as
|
||||
// null. It is an error if a field in this list has a non-empty value.
|
||||
// This may be used to include null fields in Patch requests.
|
||||
NullFields []string `json:"-"`
|
||||
|
||||
+5
@@ -9,6 +9,8 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// BackoffStrategy defines the set of functions that a backoff-er must
|
||||
// implement.
|
||||
type BackoffStrategy interface {
|
||||
// Pause returns the duration of the next pause and true if the operation should be
|
||||
// retried, or false if no further retries should be attempted.
|
||||
@@ -28,6 +30,7 @@ type ExponentialBackoff struct {
|
||||
n uint
|
||||
}
|
||||
|
||||
// Pause returns the amount of time the caller should wait.
|
||||
func (eb *ExponentialBackoff) Pause() (time.Duration, bool) {
|
||||
if eb.total > eb.Max {
|
||||
return 0, false
|
||||
@@ -40,6 +43,8 @@ func (eb *ExponentialBackoff) Pause() (time.Duration, bool) {
|
||||
return d, true
|
||||
}
|
||||
|
||||
// Reset resets the backoff strategy such that the next Pause call will begin
|
||||
// counting from the start. It is not safe to call concurrently with Pause.
|
||||
func (eb *ExponentialBackoff) Reset() {
|
||||
eb.n = 0
|
||||
eb.total = 0
|
||||
|
||||
+3
-1
@@ -11,7 +11,8 @@ import (
|
||||
"google.golang.org/api/googleapi"
|
||||
)
|
||||
|
||||
// MediaBuffer buffers data from an io.Reader to support uploading media in retryable chunks.
|
||||
// MediaBuffer buffers data from an io.Reader to support uploading media in
|
||||
// retryable chunks. It should be created with NewMediaBuffer.
|
||||
type MediaBuffer struct {
|
||||
media io.Reader
|
||||
|
||||
@@ -22,6 +23,7 @@ type MediaBuffer struct {
|
||||
off int64
|
||||
}
|
||||
|
||||
// NewMediaBuffer initializes a MediaBuffer.
|
||||
func NewMediaBuffer(media io.Reader, chunkSize int) *MediaBuffer {
|
||||
return &MediaBuffer{media: media, chunk: make([]byte, 0, chunkSize)}
|
||||
}
|
||||
|
||||
+1
@@ -242,6 +242,7 @@ func NewInfoFromResumableMedia(r io.ReaderAt, size int64, mediaType string) *Med
|
||||
}
|
||||
}
|
||||
|
||||
// SetProgressUpdater sets the progress updater for the media info.
|
||||
func (mi *MediaInfo) SetProgressUpdater(pu googleapi.ProgressUpdater) {
|
||||
if mi != nil {
|
||||
mi.progressUpdater = pu
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ func (u URLParams) Encode() string {
|
||||
return url.Values(u).Encode()
|
||||
}
|
||||
|
||||
// SetOptions sets the URL params and any additional call options.
|
||||
func SetOptions(u URLParams, opts ...googleapi.CallOption) {
|
||||
for _, o := range opts {
|
||||
u.Set(o.Get())
|
||||
|
||||
+19
-5
@@ -37,24 +37,28 @@ type SizeReaderAt interface {
|
||||
// ServerResponse is embedded in each Do response and
|
||||
// provides the HTTP status code and header sent by the server.
|
||||
type ServerResponse struct {
|
||||
// HTTPStatusCode is the server's response status code.
|
||||
// When using a resource method's Do call, this will always be in the 2xx range.
|
||||
// HTTPStatusCode is the server's response status code. When using a
|
||||
// resource method's Do call, this will always be in the 2xx range.
|
||||
HTTPStatusCode int
|
||||
// Header contains the response header fields from the server.
|
||||
Header http.Header
|
||||
}
|
||||
|
||||
const (
|
||||
// Version defines the gax version being used. This is typically sent
|
||||
// in an HTTP header to services.
|
||||
Version = "0.5"
|
||||
|
||||
// UserAgent is the header string used to identify this package.
|
||||
UserAgent = "google-api-go-client/" + Version
|
||||
|
||||
// The default chunk size to use for resumable uploads if not specified by the user.
|
||||
// DefaultUploadChunkSize is the default chunk size to use for resumable
|
||||
// uploads if not specified by the user.
|
||||
DefaultUploadChunkSize = 8 * 1024 * 1024
|
||||
|
||||
// The minimum chunk size that can be used for resumable uploads. All
|
||||
// user-specified chunk sizes must be multiple of this value.
|
||||
// MinUploadChunkSize is the minimum chunk size that can be used for
|
||||
// resumable uploads. All user-specified chunk sizes must be multiple of
|
||||
// this value.
|
||||
MinUploadChunkSize = 256 * 1024
|
||||
)
|
||||
|
||||
@@ -161,9 +165,13 @@ func CheckMediaResponse(res *http.Response) error {
|
||||
}
|
||||
}
|
||||
|
||||
// MarshalStyle defines whether to marshal JSON with a {"data": ...} wrapper.
|
||||
type MarshalStyle bool
|
||||
|
||||
// WithDataWrapper marshals JSON with a {"data": ...} wrapper.
|
||||
var WithDataWrapper = MarshalStyle(true)
|
||||
|
||||
// WithoutDataWrapper marshals JSON without a {"data": ...} wrapper.
|
||||
var WithoutDataWrapper = MarshalStyle(false)
|
||||
|
||||
func (wrap MarshalStyle) JSONReader(v interface{}) (io.Reader, error) {
|
||||
@@ -212,6 +220,7 @@ func (w countingWriter) Write(p []byte) (int, error) {
|
||||
// The remaining usable pieces of resumable uploads is exposed in each auto-generated API.
|
||||
type ProgressUpdater func(current, total int64)
|
||||
|
||||
// MediaOption defines the interface for setting media options.
|
||||
type MediaOption interface {
|
||||
setOptions(o *MediaOptions)
|
||||
}
|
||||
@@ -268,6 +277,11 @@ func ProcessMediaOptions(opts []MediaOption) *MediaOptions {
|
||||
return mo
|
||||
}
|
||||
|
||||
// ResolveRelative resolves relatives such as "http://www.golang.org/" and
|
||||
// "topics/myproject/mytopic" into a single string, such as
|
||||
// "http://www.golang.org/topics/myproject/mytopic". It strips all parent
|
||||
// references (e.g. ../..) as well as anything after the host
|
||||
// (e.g. /bar/gaz gets stripped out of foo.com/bar/gaz).
|
||||
func ResolveRelative(basestr, relstr string) string {
|
||||
u, _ := url.Parse(basestr)
|
||||
afterColonPath := ""
|
||||
|
||||
+15
-15
@@ -120,33 +120,33 @@ func quotedList(n int, fn func(dst []byte, i int) []byte) ([]byte, error) {
|
||||
return dst, nil
|
||||
}
|
||||
|
||||
func (s Int64s) MarshalJSON() ([]byte, error) {
|
||||
return quotedList(len(s), func(dst []byte, i int) []byte {
|
||||
return strconv.AppendInt(dst, s[i], 10)
|
||||
func (q Int64s) MarshalJSON() ([]byte, error) {
|
||||
return quotedList(len(q), func(dst []byte, i int) []byte {
|
||||
return strconv.AppendInt(dst, q[i], 10)
|
||||
})
|
||||
}
|
||||
|
||||
func (s Int32s) MarshalJSON() ([]byte, error) {
|
||||
return quotedList(len(s), func(dst []byte, i int) []byte {
|
||||
return strconv.AppendInt(dst, int64(s[i]), 10)
|
||||
func (q Int32s) MarshalJSON() ([]byte, error) {
|
||||
return quotedList(len(q), func(dst []byte, i int) []byte {
|
||||
return strconv.AppendInt(dst, int64(q[i]), 10)
|
||||
})
|
||||
}
|
||||
|
||||
func (s Uint64s) MarshalJSON() ([]byte, error) {
|
||||
return quotedList(len(s), func(dst []byte, i int) []byte {
|
||||
return strconv.AppendUint(dst, s[i], 10)
|
||||
func (q Uint64s) MarshalJSON() ([]byte, error) {
|
||||
return quotedList(len(q), func(dst []byte, i int) []byte {
|
||||
return strconv.AppendUint(dst, q[i], 10)
|
||||
})
|
||||
}
|
||||
|
||||
func (s Uint32s) MarshalJSON() ([]byte, error) {
|
||||
return quotedList(len(s), func(dst []byte, i int) []byte {
|
||||
return strconv.AppendUint(dst, uint64(s[i]), 10)
|
||||
func (q Uint32s) MarshalJSON() ([]byte, error) {
|
||||
return quotedList(len(q), func(dst []byte, i int) []byte {
|
||||
return strconv.AppendUint(dst, uint64(q[i]), 10)
|
||||
})
|
||||
}
|
||||
|
||||
func (s Float64s) MarshalJSON() ([]byte, error) {
|
||||
return quotedList(len(s), func(dst []byte, i int) []byte {
|
||||
return strconv.AppendFloat(dst, s[i], 'g', -1, 64)
|
||||
func (q Float64s) MarshalJSON() ([]byte, error) {
|
||||
return quotedList(len(q), func(dst []byte, i int) []byte {
|
||||
return strconv.AppendFloat(dst, q[i], 'g', -1, 64)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+22
-2
@@ -26,7 +26,7 @@
|
||||
"description": "Stores and retrieves potentially large, immutable data objects.",
|
||||
"discoveryVersion": "v1",
|
||||
"documentationLink": "https://developers.google.com/storage/docs/json_api/",
|
||||
"etag": "\"J3WqvAcMk4eQjJXvfSI4Yr8VouA/LSpI3fR5lOQdDA6XHHjB1Bie2kU\"",
|
||||
"etag": "\"J3WqvAcMk4eQjJXvfSI4Yr8VouA/KPalWULMnQfaqumeaBhBrVfHFNM\"",
|
||||
"icons": {
|
||||
"x16": "https://www.google.com/images/icons/product/cloud_storage-16.png",
|
||||
"x32": "https://www.google.com/images/icons/product/cloud_storage-32.png"
|
||||
@@ -2766,7 +2766,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"revision": "20181013",
|
||||
"revision": "20181109",
|
||||
"rootUrl": "https://www.googleapis.com/",
|
||||
"schemas": {
|
||||
"Bucket": {
|
||||
@@ -2855,6 +2855,26 @@
|
||||
"description": "HTTP 1.1 Entity tag for the bucket.",
|
||||
"type": "string"
|
||||
},
|
||||
"iamConfiguration": {
|
||||
"description": "The bucket's IAM configuration.",
|
||||
"properties": {
|
||||
"bucketPolicyOnly": {
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"description": "If set, access checks only use bucket-level IAM policies or above.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"lockedTime": {
|
||||
"description": "The deadline time for changing iamConfiguration.bucketPolicyOnly.enabled from true to false in RFC 3339 format. iamConfiguration.bucketPolicyOnly.enabled may be changed from true to false until the locked time, after which the field is immutable.",
|
||||
"format": "date-time",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"id": {
|
||||
"description": "The ID of the bucket. For buckets, the id and name properties are the same.",
|
||||
"type": "string"
|
||||
|
||||
+72
@@ -1,3 +1,9 @@
|
||||
// Copyright 2018 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated file. DO NOT EDIT.
|
||||
|
||||
// Package storage provides access to the Cloud Storage JSON API.
|
||||
//
|
||||
// This package is DEPRECATED. Use package cloud.google.com/go/storage instead.
|
||||
@@ -231,6 +237,9 @@ type Bucket struct {
|
||||
// Etag: HTTP 1.1 Entity tag for the bucket.
|
||||
Etag string `json:"etag,omitempty"`
|
||||
|
||||
// IamConfiguration: The bucket's IAM configuration.
|
||||
IamConfiguration *BucketIamConfiguration `json:"iamConfiguration,omitempty"`
|
||||
|
||||
// Id: The ID of the bucket. For buckets, the id and name properties are
|
||||
// the same.
|
||||
Id string `json:"id,omitempty"`
|
||||
@@ -438,6 +447,69 @@ func (s *BucketEncryption) MarshalJSON() ([]byte, error) {
|
||||
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
|
||||
}
|
||||
|
||||
// BucketIamConfiguration: The bucket's IAM configuration.
|
||||
type BucketIamConfiguration struct {
|
||||
BucketPolicyOnly *BucketIamConfigurationBucketPolicyOnly `json:"bucketPolicyOnly,omitempty"`
|
||||
|
||||
// ForceSendFields is a list of field names (e.g. "BucketPolicyOnly") to
|
||||
// unconditionally include in API requests. By default, fields with
|
||||
// empty values are omitted from API requests. However, any non-pointer,
|
||||
// non-interface field appearing in ForceSendFields will be sent to the
|
||||
// server regardless of whether the field is empty or not. This may be
|
||||
// used to include empty fields in Patch requests.
|
||||
ForceSendFields []string `json:"-"`
|
||||
|
||||
// NullFields is a list of field names (e.g. "BucketPolicyOnly") to
|
||||
// include in API requests with the JSON null value. By default, fields
|
||||
// with empty values are omitted from API requests. However, any field
|
||||
// with an empty value appearing in NullFields will be sent to the
|
||||
// server as null. It is an error if a field in this list has a
|
||||
// non-empty value. This may be used to include null fields in Patch
|
||||
// requests.
|
||||
NullFields []string `json:"-"`
|
||||
}
|
||||
|
||||
func (s *BucketIamConfiguration) MarshalJSON() ([]byte, error) {
|
||||
type NoMethod BucketIamConfiguration
|
||||
raw := NoMethod(*s)
|
||||
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
|
||||
}
|
||||
|
||||
type BucketIamConfigurationBucketPolicyOnly struct {
|
||||
// Enabled: If set, access checks only use bucket-level IAM policies or
|
||||
// above.
|
||||
Enabled bool `json:"enabled,omitempty"`
|
||||
|
||||
// LockedTime: The deadline time for changing
|
||||
// iamConfiguration.bucketPolicyOnly.enabled from true to false in RFC
|
||||
// 3339 format. iamConfiguration.bucketPolicyOnly.enabled may be changed
|
||||
// from true to false until the locked time, after which the field is
|
||||
// immutable.
|
||||
LockedTime string `json:"lockedTime,omitempty"`
|
||||
|
||||
// ForceSendFields is a list of field names (e.g. "Enabled") to
|
||||
// unconditionally include in API requests. By default, fields with
|
||||
// empty values are omitted from API requests. However, any non-pointer,
|
||||
// non-interface field appearing in ForceSendFields will be sent to the
|
||||
// server regardless of whether the field is empty or not. This may be
|
||||
// used to include empty fields in Patch requests.
|
||||
ForceSendFields []string `json:"-"`
|
||||
|
||||
// NullFields is a list of field names (e.g. "Enabled") to include in
|
||||
// API requests with the JSON null value. By default, fields with empty
|
||||
// values are omitted from API requests. However, any field with an
|
||||
// empty value appearing in NullFields will be sent to the server as
|
||||
// null. It is an error if a field in this list has a non-empty value.
|
||||
// This may be used to include null fields in Patch requests.
|
||||
NullFields []string `json:"-"`
|
||||
}
|
||||
|
||||
func (s *BucketIamConfigurationBucketPolicyOnly) MarshalJSON() ([]byte, error) {
|
||||
type NoMethod BucketIamConfigurationBucketPolicyOnly
|
||||
raw := NoMethod(*s)
|
||||
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
|
||||
}
|
||||
|
||||
// BucketLifecycle: The bucket's lifecycle configuration. See lifecycle
|
||||
// management for more information.
|
||||
type BucketLifecycle struct {
|
||||
|
||||
+6
@@ -78,6 +78,12 @@ func IsAppEngine() bool {
|
||||
return internal.IsAppEngine()
|
||||
}
|
||||
|
||||
// IsSecondGen reports whether the App Engine app is running on the second generation
|
||||
// runtimes (>= Go 1.11).
|
||||
func IsSecondGen() bool {
|
||||
return internal.IsSecondGen()
|
||||
}
|
||||
|
||||
// NewContext returns a context for an in-flight HTTP request.
|
||||
// This function is cheap.
|
||||
func NewContext(req *http.Request) context.Context {
|
||||
|
||||
+4
-1
@@ -579,7 +579,10 @@ func logf(c *context, level int64, format string, args ...interface{}) {
|
||||
Level: &level,
|
||||
Message: &s,
|
||||
})
|
||||
log.Print(logLevelName[level] + ": " + s)
|
||||
// Only duplicate log to stderr if not running on App Engine second generation
|
||||
if !IsSecondGen() {
|
||||
log.Print(logLevelName[level] + ": " + s)
|
||||
}
|
||||
}
|
||||
|
||||
// flushLog attempts to flush any pending logs to the appserver.
|
||||
|
||||
+9
-3
@@ -31,9 +31,15 @@ func AppID(c netcontext.Context) string {
|
||||
// ../appengine.go. See that file for commentary.
|
||||
func IsStandard() bool {
|
||||
// appengineStandard will be true for first-gen runtimes (<= Go 1.9) but not
|
||||
// second-gen (>= Go 1.11). Second-gen runtimes set $GAE_ENV so we use that
|
||||
// to check if we're on a second-gen runtime.
|
||||
return appengineStandard || os.Getenv("GAE_ENV") == "standard"
|
||||
// second-gen (>= Go 1.11).
|
||||
return appengineStandard || IsSecondGen()
|
||||
}
|
||||
|
||||
// IsStandard is the implementation of the wrapper function of the same name in
|
||||
// ../appengine.go. See that file for commentary.
|
||||
func IsSecondGen() bool {
|
||||
// Second-gen runtimes set $GAE_ENV so we use that to check if we're on a second-gen runtime.
|
||||
return os.Getenv("GAE_ENV") == "standard"
|
||||
}
|
||||
|
||||
// IsFlex is the implementation of the wrapper function of the same name in
|
||||
|
||||
+1
@@ -11,5 +11,6 @@ import (
|
||||
)
|
||||
|
||||
func Main() {
|
||||
MainPath = ""
|
||||
appengine_internal.Main()
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package internal
|
||||
|
||||
// MainPath stores the file path of the main package. On App Engine Standard
|
||||
// using Go version 1.9 and below, this will be unset. On App Engine Flex and
|
||||
// App Engine Standard second-gen (Go 1.11 and above), this will be the
|
||||
// filepath to package main.
|
||||
var MainPath string
|
||||
+21
@@ -12,9 +12,12 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
MainPath = filepath.Dir(findMainPath())
|
||||
installHealthChecker(http.DefaultServeMux)
|
||||
|
||||
port := "8080"
|
||||
@@ -31,6 +34,24 @@ func Main() {
|
||||
}
|
||||
}
|
||||
|
||||
// Find the path to package main by looking at the root Caller.
|
||||
func findMainPath() string {
|
||||
pc := make([]uintptr, 100)
|
||||
n := runtime.Callers(2, pc)
|
||||
frames := runtime.CallersFrames(pc[:n])
|
||||
for {
|
||||
frame, more := frames.Next()
|
||||
// Tests won't have package main, instead they have testing.tRunner
|
||||
if frame.Function == "main.main" || frame.Function == "testing.tRunner" {
|
||||
return frame.File
|
||||
}
|
||||
if !more {
|
||||
break
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func installHealthChecker(mux *http.ServeMux) {
|
||||
// If no health check handler has been installed by this point, add a trivial one.
|
||||
const healthPath = "/_ah/health"
|
||||
|
||||
Reference in New Issue
Block a user