From dedc638a06a52d0a69ec79c40f2a14c1a26bb6c6 Mon Sep 17 00:00:00 2001 From: Aithal Date: Mon, 20 Feb 2017 09:34:32 -0800 Subject: [PATCH] Fix compilation errors for non linux platforms. The go get command and make both fail when executed on non-linux platforms. Modified it so that there are no compilation errors when developing in such an environment. --- Makefile | 2 +- addr_test.go | 2 ++ class_test.go | 2 ++ filter_test.go | 2 ++ handle_test.go | 2 ++ link_test.go | 2 ++ neigh_test.go | 2 ++ nl/nl_unspecified.go | 11 +++++++++++ protinfo_test.go | 2 ++ qdisc_test.go | 2 ++ route_test.go | 2 ++ route_unspecified.go | 4 ++++ rule_test.go | 2 ++ socket_test.go | 2 ++ xfrm_monitor_test.go | 2 ++ xfrm_policy_test.go | 2 ++ xfrm_state_test.go | 2 ++ 17 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 nl/nl_unspecified.go diff --git a/Makefile b/Makefile index 8dc5a92..6c8413b 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ $(call testdirs,$(DIRS)): sudo -E go test -test.parallel 4 -timeout 60s -v github.com/vishvananda/netlink/$@ $(call fmt,$(call testdirs,$(DIRS))): - ! gofmt -l $(subst fmt-,,$@)/*.go | grep '' + ! gofmt -l $(subst fmt-,,$@)/*.go | grep -q . .PHONY: fmt fmt: $(call fmt,$(call testdirs,$(DIRS))) diff --git a/addr_test.go b/addr_test.go index c834a30..685b7e2 100644 --- a/addr_test.go +++ b/addr_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/class_test.go b/class_test.go index 18a91e5..1d0c27b 100644 --- a/class_test.go +++ b/class_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/filter_test.go b/filter_test.go index 0d87256..dc4ff39 100644 --- a/filter_test.go +++ b/filter_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/handle_test.go b/handle_test.go index dbf6cc2..e7a7f86 100644 --- a/handle_test.go +++ b/handle_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/link_test.go b/link_test.go index fb548c8..cdfb959 100644 --- a/link_test.go +++ b/link_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/neigh_test.go b/neigh_test.go index 34f26a7..8ad8b32 100644 --- a/neigh_test.go +++ b/neigh_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/nl/nl_unspecified.go b/nl/nl_unspecified.go new file mode 100644 index 0000000..dfc0be6 --- /dev/null +++ b/nl/nl_unspecified.go @@ -0,0 +1,11 @@ +// +build !linux + +package nl + +import "encoding/binary" + +var SupportedNlFamilies = []int{} + +func NativeEndian() binary.ByteOrder { + return nil +} diff --git a/protinfo_test.go b/protinfo_test.go index f94c42b..8826cd9 100644 --- a/protinfo_test.go +++ b/protinfo_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import "testing" diff --git a/qdisc_test.go b/qdisc_test.go index 6e1772f..dff58f9 100644 --- a/qdisc_test.go +++ b/qdisc_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/route_test.go b/route_test.go index 01906f3..a6d10fc 100644 --- a/route_test.go +++ b/route_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/route_unspecified.go b/route_unspecified.go index 1b20530..2701862 100644 --- a/route_unspecified.go +++ b/route_unspecified.go @@ -5,3 +5,7 @@ package netlink func (r *Route) ListFlags() []string { return []string{} } + +func (n *NexthopInfo) ListFlags() []string { + return []string{} +} diff --git a/rule_test.go b/rule_test.go index e4db0ce..7844877 100644 --- a/rule_test.go +++ b/rule_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/socket_test.go b/socket_test.go index 70fd440..95527af 100644 --- a/socket_test.go +++ b/socket_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/xfrm_monitor_test.go b/xfrm_monitor_test.go index 15ac206..74d3d81 100644 --- a/xfrm_monitor_test.go +++ b/xfrm_monitor_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/xfrm_policy_test.go b/xfrm_policy_test.go index f7d661b..5b88421 100644 --- a/xfrm_policy_test.go +++ b/xfrm_policy_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import ( diff --git a/xfrm_state_test.go b/xfrm_state_test.go index 7f58e53..ec5dfb6 100644 --- a/xfrm_state_test.go +++ b/xfrm_state_test.go @@ -1,3 +1,5 @@ +// +build linux + package netlink import (