Skip to content

Instantly share code, notes, and snippets.

@simplyvikram
Last active August 29, 2015 14:05
Show Gist options
  • Save simplyvikram/9c8a1d6d41844c06d25a to your computer and use it in GitHub Desktop.
Save simplyvikram/9c8a1d6d41844c06d25a to your computer and use it in GitHub Desktop.
package main
import "fmt"
type Asset interface {
AssetType() string
GetBase() Base
SetBase(b Base)
}
type Base struct {
X int
}
type Article struct {
Base
}
func (a *Article) AssetType() string {
return "article"
}
func (a *Article) GetBase() Base {
return a.Base
}
func (a *Article) SetBase(b Base) {
a.Base = b
}
func ChangeAsset(a Asset) {
var b Base = a.GetBase()
b.X = 43
a.SetBase(b)
}
func main() {
fmt.Println("Hello, playground")
var x Asset = &Article{Base: Base{5}}
ChangeAsset(x)
fmt.Println("Value of asset", x)
//a := b.(Article)
//fmt.Println(a.AssetType())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment