1 // Copyright 2016 Google LLC
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 //go:generate ./update_version.sh
17 // Package version contains version information for Google Cloud Client
18 // Libraries for Go, as reported in request headers.
27 // Repo is the current version of the client libraries in this
28 // repo. It should be a date in YYYYMMDD format.
29 const Repo = "20180226"
31 // Go returns the Go runtime version. The returned string
37 var goVersion = goVer(runtime.Version())
39 const develPrefix = "devel +"
41 func goVer(s string) string {
42 if strings.HasPrefix(s, develPrefix) {
43 s = s[len(develPrefix):]
44 if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 {
50 if strings.HasPrefix(s, "go1") {
53 if p := strings.IndexFunc(s, notSemverRune); p >= 0 {
54 s, prerelease = s[:p], s[p:]
56 if strings.HasSuffix(s, ".") {
58 } else if strings.Count(s, ".") < 2 {
69 func notSemverRune(r rune) bool {
70 return !strings.ContainsRune("0123456789.", r)