Skip to content

Commit

Permalink
additional mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
cjimti committed Aug 25, 2019
1 parent 4482b2f commit 01dac41
Show file tree
Hide file tree
Showing 135 changed files with 42 additions and 22,051 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![txeh - /etc/hosts mangement](txeh.png)
![txeh - /etc/hosts mangement](logo.png)


# Etc Hosts Management Utility & Go Library
Expand Down
10 changes: 0 additions & 10 deletions glide.lock

This file was deleted.

4 changes: 0 additions & 4 deletions glide.yaml

This file was deleted.

6 changes: 1 addition & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@ module github.com/txn2/txeh

go 1.12

require (
github.com/inconshreveable/mousetrap v1.0.0
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v0.0.0-20181223182923-24fa6976df40
)
require github.com/spf13/cobra v0.0.5
37 changes: 31 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/pflag v0.0.0-20181223182923-24fa6976df40 h1:+fBLXG9122bARNDiwUt7b1hnca/mLnUxXlH7ChuFKPQ=
github.com/spf13/pflag v0.0.0-20181223182923-24fa6976df40/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/txn2/txeh v1.1.0 h1:VqsufAE1HTHYAxsTU5Ut7bEXpFJ8P0SUTeDd349wD/Y=
github.com/txn2/txeh v1.1.0/go.mod h1:nursimZu+KRNot5XhbDImDMvu5OYN60/XUfUJ6WJcN8=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
File renamed without changes
11 changes: 9 additions & 2 deletions hosts.go → txeh.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ func (h *Hosts) Save() error {
func (h *Hosts) SaveAs(fileName string) error {
hfData := []byte(h.RenderHostsFile())

h.Lock()
defer h.Unlock()

err := ioutil.WriteFile(fileName, hfData, 0644)
if err != nil {
return err
Expand All @@ -102,14 +105,15 @@ func (h *Hosts) SaveAs(fileName string) error {

// Reload hosts file
func (h *Hosts) Reload() error {
h.Lock()
defer h.Unlock()

hfl, err := ParseHosts(h.ReadFilePath)
if err != nil {
return err
}

h.Lock()
h.hostFileLines = hfl
h.Unlock()

return nil
}
Expand Down Expand Up @@ -278,6 +282,9 @@ func (h *Hosts) RenderHostsFile() string {

// GetHostFileLines
func (h *Hosts) GetHostFileLines() *HostFileLines {
h.Lock()
defer h.Unlock()

return &h.hostFileLines
}

Expand Down
13 changes: 0 additions & 13 deletions vendor/github.com/inconshreveable/mousetrap/LICENSE

This file was deleted.

23 changes: 0 additions & 23 deletions vendor/github.com/inconshreveable/mousetrap/README.md

This file was deleted.

15 changes: 0 additions & 15 deletions vendor/github.com/inconshreveable/mousetrap/trap_others.go

This file was deleted.

98 changes: 0 additions & 98 deletions vendor/github.com/inconshreveable/mousetrap/trap_windows.go

This file was deleted.

46 changes: 0 additions & 46 deletions vendor/github.com/inconshreveable/mousetrap/trap_windows_1.4.go

This file was deleted.

38 changes: 0 additions & 38 deletions vendor/github.com/spf13/cobra/.circleci/config.yml

This file was deleted.

36 changes: 0 additions & 36 deletions vendor/github.com/spf13/cobra/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions vendor/github.com/spf13/cobra/.mailmap

This file was deleted.

Loading

0 comments on commit 01dac41

Please sign in to comment.