[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("generateWarning", "*/...
array
[codesyntax lang="c"]
package main
import (
"encoding/json"
"fmt"
)
func test(data [2]string) {
data[0] = "python"
}
func main() {
var testArray = [2]string{
"php",
"java",
}
v, ...
安装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-release-posix-seh-r...
本文主要介绍go语言静态库的编译和使用方法,以windows平台为例,linux平台步骤一样,具体环境如下:
[codesyntax lang="bash"]
>echo %GOPATH%
E:\share\git\go_practice\
>echo %GOROOT%
C:\Go\
>tree /F %GOP...
plugin.go
[codesyntax lang="c"]
/************************************************************
go build --buildmode=plugin plugin.go
**********************************************************/
package main
...
代码:
[codesyntax lang="c"]
package main
import (
"fmt"
)
func main() {
var str1 = "2"
var str2 = "11"
fmt.Println(str1 < str2)
str1 = "02"
str2 = "11"
fmt.Println(str1 < str2)
}
[/c...
使用 go get 时可以配合附加参数显示更多的信息及实现特殊的下载和安装操作
[table id=2 /]
接口定义:
[codesyntax lang="c"]
package testPlugin
type PluginFunc interface {
Hello()
World()
}
type Plugins struct {
Plist map[string]PluginFunc
}
func (p *Plugins) Init() {
p.Plist = make(m...
[codesyntax lang="c"]
package main
import "fmt"
func max(l []int) (max int) {
max = l[0]
for _, v := range l {
if v > max {
max = v
}
}
return
}
func min(l []int) (min int) {
min =...
[codesyntax lang="c"]
package main
import (
"fmt"
"math/rand"
"time"
)
//生成count个[start,end)结束的不重复的随机数
func GenerateRandomNumber(start int, end int, count int) []int {
//范围检查
if end...
[codesyntax lang="c"]
package main
import (
"fmt"
)
func test() int {
defer func() {
err := recover()
if err != nil {
fmt.Println(err)
}
}()
var a int = 10
var b int = 0
return a/b
}
...
[codesyntax lang="c"]
package main
import (
"fmt"
"strings"
)
// 构建闭包,判断传入的 name 是否包含 suffix 后缀,如果不包含,则添加后缀
// 如果包含,则直接返回 name
func dealSuffix(suffix string) func(st...
代码:
[codesyntax lang="c"]
package main
import "fmt"
var a = test()
func test() int {
fmt.Println("全局变量。。。")
return 90
}
func init() {
fmt.Println("init 方法。。", a)
}
func main()...
最近在项目中遇到一个很奇怪的问题,因为修改配置(redis中缓存的),nginx服务突然报upstream timed out (110: Connection timed out),然后去查为什么会出现这样的问题,发现出问题的服务是一个golang的http server,查看程序日志,...
[codesyntax lang="c"]
package main
import (
"fmt"
"sort"
)
func main() {
mapInfo := map[string]int32{
"roy":18,
"kitty":16,
"hugo":21,
"tina":35,
"jason":23,
}
type peroson struct {
...