header.go 656 B

12345678910111213141516171819202122
  1. // Copyright 2017 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package gensupport
  5. import (
  6. "fmt"
  7. "runtime"
  8. "strings"
  9. )
  10. // GoogleClientHeader returns the value to use for the x-goog-api-client
  11. // header, which is used internally by Google.
  12. func GoogleClientHeader(generatorVersion, clientElement string) string {
  13. elts := []string{"gl-go/" + strings.Replace(runtime.Version(), " ", "_", -1)}
  14. if clientElement != "" {
  15. elts = append(elts, clientElement)
  16. }
  17. elts = append(elts, fmt.Sprintf("gdcl/%s", generatorVersion))
  18. return strings.Join(elts, " ")
  19. }