From 11486e81433005767f9495f9ca71f2ee22dcead5 Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Tue, 20 Jun 2023 15:58:52 -0700 Subject: [PATCH] Remove code needed for Go versions below 1.18 (#1201) --- .../internal/buildinfo/buildinfo-prev.go | 52 ------------------- .../{buildinfo-1.18.go => buildinfo.go} | 3 -- 2 files changed, 55 deletions(-) delete mode 100644 server/registry/internal/buildinfo/buildinfo-prev.go rename server/registry/internal/buildinfo/{buildinfo-1.18.go => buildinfo.go} (97%) diff --git a/server/registry/internal/buildinfo/buildinfo-prev.go b/server/registry/internal/buildinfo/buildinfo-prev.go deleted file mode 100644 index fbdd47813..000000000 --- a/server/registry/internal/buildinfo/buildinfo-prev.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2022 Google LLC. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//go:build !go1.18 -// +build !go1.18 - -package buildinfo - -import ( - "runtime/debug" - - "github.com/apigee/registry/rpc" -) - -func module(m *debug.Module) *rpc.BuildInfo_Module { - if m == nil { - return nil - } - return &rpc.BuildInfo_Module{ - Path: m.Path, - Version: m.Version, - Sum: m.Sum, - Replacement: module(m.Replace), - } -} - -func BuildInfo() *rpc.BuildInfo { - info, ok := debug.ReadBuildInfo() - if !ok { - return nil - } - dependencies := make([]*rpc.BuildInfo_Module, 0) - for _, dep := range info.Deps { - dependencies = append(dependencies, module(dep)) - } - return &rpc.BuildInfo{ - Path: info.Path, - Main: module(&info.Main), - Dependencies: dependencies, - } -} diff --git a/server/registry/internal/buildinfo/buildinfo-1.18.go b/server/registry/internal/buildinfo/buildinfo.go similarity index 97% rename from server/registry/internal/buildinfo/buildinfo-1.18.go rename to server/registry/internal/buildinfo/buildinfo.go index 7abc105a6..ff2168e41 100644 --- a/server/registry/internal/buildinfo/buildinfo-1.18.go +++ b/server/registry/internal/buildinfo/buildinfo.go @@ -12,9 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build go1.18 -// +build go1.18 - package buildinfo import (