MCPcopy
hub / github.com/elastic/go-elasticsearch / initMetaHeader

Function initMetaHeader

elasticsearch.go:775–816  ·  view source on GitHub ↗
(transport interface{})

Source from the content-addressed store, hash-verified

773}
774
775func initMetaHeader(transport interface{}) string {
776 var b strings.Builder
777 var strippedGoVersion string
778 var strippedEsVersion string
779 var strippedTransportVersion string
780
781 strippedEsVersion = buildStrippedVersion(Version)
782 strippedGoVersion = buildStrippedVersion(runtime.Version())
783
784 if _, ok := transport.(*elastictransport.Client); ok {
785 strippedTransportVersion = buildStrippedVersion(tpversion.Transport)
786 } else {
787 strippedTransportVersion = strippedEsVersion
788 }
789
790 var duos = [][]string{
791 {
792 "es",
793 strippedEsVersion,
794 },
795 {
796 "go",
797 strippedGoVersion,
798 },
799 {
800 "t",
801 strippedTransportVersion,
802 },
803 {
804 "hc",
805 strippedGoVersion,
806 },
807 }
808
809 var arr []string
810 for _, duo := range duos {
811 arr = append(arr, strings.Join(duo, "="))
812 }
813 b.WriteString(strings.Join(arr, ","))
814
815 return b.String()
816}
817
818func buildStrippedVersion(version string) string {
819 v := reMetaVersion.FindStringSubmatch(version)

Callers 4

resolveOptionsFunction · 0.85
NewBaseClientFunction · 0.85
NewClientFunction · 0.85
NewTypedClientFunction · 0.85

Calls 4

buildStrippedVersionFunction · 0.85
JoinMethod · 0.80
VersionMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected