Created
April 29, 2018 20:26
-
-
Save fenollp/3709f48a69594fa0de4ac5e904a7c6e2 to your computer and use it in GitHub Desktop.
Monkey patching idea in Golang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
import "bytes" | |
func (* bytes.Buffer) Eh() string { | |
return "yay" | |
} | |
func main() { | |
fmt.Println("hey!") | |
fmt.Println(bytes.NewBuffer([]byte{}).Eh()) | |
} | |
// ./monkey_patching.go:5:6: cannot define new methods on non-local type bytes.Buffer | |
// ./monkey_patching.go:11:39: bytes.NewBuffer([]byte literal).Eh undefined (type *bytes.Buffer has no field or method Eh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment