learninggolang's People
learninggolang's Issues
设计模式 options
golang learning临时笔记
https://pkg.go.dev/go.uber.org/fx#section-readme
fx 的使用
uface 中的已知问题
## 命令 lotus-shed election backtest t029390 --height=594153 --count=10000
--height
-- count
不生效原因是 uface/v2版本的已知问题,等v3出来吧
https://github.com/urfave/cli/issues/1113
临时笔记
钉钉消息 html转图片总结
在golang 自行调度的场景下,wkhtmltoimage (wkhtmltopdf)这个工具遇到的一些问题
- 因为依赖qt 而qt 需要在主线程中创建application
WARNING: QApplication was not created in main() thread
这样造成的后果是 因为qt没有初始化好,后面转换出现了乱码
- cgo调用c代码的时候,如果go的调度器切换了线程,那么cgo有可能会失败
cgo Interacting with C Library that uses Thread Local Storage
//https://github.com/bratsche/glib/blob/master/glib/gmain.c
/**
* g_main_context_pop_thread_default:
* @context: a #GMainContext object, or %NULL
*
* Pops @context off the thread-default context stack (verifying that
* it was on the top of the stack).
*
* Since: 2.22
**/
void
g_main_context_pop_thread_default (GMainContext *context)
{
GQueue *stack;
if (context == g_main_context_default ())
context = NULL;
stack = g_static_private_get (&thread_context_stack);
g_return_if_fail (stack != NULL);
g_return_if_fail (g_queue_peek_head (stack) == context);
g_queue_pop_head (stack);
g_main_context_release (context);
if (context)
g_main_context_unref (context);
}
(process:14437): GLib-CRITICAL **: 03:30:03.635: g_main_context_pop_thread_default: assertion 'stack != NULL' failed
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x7fb271104041]
runtime stack:
runtime.throw(0x117aaed, 0x2a)
/usr/local/go/src/runtime/panic.go:1116 +0x72
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:726 +0x4ac
goroutine 23316 [syscall]:
runtime.cgocall(0xef1610, 0xc0008c99e8, 0xc0008c99f0)
/usr/local/go/src/runtime/cgocall.go:133 +0x5b fp=0xc0008c99b8 sp=0xc0008c9980 pc=0x4058bb
github.com/shezadkhan137/go-wkhtmltoimage._Cfunc_wkhtmltoimage_deinit(0x0)
_cgo_gotypes.go:143 +0x49 fp=0xc0008c99e8 sp=0xc0008c99b8 pc=0xd779a9
github.com/shezadkhan137/go-wkhtmltoimage.Destroy()
最终的解决办法是用
runtime.LockOSThread()
runtime.UnlockOSThread()
通过不让调度器切换线程来避免这样的问题,这样的操作当然是有代价的 性能会下降
中台定时任务故障排查跟踪
golang 调度研究
hell | hello | heh |
---|---|---|
os层 最大线程数量
https://stackoverflow.com/questions/344203/maximum-number-of-threads-per-process-in-linux
golang 最大线程数量 10000
可以通过 runtime debug 包中的SetMaxThreads() 来设置
创建的条件是,
当前的thread 如果被block 了 (比如在io等待)将会重新创建一个新的os层的thread 来继续工作
It will create a new thread once current one is blocked.
golang实现接口注意事项
简介
golang实现接口有很多需要注意的地方
var dataSlice []int = foo()
var interfaceSlice []interface{} = dataSlice
Why can't I assign any slice to an []interface{}
原因:
[]interface{} is not an interface!
长度不一样 []interface{} 占两个words 一个是类型,一个是内容或者指针 对于N长的数据总长是 N*2
如果非要用 可以这样
var dataSlice []int = foo()
var interfaceSlice []interface{} = make([]interface{}, len(dataSlice)) //这里指定已知类型的长度
for i, d := range dataSlice {
interfaceSlice[i] = d
}
常用debug的方法
JsonRpc学习
简介
如何利用jsonrpc 来搭建web服务
golang 调度器文档总结
hello
generate go code with json text
golang 中 遍历一个channel的方法
https://go.dev/tour/concurrency/4
要么用 c,ok <- channel 如果 ok =false 说明channel关闭了
或者 for ic := range channel 如果for结束了,说明channel关闭
两个方法都比较安全
自定义json marshal unmarshal 方法
golang 引入私有repo
参考资料
go env -w GOPRIVATE=github.com/woshidama323/FILECOIN
注意:
加私有仓储 需要提供当前环境的 ssh public key到github私有仓储中
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.