Skip to content

Commit

Permalink
avoid nil checks
Browse files Browse the repository at this point in the history
  • Loading branch information
myleshorton committed Aug 18, 2015
1 parent 34e978c commit 4b782e9
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/github.com/getlantern/flashlight/geolookup/geolookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,11 @@ var (
)

func GetIp() string {
c := ip.Load()
if c == nil {
return ""
}
return c.(string)
return ip.Load().(string)
}

func GetCountry() string {
c := country.Load()
if c == nil {
return ""
}
return c.(string)
return country.Load().(string)
}

// Configure configures geolookup to use the given http.Client to perform
Expand All @@ -59,6 +51,10 @@ func Configure(newClient *http.Client) {
cfgMutex.Lock()
defer cfgMutex.Unlock()

// Avoid annoying checks for nil later.
ip.Store("")
country.Store("")

client.Store(newClient)

if service == nil {
Expand Down

0 comments on commit 4b782e9

Please sign in to comment.