Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Go 1.9 issues #4156

Merged
merged 3 commits into from
Aug 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/ipfs/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ $(IPFS_BIN_$(d)): $(d) $$(DEPS_GO) ALWAYS #| $(DEPS_OO_$(d))

$(d)-install: GOFLAGS += $(cmd/ipfs_flags)
$(d)-install: $(d) $$(DEPS_GO) ALWAYS
go install $(go-flags-with-tags) ./cmd/ipfs
$(GOCC) install $(go-flags-with-tags) ./cmd/ipfs
.PHONY: $(d)-install

COVER_BIN_$(d) := $(d)/ipfs-test-cover
CLEAN += $(COVER_BIN_$(d))

$(COVER_BIN_$(d)): GOTAGS += testrunmain
$(COVER_BIN_$(d)): $(d) $$(DEPS_GO) ALWAYS
$(eval TMP_PKGS := $(shell go list -f '{{range .Deps}}{{.}} {{end}}' $(go-flags-with-tags) ./cmd/ipfs | sed 's/ /\n/g' | grep ipfs/go-ipfs | grep -v ipfs/go-ipfs/Godeps) $(call go-pkg-name,$<))
$(eval TMP_PKGS := $(shell $(GOCC) list -f '{{range .Deps}}{{.}} {{end}}' $(go-flags-with-tags) ./cmd/ipfs | sed 's/ /\n/g' | grep ipfs/go-ipfs | grep -v ipfs/go-ipfs/Godeps) $(call go-pkg-name,$<))
$(eval TMP_LIST := $(call join-with,$(comma),$(TMP_PKGS)))
@echo go test $@ -c -covermode atomic -coverpkg ... $(go-flags-with-tags) ./$(@D) # for info
@go test -o $@ -c -covermode atomic -coverpkg $(TMP_LIST) $(go-flags-with-tags) ./$(@D) 2>&1 | (grep -v 'warning: no packages being tested' || true)
@echo $(GOCC) test $@ -c -covermode atomic -coverpkg ... $(go-flags-with-tags) ./$(@D) # for info
@$(GOCC) test -o $@ -c -covermode atomic -coverpkg $(TMP_LIST) $(go-flags-with-tags) ./$(@D) 2>&1 | (grep -v 'warning: no packages being tested' || true)

include mk/footer.mk
9 changes: 8 additions & 1 deletion commands/files/serialfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ func (f *serialFile) NextFile() (File, error) {
// if a file was opened previously, close it
err := f.Close()
if err != nil {
return nil, err
switch err2 := err.(type) {
case *os.PathError:
if err2.Err != os.ErrClosed {
return nil, err
}
default:
return nil, err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seams over complicated, why not just:

if err != nil && err != os.ErrClosed {
    return nil, err
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error is wrapped within os.PathError, that wouldn't work

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, sorry didn't notice that.


// if there aren't any files left in the root directory, we're done
Expand Down
11 changes: 6 additions & 5 deletions mk/golang.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
GO_MIN_VERSION = 1.8

# pre-definitions
GOCC ?= go
GOTAGS ?=
GOFLAGS ?=
GOTFLAGS ?=
Expand All @@ -10,16 +11,16 @@ DEPS_GO :=
TEST_GO :=
CHECK_GO :=

go-pkg-name=$(shell go list $(go-tags) github.com/ipfs/go-ipfs/$(1))
go-pkg-name=$(shell $(GOCC) list $(go-tags) github.com/ipfs/go-ipfs/$(1))
go-main-name=$(notdir $(call go-pkg-name,$(1)))$(?exe)
go-curr-pkg-tgt=$(d)/$(call go-main-name,$(d))
go-pkgs-novendor=$(shell go list github.com/ipfs/go-ipfs/... | grep -v /Godeps/)
go-pkgs-novendor=$(shell $(GOCC) list github.com/ipfs/go-ipfs/... | grep -v /Godeps/)

go-tags=$(if $(GOTAGS), -tags="$(call join-with,$(space),$(GOTAGS))")
go-flags-with-tags=$(GOFLAGS)$(go-tags)

define go-build
go build -i $(go-flags-with-tags) -o "$@" "$(call go-pkg-name,$<)"
$(GOCC) build -i $(go-flags-with-tags) -o "$@" "$(call go-pkg-name,$<)"
endef

test_go_short: GOTFLAGS += -test.short
Expand All @@ -31,7 +32,7 @@ test_go_race: test_go_expensive
.PHONY: test_go_race

test_go_expensive: $$(DEPS_GO)
go test $(go-flags-with-tags) $(GOTFLAGS) ./...
$(GOCC) test $(go-flags-with-tags) $(GOTFLAGS) ./...
.PHONY: test_go_expensive
TEST_GO += test_go_expensive

Expand All @@ -41,7 +42,7 @@ test_go_fmt:
TEST_GO += test_go_fmt

test_go_megacheck:
@go get honnef.co/go/tools/cmd/megacheck
@$(GOCC) get honnef.co/go/tools/cmd/megacheck
@for pkg in $(go-pkgs-novendor); do megacheck "$$pkg"; done
.PHONY: megacheck

Expand Down
4 changes: 2 additions & 2 deletions plugin/plugins/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ $(d)_plugins_main:=$(addsuffix /main/main.go,$($(d)_plugins))
$($(d)_plugins_main): d:=$(d)
$($(d)_plugins_main):
$(d)/gen_main.sh "$(dir $@).." "$(call go-pkg-name,$(dir $@)/..)"
go fmt $@ >/dev/null
$(GOCC) fmt $@ >/dev/null

$($(d)_plugins_so): %.so : %/main/main.go
$($(d)_plugins_so): $$(DEPS_GO) ALWAYS
go build -buildmode=plugin -i -pkgdir "$(GOPATH)/pkg/linux_amd64_dynlink" $(go-flags-with-tags) -o "$@" "$(call go-pkg-name,$(basename $@))/main"
$(GOCC) build -buildmode=plugin -i -pkgdir "$(GOPATH)/pkg/linux_amd64_dynlink" $(go-flags-with-tags) -o "$@" "$(call go-pkg-name,$(basename $@))/main"
chmod +x "$@"

CLEAN += $($(d)_plugins_so)
Expand Down