Skip to content

Instantly share code, notes, and snippets.

@ha1t
Created February 5, 2016 11:00
Show Gist options
  • Save ha1t/d97f7315ec99a30083ec to your computer and use it in GitHub Desktop.
Save ha1t/d97f7315ec99a30083ec to your computer and use it in GitHub Desktop.
package main
import "fmt"
type counter int
type mystring string
func (c *counter) inc() int { *c++; return int(*c) }
func (c *counter) dec() int { *c--; return int(*c) }
func (s *mystring) first() string { return string(string(*s)[0]) }
func main() {
var c counter
fmt.Println(c.inc())
fmt.Println(c.inc())
var hoge = "hogehoge"
fmt.Println(string(hoge[0]))
var moge mystring
moge = "mogemoge"
fmt.Println(moge.first())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment