123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package main
- import (
- "fmt"
- "net/http"
- "reflect"
- )
- type IBase interface {
- GetMeta() map[string]http.Handler
- }
- type IUserService interface {
- IBase
- Login(username string, password string) (bool, error)
- }
- type UserService struct {
- }
- func (userSrv *UserService) Login(username, password string) (bool, error) {
- return true, nil
- }
- func (userSrv *UserService) GetMeta() map[string]http.Handler {
- return map[string]http.Handler{}
- }
- func TestSrv(srv IBase) {
- fmt.Println(srv.GetMeta())
- }
- func main() {
- userSrv := &UserService{}
- TestSrv(userSrv)
- fmt.Println(reflect.TypeOf(userSrv.Login))
- tf(userSrv.Login)
- }
- func tf(f interface{}) {
- fc := reflect.ValueOf(f)
- fc.Call([]reflect.Value{"silenceqi", "sss"})
- }
|