From cb80baf5909aa01c73596d34fa1902ace3293dd8 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Thu, 15 Mar 2018 19:58:19 -0400 Subject: [PATCH] Add darwin amd64 build tags The darwin provider was written and tested for amd64. This adds build tags to match those assumptions about the code. This will ensure that the provider is not register on other darwin architectures. But in my experience only darwin/amd64 is really ever used. macOS doesn't even support 32-bit anymore --- providers/darwin/{arch_darwin.go => arch_darwin_amd64.go} | 0 .../darwin/{boottime_darwin.go => boottime_darwin_amd64.go} | 4 +++- providers/darwin/{host_darwin.go => host_darwin_amd64.go} | 2 ++ providers/darwin/{kernel_darwin.go => kernel_darwin_amd64.go} | 0 providers/darwin/{memory_darwin.go => memory_darwin_amd64.go} | 2 ++ .../darwin/{process_darwin.go => process_darwin_amd64.go} | 2 ++ .../{process_darwin_test.go => process_darwin_amd64_test.go} | 2 ++ .../darwin/{syscall_darwin.go => syscall_darwin_amd64.go} | 2 ++ 8 files changed, 13 insertions(+), 1 deletion(-) rename providers/darwin/{arch_darwin.go => arch_darwin_amd64.go} (100%) rename providers/darwin/{boottime_darwin.go => boottime_darwin_amd64.go} (94%) rename providers/darwin/{host_darwin.go => host_darwin_amd64.go} (98%) rename providers/darwin/{kernel_darwin.go => kernel_darwin_amd64.go} (100%) rename providers/darwin/{memory_darwin.go => memory_darwin_amd64.go} (96%) rename providers/darwin/{process_darwin.go => process_darwin_amd64.go} (99%) rename providers/darwin/{process_darwin_test.go => process_darwin_amd64_test.go} (97%) rename providers/darwin/{syscall_darwin.go => syscall_darwin_amd64.go} (99%) diff --git a/providers/darwin/arch_darwin.go b/providers/darwin/arch_darwin_amd64.go similarity index 100% rename from providers/darwin/arch_darwin.go rename to providers/darwin/arch_darwin_amd64.go diff --git a/providers/darwin/boottime_darwin.go b/providers/darwin/boottime_darwin_amd64.go similarity index 94% rename from providers/darwin/boottime_darwin.go rename to providers/darwin/boottime_darwin_amd64.go index 141ae06a..fb276bb2 100644 --- a/providers/darwin/boottime_darwin.go +++ b/providers/darwin/boottime_darwin_amd64.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build darwin,amd64,cgo + package darwin import ( @@ -24,7 +26,7 @@ import ( const kernBoottimeMIB = "kern.boottime" func BootTime() (time.Time, error) { - var tv syscall.Timeval32 + var tv syscall.Timeval if err := sysctlByName(kernBoottimeMIB, &tv); err != nil { return time.Time{}, errors.Wrap(err, "failed to get host uptime") } diff --git a/providers/darwin/host_darwin.go b/providers/darwin/host_darwin_amd64.go similarity index 98% rename from providers/darwin/host_darwin.go rename to providers/darwin/host_darwin_amd64.go index 98260971..9f8a3c47 100644 --- a/providers/darwin/host_darwin.go +++ b/providers/darwin/host_darwin_amd64.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build darwin,amd64,cgo + package darwin import ( diff --git a/providers/darwin/kernel_darwin.go b/providers/darwin/kernel_darwin_amd64.go similarity index 100% rename from providers/darwin/kernel_darwin.go rename to providers/darwin/kernel_darwin_amd64.go diff --git a/providers/darwin/memory_darwin.go b/providers/darwin/memory_darwin_amd64.go similarity index 96% rename from providers/darwin/memory_darwin.go rename to providers/darwin/memory_darwin_amd64.go index 307f637c..6fa8d1e7 100644 --- a/providers/darwin/memory_darwin.go +++ b/providers/darwin/memory_darwin_amd64.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build darwin,amd64,cgo + package darwin import ( diff --git a/providers/darwin/process_darwin.go b/providers/darwin/process_darwin_amd64.go similarity index 99% rename from providers/darwin/process_darwin.go rename to providers/darwin/process_darwin_amd64.go index 31bc1784..7f630bed 100644 --- a/providers/darwin/process_darwin.go +++ b/providers/darwin/process_darwin_amd64.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build darwin,amd64,cgo + package darwin // #cgo LDFLAGS:-lproc diff --git a/providers/darwin/process_darwin_test.go b/providers/darwin/process_darwin_amd64_test.go similarity index 97% rename from providers/darwin/process_darwin_test.go rename to providers/darwin/process_darwin_amd64_test.go index aa320e0c..70ed45c4 100644 --- a/providers/darwin/process_darwin_test.go +++ b/providers/darwin/process_darwin_amd64_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build darwin,amd64,cgo + package darwin import ( diff --git a/providers/darwin/syscall_darwin.go b/providers/darwin/syscall_darwin_amd64.go similarity index 99% rename from providers/darwin/syscall_darwin.go rename to providers/darwin/syscall_darwin_amd64.go index 42fa1eb7..991ca3c1 100644 --- a/providers/darwin/syscall_darwin.go +++ b/providers/darwin/syscall_darwin_amd64.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build darwin,amd64,cgo + package darwin // #cgo LDFLAGS:-lproc