Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.50 KB | None | 0 0
  1. package main
  2.  
  3. import "fmt"
  4.  
  5. type test struct {
  6.     value int
  7. }
  8.  
  9. //type Test interface {
  10. //  changeValue(newValue int)
  11. //  getValue() int
  12. //}
  13.  
  14. func (tst *test) changeValue(newValue int) {
  15.     tst.value = newValue
  16. }
  17.  
  18. func (tst *test) getValue() int {
  19.     return tst.value
  20. }
  21.  
  22. func main() {
  23.     var lol test
  24.     lol = test{value:0}
  25.     fmt.Println(lol.getValue())
  26.     lol.changeValue(1)
  27.     fmt.Println(lol.getValue())
  28.     change(lol)
  29.     fmt.Println(lol.getValue())
  30. }
  31.  
  32. func change(tst test){
  33.     tst.changeValue(2)
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement