mirror of
https://github.com/golang/go
synced 2024-11-23 19:50:06 -07:00
doc/progs: gofmt -w
R=r, gri, r CC=golang-dev https://golang.org/cl/4662085
This commit is contained in:
parent
e86d727e60
commit
ab3365d34e
@ -36,28 +36,24 @@ func (p IntSlice) Len() int { return len(p) }
|
||||
func (p IntSlice) Less(i, j int) bool { return p[i] < p[j] }
|
||||
func (p IntSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
|
||||
|
||||
type Float64Slice []float64
|
||||
|
||||
func (p Float64Slice) Len() int { return len(p) }
|
||||
func (p Float64Slice) Less(i, j int) bool { return p[i] < p[j] }
|
||||
func (p Float64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
|
||||
|
||||
type StringSlice []string
|
||||
|
||||
func (p StringSlice) Len() int { return len(p) }
|
||||
func (p StringSlice) Less(i, j int) bool { return p[i] < p[j] }
|
||||
func (p StringSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
|
||||
|
||||
|
||||
// Convenience wrappers for common cases
|
||||
|
||||
func SortInts(a []int) { Sort(IntSlice(a)) }
|
||||
func SortFloat64s(a []float64) { Sort(Float64Slice(a)) }
|
||||
func SortStrings(a []string) { Sort(StringSlice(a)) }
|
||||
|
||||
|
||||
func IntsAreSorted(a []int) bool { return IsSorted(IntSlice(a)) }
|
||||
func Float64sAreSorted(a []float64) bool { return IsSorted(Float64Slice(a)) }
|
||||
func StringsAreSorted(a []string) bool { return IsSorted(StringSlice(a)) }
|
||||
|
@ -8,7 +8,9 @@ import "os"
|
||||
|
||||
func main() {
|
||||
s := "hello"
|
||||
if s[1] != 'e' { os.Exit(1) }
|
||||
if s[1] != 'e' {
|
||||
os.Exit(1)
|
||||
}
|
||||
s = "good bye"
|
||||
var p *string = &s
|
||||
*p = "ciao"
|
||||
|
@ -14,7 +14,6 @@ func sum(a []int) int { // returns an int
|
||||
return s
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
s := sum([3]int{1, 2, 3}[:]) // a slice of the array is passed to sum
|
||||
fmt.Print(s, "\n")
|
||||
|
Loading…
Reference in New Issue
Block a user