Golang 继承

Jackey Golang 3,464 次浏览 0 评论 ,
package main import "fmt" type Student struct { Name string Age int Score float64 } // 将公有的方法绑定到Student 结构体 func (s *Student) GetInfo() { fmt.Printf("学生姓名=%v...

Golang 封装

Jackey Golang 2,758 次浏览 0 评论 ,
person.go package model import "fmt" type person struct { Name string age int // 其他包不能访问 salary int } // 写一个工厂模式的函数,相当于构造函数 func NewPerson(name st...

Golang 工厂模式

Jackey Golang 2,736 次浏览 0 评论 ,
student.go package model type student struct { Name string age int } // 结构体student 首字母小写,因此只能在 model 内部使用 // 如果想外部调用,我们可以通过工厂模式解决 func NewStude...

go get 超时的解决方法

Jackey Golang 4,328 次浏览 0 评论
GO 1.13 及以上(推荐) Windows $ go env -w GO111MODULE=on $ go env -w GOPROXY=https://goproxy.cn,direct macOS 或 Linux $ export GO111MODULE=on $ export GOPROXY=https://goproxy.cn 然后再执行 ...

Golang 方法中指针传值的陷阱

Jackey Golang 2,584 次浏览 1 评论 ,
package main import "fmt" type Person struct { Name string } func (p Person) test1() { p.Name = "www.gopher.cc" fmt.Println(p.Name) } func (p *Person) test2() { p.Name =...

Golang 切片在内存中的形式

Jackey Golang 2,641 次浏览 1 评论 ,
代码示例: package main import "fmt" func main() { var intArr [5]int = [...]int{1, 22, 33, 66, 99} slice := intArr[1:3] fmt.Println("intArr=", intArr) fmt.Println("slice 的元素...

Golang 数组的内存布局

Jackey Golang 3,819 次浏览 2 评论 ,
如下面一段代码: package main import "fmt" func main() { var intArr [3]int fmt.Println(intArr) } 内存布局如下: 对上图的总结: 数组的地址可以通过数组名来获取 &intArr...

Golang 单元测试

Jackey Golang 2,902 次浏览 0 评论 ,
在package main里定义一个函数Add,求两个数之和的函数,然后我们使用单元测试进行求和逻辑测试。单元测试的最常见以及默认组织方式就是写在以 _test.go 结尾的文件中,所有的测试方法也都是以 Test 开头并且只接...

beego 定时任务的实现

Jackey Golang 5,575 次浏览 2 评论 ,
[codesyntax lang="c"] package main import ( "github.com/astaxie/beego" "github.com/astaxie/beego/logs" "github.com/astaxie/beego/toolbox" ) func InitTask(){ tk := toolbox.NewTask("g...

Golang 生成dll动态库并调用

Jackey Golang 8,298 次浏览 0 评论 ,
安装gcc环境 运行环境:window10 64位 下载路径:http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.8.2/threads-posix/seh/x86_64-4.8.2...

Golang 静态库的编译和使用

Jackey Golang 4,307 次浏览 0 评论
本文主要介绍go语言静态库的编译和使用方法,以windows平台为例,linux平台步骤一样,具体环境如下: [codesyntax lang="bash"] >echo %GOPATH% E:\share\git\go_practice\ >echo %GOROOT% C:\Go\...

windows系统使用ls命令

Jackey 其他 2,807 次浏览 0 评论 ,
1.打开C:\Windows\System32文件夹 2.在文件夹中新建ls.bat文件 3.右键编辑此文件在文本中输入 [codesyntax lang="bash"] @echo off dir [/codesyntax]   保存 此时就已经可以在命令行使用l...

Golang 生成动态库及调用

Jackey Golang 4,193 次浏览 0 评论
plugin.go [codesyntax lang="c"] /************************************************************ go build --buildmode=plugin plugin.go **********************************************************/...
Go