|
| 1 | +// Copyright 42 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. |
| 16 | + |
| 17 | +// Package awesome is an auto-generated package for the |
| 18 | +// Awesome Foo API. |
| 19 | +// |
| 20 | +// The Awesome Foo API is really really awesome. It enables the use of Foo |
| 21 | +// with Buz and Baz to acclerate bar. |
| 22 | +// |
| 23 | +// NOTE: This package is in beta. It is not stable, and may be subject to changes. |
| 24 | +// |
| 25 | +// Use of Context |
| 26 | +// |
| 27 | +// The ctx passed to NewClient is used for authentication requests and |
| 28 | +// for creating the underlying connection, but is not used for subsequent calls. |
| 29 | +// Individual methods on the client use the ctx given to them. |
| 30 | +// |
| 31 | +// To close the open connection, use the Close() method. |
| 32 | +// |
| 33 | +// For information about setting deadlines, reusing contexts, and more |
| 34 | +// please visit godoc.org/cloud.google.com/go. |
| 35 | + |
| 36 | +package awesome // import "path/to/awesome" |
| 37 | + |
| 38 | +import ( |
| 39 | + "context" |
| 40 | + "runtime" |
| 41 | + "strings" |
| 42 | + "unicode" |
| 43 | + |
| 44 | + "google.golang.org/grpc/metadata" |
| 45 | +) |
| 46 | + |
| 47 | +const versionClient = "UNKNOWN" |
| 48 | + |
| 49 | +func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { |
| 50 | + out, _ := metadata.FromOutgoingContext(ctx) |
| 51 | + out = out.Copy() |
| 52 | + for _, md := range mds { |
| 53 | + for k, v := range md { |
| 54 | + out[k] = append(out[k], v...) |
| 55 | + } |
| 56 | + } |
| 57 | + return metadata.NewOutgoingContext(ctx, out) |
| 58 | +} |
| 59 | + |
| 60 | +// DefaultAuthScopes reports the default set of authentication scopes to use with this package. |
| 61 | +func DefaultAuthScopes() []string { |
| 62 | + return []string{ |
| 63 | + "https://foo.bar.com/auth", |
| 64 | + "https://zip.zap.com/auth", |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +// versionGo returns the Go runtime version. The returned string |
| 69 | +// has no whitespace, suitable for reporting in header. |
| 70 | +func versionGo() string { |
| 71 | + const develPrefix = "devel +" |
| 72 | + |
| 73 | + s := runtime.Version() |
| 74 | + if strings.HasPrefix(s, develPrefix) { |
| 75 | + s = s[len(develPrefix):] |
| 76 | + if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { |
| 77 | + s = s[:p] |
| 78 | + } |
| 79 | + return s |
| 80 | + } |
| 81 | + |
| 82 | + notSemverRune := func(r rune) bool { |
| 83 | + return !strings.ContainsRune("0123456789.", r) |
| 84 | + } |
| 85 | + |
| 86 | + if strings.HasPrefix(s, "go1") { |
| 87 | + s = s[2:] |
| 88 | + var prerelease string |
| 89 | + if p := strings.IndexFunc(s, notSemverRune); p >= 0 { |
| 90 | + s, prerelease = s[:p], s[p:] |
| 91 | + } |
| 92 | + if strings.HasSuffix(s, ".") { |
| 93 | + s += "0" |
| 94 | + } else if strings.Count(s, ".") < 2 { |
| 95 | + s += ".0" |
| 96 | + } |
| 97 | + if prerelease != "" { |
| 98 | + s += "-" + prerelease |
| 99 | + } |
| 100 | + return s |
| 101 | + } |
| 102 | + return "UNKNOWN" |
| 103 | +} |
| 104 | + |
0 commit comments