Skip to content

Commit 3446338

Browse files
authored
Merge pull request #23 from txn2/add-support-for-go-install
Add support for go install
2 parents 6a28df2 + f9fd663 commit 3446338

File tree

16 files changed

+71
-38
lines changed

16 files changed

+71
-38
lines changed

.goreleaser.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ builds:
33
- id: txeh
44
# Path to main.go file.
55
# Default is `main.go`
6-
main: ./util/txeh.go
6+
main: ./txeh/txeh.go
77
binary: txeh
88

99
env:
@@ -29,7 +29,7 @@ builds:
2929
- "6"
3030
- "7"
3131

32-
ldflags: "-s -w -X github.com/txn2/txeh/util/cmd.Version={{.Version}}"
32+
ldflags: "-s -w -X github.com/txn2/txeh/txeh/cmd.Version={{.Version}}"
3333

3434
checksum:
3535
name_template: '{{ .ProjectName }}_checksums.txt'
@@ -91,4 +91,4 @@ snapcrafts:
9191
description: |
9292
Kubernetes bulk port forwarding utility.
9393
grade: stable
94-
confinement: classic
94+
confinement: classic

README.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,21 @@ A computer's [/etc/hosts] file is a powerful utility for developers and system a
1919

2020
MacOS [homebrew](https://brew.sh) users can `brew install txn2/tap/txeh`, otherwise see [releases](https://github.com/txn2/txeh/releases) for packages and binaries for a number of distros and architectures including Windows, Linux and Arm based systems.
2121

22-
Complie and run from source (dependencies are vendored):
22+
#### Install with go install
23+
24+
When installing with Go please use the latest stable Go release. At least go1.16 or greater is required.
25+
26+
To install use: `go install github.com/txn2/txeh/txeh@master`
27+
28+
If you are building from a local source clone, use `go install ./txeh` from the top-level directory of the clone.
29+
30+
go install will typically put the txeh binary inside the bin directory under go env GOPATH, see Go’s [Compile and install packages and dependencies](https://golang.org/cmd/go/#hdr-Compile_and_install_packages_and_dependencies) for more on this. You may need to add that directory to your $PATH if you encounter the error `txeh: command not found` after installation, you can find a guide for adding a directory to your PATH at https://gist.github.com/nex3/c395b2f8fd4b02068be37c961301caa7#file-path-md.
31+
32+
#### Compile and run from source
33+
34+
dependencies are vendored:
2335
```
24-
go run ./util/txeh.go
36+
go run ./txeh/txeh.go
2537
```
2638

2739
### Use
@@ -69,7 +81,7 @@ sudo txeh add 127.0.0.1 test test.two
6981
# remove the hostname "test"
7082
sudo txeh remove host test
7183
72-
# remove multiple hostnames
84+
# remove multiple hostnames
7385
sudo txeh remove host test test2 test.two
7486
7587
# remove an IP address and all the hosts that point to it
@@ -129,27 +141,27 @@ func main() {
129141
hosts.AddHost("127.100.100.100", "test")
130142
hosts.AddHost("127.100.100.101", "logstash")
131143
hosts.AddHosts("127.100.100.102", []string{"a", "b", "c"})
132-
144+
133145
hosts.RemoveHosts([]string{"example", "example.machine", "example.machine.example.com"})
134146
hosts.RemoveHosts(strings.Fields("example2 example.machine2 example.machine.example.com2"))
135147
136-
148+
137149
hosts.RemoveAddress("127.1.27.1")
138-
150+
139151
removeList := []string{
140152
"127.1.27.15",
141153
"127.1.27.14",
142154
"127.1.27.13",
143155
}
144-
156+
145157
hosts.RemoveAddresses(removeList)
146-
158+
147159
hfData := hosts.RenderHostsFile()
148160
149161
// if you like to see what the outcome will
150162
// look like
151163
fmt.Println(hfData)
152-
164+
153165
hosts.Save()
154166
// or hosts.SaveAs("./test.hosts")
155167
}
@@ -160,12 +172,12 @@ func main() {
160172
161173
Build test release:
162174
```bash
163-
goreleaser --skip-publish --rm-dist --skip-validate
175+
goreleaser --skip-publish --clean --skip-validate
164176
```
165177
166178
Build and release:
167179
```bash
168-
GITHUB_TOKEN=$GITHUB_TOKEN goreleaser --rm-dist
180+
GITHUB_TOKEN=$GITHUB_TOKEN goreleaser --clean
169181
```
170182
171183
### License
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)