This repository has been archived by the owner on Sep 16, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from tamada/introduce_docker
Introduce docker
- Loading branch information
Showing
15 changed files
with
591 additions
and
356 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM alpine:3.10.1 | ||
ARG version="1.1.0" | ||
LABEL maintainer="Haruai Tamada" \ | ||
uniq2-version="1.0.2" \ | ||
description="Deleting duplicate lines" | ||
|
||
RUN adduser -D uniq2 \ | ||
&& apk --no-cache add curl=7.66.0-r0 tar=1.32-r0 \ | ||
&& curl -s -L -O https://github.com/tamada/uniq2/releases/download/v${version}/uniq2-${version}_linux_amd64.tar.gz \ | ||
&& tar xfz uniq2-${version}_linux_amd64.tar.gz \ | ||
&& mv uniq2-${version} /opt \ | ||
&& ln -s /opt/uniq2-${version} /opt/uniq2 \ | ||
&& ln -s /opt/uniq2/uniq2 /usr/local/bin/uniq2 \ | ||
&& rm uniq2-${version}_linux_amd64.tar.gz | ||
|
||
ENV HOME="home/uniq2" | ||
|
||
WORKDIR /home/uniq2 | ||
USER uniq2 | ||
|
||
ENTRYPOINT [ "uniq2" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package uniq2 | ||
|
||
/* | ||
AdjacentUniqer is an implementation of uniqer for adjacent lines. | ||
*/ | ||
type AdjacentUniqer struct { | ||
prev string | ||
firstLine bool | ||
} | ||
|
||
/* | ||
NewAdjacentUniqer creates an instance of AdjacentUniqer. | ||
*/ | ||
func NewAdjacentUniqer() *AdjacentUniqer { | ||
return &AdjacentUniqer{prev: "", firstLine: true} | ||
} | ||
|
||
/* | ||
StreamLine tries to remove the duplicated line. | ||
*/ | ||
func (au *AdjacentUniqer) StreamLine(line string) bool { | ||
if au.firstLine { | ||
au.prev = line | ||
au.firstLine = false | ||
return true | ||
} | ||
if au.prev == line { | ||
return false | ||
} | ||
au.prev = line | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
func Example_uniq2() { | ||
goMain([]string{"uniq2", "-i", "../../testdata/test1.txt"}) | ||
// Output: | ||
// a1 | ||
// a2 | ||
// a3 | ||
// a4 | ||
} | ||
|
||
func Example_printHelp() { | ||
goMain([]string{"uniq2", "--help"}) | ||
// Output: | ||
// 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. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.