Skip to content

Instantly share code, notes, and snippets.

@takuan-osho
Created January 19, 2014 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuan-osho/8505273 to your computer and use it in GitHub Desktop.
Save takuan-osho/8505273 to your computer and use it in GitHub Desktop.
Go言語でスライスとか文字列関係の勉強をしてみた ref: http://qiita.com/takuan_osho/items/74ef2d970a4888175336
package main
import (
"fmt"
"strings"
)
func main() {
s := []string{"ようこそ", "世界"}
fmt.Println(strings.Join(s, ""))
}
package main
import (
"fmt"
"sort"
)
func main() {
s := []string{"運", "いう", "ウン", "アナタ", "あなた", "うん", "言う", "イウ", "貴方"}
sort.Strings(s)
fmt.Println(s)
}
package main
import (
"fmt"
"sort"
)
func main() {
s := []string{"運", "いう", "ウン", "アナタ", "あなた", "うん", "言う", "イウ", "貴方"}
sort.StringSlice(s).Sort()
fmt.Println(s)
}
package main
import (
"fmt"
"sort"
)
func main() {
s := []string{"運", "いう", "ウン", "アナタ", "あなた", "うん", "言う", "イウ", "貴方"}
sort.Sort(sort.Reverse(sort.StringSlice(s)))
fmt.Println(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment