Commit a7ccbf29 authored by Amos Wenger's avatar Amos Wenger

Use Runtime as a value, not a pointer

parent b613e528
Pipeline #14884 failed with stage
in 5 minutes and 14 seconds
......@@ -13,6 +13,7 @@ import (
func Test_Preallocate(t *testing.T) {
assert := assert.New(t)
f, err := ioutil.TempFile("", "")
must(err)
assertSize := func(expected int64) {
s, err := f.Stat()
......
......@@ -24,7 +24,7 @@ type Runtime struct {
Is64 bool `json:"is64"`
}
type Runtimes []*Runtime
type Runtimes []Runtime
func (rs Runtimes) HasPlatform(platform Platform) bool {
for _, r := range rs {
......@@ -35,7 +35,7 @@ func (rs Runtimes) HasPlatform(platform Platform) bool {
return false
}
func (r *Runtime) String() string {
func (r Runtime) String() string {
var arch string
if r.Is64 {
arch = "64-bit"
......@@ -55,7 +55,7 @@ func (r *Runtime) String() string {
}
// OS returns the operating system in GOOS format
func (r *Runtime) OS() string {
func (r Runtime) OS() string {
switch r.Platform {
case PlatformLinux:
return "linux"
......@@ -69,20 +69,20 @@ func (r *Runtime) OS() string {
}
// Arch returns the architecture in GOARCH format
func (r *Runtime) Arch() string {
func (r Runtime) Arch() string {
if r.Is64 {
return "amd64"
}
return "386"
}
func (r *Runtime) Equals(other *Runtime) bool {
func (r Runtime) Equals(other Runtime) bool {
return r.Is64 == other.Is64 && r.Platform == other.Platform
}
var cachedRuntime *Runtime
func CurrentRuntime() *Runtime {
func CurrentRuntime() Runtime {
if cachedRuntime == nil {
var is64 = is64Bit()
var platform Platform
......@@ -102,7 +102,7 @@ func CurrentRuntime() *Runtime {
Platform: platform,
}
}
return cachedRuntime
return *cachedRuntime
}
var win64Arches = map[string]bool{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment