-
首先撰写golang程序exportgo.go:
package main
import "C"
import "fmt"
//export PrintBye
func PrintBye() {
fmt.Println("From DLL: Bye!")
}
//export Sum
func Sum(a int, b int) int {
return a + b;
}
func main() {
// Need a main func
-
在go的微服务架构中
使用go-kit组件进行开发微服务
type Reg struct {
Host string
Port int
Client consul.Client
}
func MakeReg (host string , port int) (*Reg , error) {
reg := api.DefaultConfig()
reg.Address = host + ":" + strconv.It
-
最近用go写程序时遇到一个问题——求任意类型切片的长度。
作为一个初学者,刚刚学了接口和切片,知道了每个类型都实现了一个空接口interface{},那么如果接口类型作为函数的参数,那它应
-
源码中的 nil 是这样定义的
// nil is a predeclared identifier representing the zero value for a
// pointer, channel, func, interface, map, or slice type.
var nil Type // Type must be a pointer, channel, func, interface, map, or slice type
所
-
问题内容
我用的github.com/go-sql-driver/mysql这个驱动,我像下面这样写没有报错,但是里面的数据为空或者0
type data struct {
id int
name string
weight int
}
rows, _ := db.Query("select * from test where id = ?",
-
问题内容
func test_gomaxprocs() {
runtime.GOMAXPROCS(1)
wg := sync.WaitGroup{}
wg.Add(20)
for i := 0; i < 10; i++ {
go func() {
fmt.Println("i:", i)
defer wg.Done()
}()
}
for i := 0;
-
问题内容package main
import (
"fmt"
)
func main() {
fmt.Println(f0()) // 1
fmt.Println(f1()) // 0
}
func f0() (result int) {
defer func() {
result++
}()
return 0
}
func f1() (result int) {
result = 0 //return语
-
1、算数运算符
MySQL支持的算术运算符:
运算符
作用
+
-
问题内容基于docker的web微服务运行的时候,映射了宿主的log目录到容器的log目录,此时我们开启了一个filebeat微服务,这个微服务的目的就是吧log目录的日志同步到elasticsearch,问题是我们如何确
-
问题内容go新手,现在利用 go 实现一个在终端聊天的程序,我想请问一下如何实现服务端一边在监听新的连接请求,一边可以和其中的一个客户端聊天呢?我现在写的监听客户端连接的程序会阻
-
锁概念InnoDB存储引擎包含了三种行锁的算法,分别如下所示:Record Lock:行锁,针对的是单行记录;Gap Lock:间隙锁,锁定的是一个范围,但是不包含记录本身;Next-Key Lock:其实就是行锁+间隙锁
-
不写 database 参数就好了import pymysql.cursors
# Connect to the database
connection = pymysql.connect(host='192.168.31.xxx',
user='root',
password='xxx',
)
-
MHA(Master HA)是一款开源的 MySQL 的高可用程序,它为 MySQL 主从复制架构提供了 automating master failover 功能。MHA 在监控到 master 节点故障时,会提升其中拥有最新数据的 slave 节点成为新的master 节
-
最近在解析 // model.LocalTime
package model
const TimeFormat = "2006-01-02 15:04:05"
type LocalTime time.Time
业务代码结构
// You Application Struct
package order
type OrderTest struct {
OrderId int `json:"order_id"`
-
最近打算把博客转移到typecho平台,选了一个风格个人比较喜欢的主题,即Akina for Typecho 主题模板,在这里先感谢题主的开源分享,但是在使用过程中一开始就出现“500 Database Query Error”问题。