Last active
October 5, 2018 08:16
-
-
Save SeptiyanAndika/4be92242c3e2e23402cafae315a84875 to your computer and use it in GitHub Desktop.
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" | |
"reflect" | |
) | |
type CurrencySchema struct { | |
Code string | |
Name string | |
Type string | |
} | |
type CRUDInterface interface { | |
Model() (interface{}, interface{}) | |
} | |
type CRUD struct { | |
CRUDInterface | |
} | |
func (cr CRUD) Create(data string) { | |
fmt.Println("create function"); | |
m, _:=cr.Model() | |
fmt.Println(reflect.TypeOf(m).Name()); | |
fmt.Println(data); | |
} | |
func (cr CRUD) GET() { | |
fmt.Println("Get function"); | |
} | |
type CurrencyRepository struct { | |
CRUD | |
} | |
func (repository CurrencyRepository) Model() (interface{}, interface{}) { | |
return CurrencySchema{}, []CurrencySchema{} | |
} | |
func main() { | |
cr := CurrencyRepository{}; | |
cr.CRUDInterface = cr; | |
cr.Create("ini data") | |
fmt.Println("=====") | |
cr.GET() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment