1
0
mirror of https://github.com/thebaer/tildes.git synced 2018-07-20 07:15:21 +00:00

Unexport unnecessary where types and functions

This commit is contained in:
Matt Baer 2015-02-17 20:48:51 -05:00
parent 8a41cc577e
commit 66c236ccb3

View File

@ -32,7 +32,7 @@ func main() {
generate(users, *outFilePtr) generate(users, *outFilePtr)
} }
type User struct { type user struct {
Name string Name string
IP string IP string
Region string Region string
@ -42,7 +42,7 @@ type User struct {
var ipRegex = regexp.MustCompile("(([0-9]{1,3}[.-]){3}[0-9]{1,3})") var ipRegex = regexp.MustCompile("(([0-9]{1,3}[.-]){3}[0-9]{1,3})")
func who() []User { func who() []user {
fmt.Println("who --ips") fmt.Println("who --ips")
cmd := exec.Command("who", "--ips") cmd := exec.Command("who", "--ips")
@ -76,10 +76,10 @@ func who() []User {
ips[newIp] = name ips[newIp] = name
} }
users := make([]User, len(ips)) users := make([]user, len(ips))
i := 0 i := 0
for ip, name := range ips { for ip, name := range ips {
users[i] = User{Name: name, IP: ip} users[i] = user{Name: name, IP: ip}
i++ i++
} }
@ -106,7 +106,7 @@ func getTimeInZone(tz string) string {
return "" return ""
} }
func getGeo(u *User) { func getGeo(u *user) {
fmt.Printf("Fetching %s location...\n", u.Name) fmt.Printf("Fetching %s location...\n", u.Name)
response, err := http.Get(fmt.Sprintf("https://freegeoip.net/json/%s", u.IP)) response, err := http.Get(fmt.Sprintf("https://freegeoip.net/json/%s", u.IP))
@ -143,13 +143,13 @@ func prettyLocation(region, country string) string {
return country return country
} }
type Page struct { type page struct {
Users []User Users []user
Updated string Updated string
UpdatedForHumans string UpdatedForHumans string
} }
func generate(users []User, outputFile string) { func generate(users []user, outputFile string) {
fmt.Println("Generating page.") fmt.Println("Generating page.")
f, err := os.Create(os.Getenv("HOME") + "/public_html/" + strings.ToLower(outputFile) + ".html") f, err := os.Create(os.Getenv("HOME") + "/public_html/" + strings.ToLower(outputFile) + ".html")
@ -175,8 +175,8 @@ func generate(users []User, outputFile string) {
updated := curTime.Format(time.RFC3339) updated := curTime.Format(time.RFC3339)
// Generate the page // Generate the page
page := &Page{Users: users, UpdatedForHumans: updatedReadable, Updated: updated} p := &page{Users: users, UpdatedForHumans: updatedReadable, Updated: updated}
template.ExecuteTemplate(w, "where", page) template.ExecuteTemplate(w, "where", p)
w.Flush() w.Flush()
fmt.Println("DONE!") fmt.Println("DONE!")