58 Star 602 Fork 278

ShirDon-廖显东 / Go Web编程实战派源码

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
1.7.3-interface1.go 917 Bytes
一键复制 编辑 原始数据 按行查看 历史
ShirDon-廖显东 提交于 2021-01-19 21:25 . commit
//++++++++++++++++++++++++++++++++++++++++
// 《Go Web编程实战派从入门到精通》源码
//++++++++++++++++++++++++++++++++++++++++
// Author:廖显东(ShirDon)
// Blog:https://www.shirdon.com/
// 仓库地址:https://gitee.com/shirdonl/goWebActualCombat
// 仓库地址:https://github.com/shirdonl/goWebActualCombat
//++++++++++++++++++++++++++++++++++++++++
package main
import "fmt"
type InterfaceFile interface {
Read()
Write()
}
type InterfaceReader interface {
Read()
}
type File struct {
}
func (f *File) Read() {
}
func (f *File) Write() {
}
func main() {
f := new(File)
var f1 InterfaceFile = f
var f2 InterfaceReader = f1
var f3 InterfaceReader = new(File)
// 接口查询
if f5, ok := f3.(InterfaceFile); ok {
fmt.Println(f5)
}
// 询问接口它指向的对象是否是某个类型
if f6, ok := f3.(*File); ok {
fmt.Println(f6)
}
fmt.Println(f1, f2, f3)
}
Go
1
https://gitee.com/shirdonl/goWebActualCombat.git
git@gitee.com:shirdonl/goWebActualCombat.git
shirdonl
goWebActualCombat
Go Web编程实战派源码
24222606b5c9

搜索帮助