From f938cc85fc9c789392594fe3a2999209c4021d54 Mon Sep 17 00:00:00 2001 From: Michael Leow Date: Mon, 17 Jun 2019 22:27:59 +0800 Subject: [PATCH] Summary: Minor bugfix + crosscompile binary --- .gitignore | 3 +++ Makefile | 17 ++++++++++++++++- dist/README.md | 5 +++++ internal/hansard/pdf.go | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 dist/README.md diff --git a/.gitignore b/.gitignore index 379eab5..931f15b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ # Ignore binary go-pardocs +# Ignore dist binary +dist/* + # Ignore direnv .envrc* diff --git a/Makefile b/Makefile index 4858e01..397d361 100644 --- a/Makefile +++ b/Makefile @@ -5,4 +5,19 @@ build: @go build ./cmd/go-pardocs test: - @go test . + @go test ./... + +# https://vic.demuzere.be/articles/golang-makefile-crosscompile/ +PLATFORMS := linux/amd64 windows/amd64 darwin/amd64 + +temp = $(subst /, ,$@) +os = $(word 1, $(temp)) +arch = $(word 2, $(temp)) + +release: $(PLATFORMS) + +$(PLATFORMS): + @mkdir -p dist/$(os)-$(arch) + @GOOS=$(os) GOARCH=$(arch) go build -o './dist/$(os)-$(arch)/go-pardocs' ./cmd/go-pardocs + +.PHONY release: $(PLATFORMS) diff --git a/dist/README.md b/dist/README.md new file mode 100644 index 0000000..844a102 --- /dev/null +++ b/dist/README.md @@ -0,0 +1,5 @@ +# Platform specific binaries + +- Genetrated by ```make release``` +- Cross-compile binary for release + diff --git a/internal/hansard/pdf.go b/internal/hansard/pdf.go index 2ea3e72..e8b65c6 100644 --- a/internal/hansard/pdf.go +++ b/internal/hansard/pdf.go @@ -38,7 +38,7 @@ func NewPDFDoc(sourcePath string) (*PDFDocument, error) { exerr := pdfDoc.extractPDF() if exerr != nil { - panic(exerr) + return nil, exerr } return &pdfDoc, nil