From ee5400dc9f2b0d788bf92c3948b3a7d460be2bad Mon Sep 17 00:00:00 2001 From: Noah Zoschke Date: Fri, 26 Jan 2018 09:35:38 -0800 Subject: [PATCH] dont export types (golint) --- examples/json/json.go | 10 +++++----- .../sorting-by-functions/sorting-by-functions.go | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/json/json.go b/examples/json/json.go index b3853f2..475ffe5 100644 --- a/examples/json/json.go +++ b/examples/json/json.go @@ -10,11 +10,11 @@ import "os" // We'll use these two structs to demonstrate encoding and // decoding of custom types below. -type Response1 struct { +type response1 struct { Page int Fruits []string } -type Response2 struct { +type response2 struct { Page int `json:"page"` Fruits []string `json:"fruits"` } @@ -50,7 +50,7 @@ func main() { // custom data types. It will only include exported // fields in the encoded output and will by default // use those names as the JSON keys. - res1D := &Response1{ + res1D := &response1{ Page: 1, Fruits: []string{"apple", "peach", "pear"}} res1B, _ := json.Marshal(res1D) @@ -60,7 +60,7 @@ func main() { // to customize the encoded JSON key names. Check the // definition of `Response2` above to see an example // of such tags. - res2D := &Response2{ + res2D := &response2{ Page: 1, Fruits: []string{"apple", "peach", "pear"}} res2B, _ := json.Marshal(res2D) @@ -103,7 +103,7 @@ func main() { // need for type assertions when accessing the decoded // data. str := `{"page": 1, "fruits": ["apple", "peach"]}` - res := Response2{} + res := response2{} json.Unmarshal([]byte(str), &res) fmt.Println(res) fmt.Println(res.Fruits[0]) diff --git a/examples/sorting-by-functions/sorting-by-functions.go b/examples/sorting-by-functions/sorting-by-functions.go index 3564da9..f68c298 100644 --- a/examples/sorting-by-functions/sorting-by-functions.go +++ b/examples/sorting-by-functions/sorting-by-functions.go @@ -13,7 +13,7 @@ import "fmt" // corresponding type. Here we've created a `ByLength` // type that is just an alias for the builtin `[]string` // type. -type ByLength []string +type byLength []string // We implement `sort.Interface` - `Len`, `Less`, and // `Swap` - on our type so we can use the `sort` package's @@ -22,22 +22,22 @@ type ByLength []string // hold the actual custom sorting logic. In our case we // want to sort in order of increasing string length, so // we use `len(s[i])` and `len(s[j])` here. -func (s ByLength) Len() int { +func (s byLength) Len() int { return len(s) } -func (s ByLength) Swap(i, j int) { +func (s byLength) Swap(i, j int) { s[i], s[j] = s[j], s[i] } -func (s ByLength) Less(i, j int) bool { +func (s byLength) Less(i, j int) bool { return len(s[i]) < len(s[j]) } // With all of this in place, we can now implement our // custom sort by casting the original `fruits` slice to -// `ByLength`, and then use `sort.Sort` on that typed +// `byLength`, and then use `sort.Sort` on that typed // slice. func main() { fruits := []string{"peach", "banana", "kiwi"} - sort.Sort(ByLength(fruits)) + sort.Sort(byLength(fruits)) fmt.Println(fruits) }