From 52c0d35f398288aa82f98d8fee9fd152a11fdf8e Mon Sep 17 00:00:00 2001 From: Haruaki Tamada Date: Sun, 8 Mar 2020 10:57:53 +0900 Subject: [PATCH 1/4] introduce dist target for creating distribution files for each platform --- Makefile | 36 +++++++++++++---------- docs/content/_index.md | 26 +++++++++++++++- docs/layouts/partials/blog-post-list.html | 4 ++- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 7da4cf8..5e3487c 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,11 @@ GO=go NAME := uniq2 -VERSION := 1.0.0 -REVISION := $(shell git rev-parse --short HEAD) -LDFLAGS := -X 'main.version=$(VERSION)' - -X 'main.revision=$(REVISION)' +VERSION := 1.0.1 +DIST := $(NAME)-$(VERSION) all: test build -deps: - $(GO) get golang.org/x/lint/golint - $(GO) get golang.org/x/tools/cmd/goimports - $(GO) get github.com/golang/dep/cmd/dep - - $(GO) get golang.org/x/tools/cmd/cover - $(GO) get github.com/mattn/goveralls - - dep ensure -vendor-only - -setup: deps update_version +setup: update_version git submodule update --init update_version: @@ -31,8 +19,24 @@ update_version: test: setup $(GO) test -covermode=count -coverprofile=coverage.out $$(go list ./... | grep -v vendor) +# refer from https://pod.hatenablog.com/entry/2017/06/13/150342 +define _createDist + mkdir -p dist/$(1)_$(2)/$(DIST) + GOOS=$1 GOARCH=$2 go build -o dist/$(1)_$(2)/$(DIST)/$(NAME)$(3) cmd/$(NAME)/main.go + cp -r README.md LICENSE dist/$(1)_$(2)/$(DIST) + tar cfz dist/$(DIST)_$(1)_$(2).tar.gz -C dist/$(1)_$(2) $(DIST) +endef + +dist: build + @$(call _createDist,darwin,amd64,) + @$(call _createDist,darwin,386,) + @$(call _createDist,windows,amd64,.exe) + @$(call _createDist,windows,386,.exe) + @$(call _createDist,linux,amd64,) + @$(call _createDist,linux,386,) + build: setup - cd cmd/uniq2; $(GO) build -o $(NAME) -v + $(GO) build -o $(NAME) -v cmd/$(NAME)/main.go clean: $(GO) clean diff --git a/docs/content/_index.md b/docs/content/_index.md index 5aacdc2..a7b3483 100644 --- a/docs/content/_index.md +++ b/docs/content/_index.md @@ -19,7 +19,16 @@ When deleting not continuous duplicate lines, we use `sort` command together, in We want to delete not continuous duplicated lines with remaining the order. -## Install +### Install by Homebrew + +Simply type the following commands. + +```sh +$ brew tap tamada/brew +$ brew install uniq2 +``` + +### Install by Go Simply type the following command. @@ -27,6 +36,21 @@ Simply type the following command. $ go get github.com/tamada/uniq2 ``` +## Usage + +``` +uniq2 [OPTIONS] [INPUT [OUTPUT]] +OPTIONS + -a, --adjacent delete only adjacent duplicated lines. + -d, --delete-lines only prints deleted lines. + -i, --ignore-case case sensitive. + -h, --help print this message. + +INPUT gives file name of input. If argument is single dash ('-') + or absent, the program read strings from stdin. +OUTPUT represents the destination. +``` + ## License [WTFPL](https://github.com/tamada/uniq2/blob/master/LICENSE) diff --git a/docs/layouts/partials/blog-post-list.html b/docs/layouts/partials/blog-post-list.html index c53c7ff..aa34277 100644 --- a/docs/layouts/partials/blog-post-list.html +++ b/docs/layouts/partials/blog-post-list.html @@ -3,7 +3,8 @@

{{ .Title }}

{{ .Content }} + From b2c93257d583c2d47943cc5b763532c694332fee Mon Sep 17 00:00:00 2001 From: Haruaki Tamada Date: Sun, 8 Mar 2020 10:59:30 +0900 Subject: [PATCH 2/4] change using dependency management dep to go mod. --- .gitignore | 7 +++---- Gopkg.lock | 17 ----------------- Gopkg.toml | 34 ---------------------------------- go.mod | 5 +++++ go.sum | 2 ++ 5 files changed, 10 insertions(+), 55 deletions(-) delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml create mode 100644 go.mod create mode 100644 go.sum diff --git a/.gitignore b/.gitignore index 68ff8e4..484d3f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ -vendor uniq2 -### https://raw.github.com/github/gitignore/5c5a1b536b6f9bf11515518f03d58addaf29f681/Go.gitignore +### https://raw.github.com/github/gitignore/599646e9d0a26283d67715dead8f26e0eb2df753/Go.gitignore # Binaries for programs and plugins *.exe @@ -20,7 +19,7 @@ uniq2 # vendor/ -### https://raw.github.com/github/gitignore/5c5a1b536b6f9bf11515518f03d58addaf29f681/Global/Emacs.gitignore +### https://raw.github.com/github/gitignore/599646e9d0a26283d67715dead8f26e0eb2df753/Global/Emacs.gitignore # -*- mode: gitignore; -*- *~ @@ -73,7 +72,7 @@ flycheck_*.el -### https://raw.github.com/github/gitignore/5c5a1b536b6f9bf11515518f03d58addaf29f681/Global/macOS.gitignore +### https://raw.github.com/github/gitignore/599646e9d0a26283d67715dead8f26e0eb2df753/Global/macOS.gitignore # General .DS_Store diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index 84420c2..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,17 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - digest = "1:8fd3a15613c7e70cceff3aa03dd57560dba87c4868864e397d5eb2f14addd3f5" - name = "github.com/ogier/pflag" - packages = ["."] - pruneopts = "UT" - revision = "32a05c62658bd1d7c7e75cbc8195de5d585fde0f" - version = "v0.0.1" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - input-imports = ["github.com/ogier/pflag"] - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index dc24a89..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,34 +0,0 @@ -# Gopkg.toml example -# -# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html -# for detailed Gopkg.toml documentation. -# -# required = ["github.com/user/thing/cmd/thing"] -# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] -# -# [[constraint]] -# name = "github.com/user/project" -# version = "1.0.0" -# -# [[constraint]] -# name = "github.com/user/project2" -# branch = "dev" -# source = "github.com/myfork/project2" -# -# [[override]] -# name = "github.com/x/y" -# version = "2.4.0" -# -# [prune] -# non-go = false -# go-tests = true -# unused-packages = true - - -[[constraint]] - name = "github.com/ogier/pflag" - version = "0.0.1" - -[prune] - go-tests = true - unused-packages = true diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..0c833ed --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/tamada/uniq2 + +go 1.14 + +require github.com/ogier/pflag v0.0.1 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..d273608 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/ogier/pflag v0.0.1 h1:RW6JSWSu/RkSatfcLtogGfFgpim5p7ARQ10ECk5O750= +github.com/ogier/pflag v0.0.1/go.mod h1:zkFki7tvTa0tafRvTBIZTvzYyAu6kQhPZFnshFFPE+g= From d3f3aacc2a3716a6b703df0df9fa3a95803e2a5f Mon Sep 17 00:00:00 2001 From: Haruaki Tamada Date: Sun, 8 Mar 2020 11:01:43 +0900 Subject: [PATCH 3/4] introduce github workflow instead of travis CI for conducting unit tests in Windows platform. --- .github/workflows/build.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..6ace4b1 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,35 @@ +name: build +on: + push: + branches: + - "**" +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + - macOS-latest + - windows-latest + steps: + - name: setup go + uses: actions/setup-go@v1 + with: + go-version: 1.14 + - name: checkout + uses: actions/checkout@v1 + - name: build + run: make + - name: Convert coverage to lcov + uses: jandelgado/gcov2lcov-action@v1.0.0 + with: + infile: coverage.out + outfile: coverage.lcov + if: "matrix.os == 'ubuntu-latest'" + - name: coveralls + uses: coverallsapp/github-action@v1.0.1 + with: + github-token: ${{ secrets.github_token }} + path-to-lcov: coverage.lcov + if: "matrix.os == 'ubuntu-latest'" From 743260cea5ec431e22055478b1a53d22c32998cf Mon Sep 17 00:00:00 2001 From: Haruaki Tamada Date: Sun, 8 Mar 2020 11:08:58 +0900 Subject: [PATCH 4/4] update version to 1.0.2 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 83bc117..e0fb718 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ GO=go NAME := uniq2 -VERSION := 1.0.1 +VERSION := 1.0.2 DIST := $(NAME)-$(VERSION) all: test build