Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

72 Zeilen
1.7 KiB

  1. // Copyright 2016 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. // http://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. //go:generate ./update_version.sh
  15. // Package version contains version information for Google Cloud Client
  16. // Libraries for Go, as reported in request headers.
  17. package version
  18. import (
  19. "runtime"
  20. "strings"
  21. "unicode"
  22. )
  23. // Repo is the current version of the client libraries in this
  24. // repo. It should be a date in YYYYMMDD format.
  25. const Repo = "20180226"
  26. // Go returns the Go runtime version. The returned string
  27. // has no whitespace.
  28. func Go() string {
  29. return goVersion
  30. }
  31. var goVersion = goVer(runtime.Version())
  32. const develPrefix = "devel +"
  33. func goVer(s string) string {
  34. if strings.HasPrefix(s, develPrefix) {
  35. s = s[len(develPrefix):]
  36. if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 {
  37. s = s[:p]
  38. }
  39. return s
  40. }
  41. if strings.HasPrefix(s, "go1") {
  42. s = s[2:]
  43. var prerelease string
  44. if p := strings.IndexFunc(s, notSemverRune); p >= 0 {
  45. s, prerelease = s[:p], s[p:]
  46. }
  47. if strings.HasSuffix(s, ".") {
  48. s += "0"
  49. } else if strings.Count(s, ".") < 2 {
  50. s += ".0"
  51. }
  52. if prerelease != "" {
  53. s += "-" + prerelease
  54. }
  55. return s
  56. }
  57. return ""
  58. }
  59. func notSemverRune(r rune) bool {
  60. return !strings.ContainsRune("0123456789.", r)
  61. }