摘要:
使用Golang编程时,一般只有在写最终的main函数时我们才有机会调用某个函数进行测试,在大型项目中如果只负责编写某个非main模块时应当如何测试函数的可用性? Golang提供了Testing模块,这个模块可以让我们随时随地进行函数功能验证。 testing - The Go Programmi 阅读全文
摘要:
https://go.dev/blog/intro-generics 在《Interface简介》一文中,我使用如下代码实现了简单的Contains函数: package main import ( "fmt" ) func main() { var s []interface{} s = appe 阅读全文
摘要:
What is the difference between Builder Design pattern and Factory Design pattern? - Stack Overflow A factory is simply a wrapper function around a con 阅读全文
摘要:
项目地址:spf13/cobra: A Commander for modern Go CLI interactions (github.com) 文档地址:cobra/user_guide.md at master · spf13/cobra (github.com) Overview cobra 阅读全文
摘要:
go - Should I use panic or return error? - Stack Overflow 上述回答解释了panic与error的区别,一般来说panic用于会导致整个程序崩溃的错误(goroutine panic也会导致主程序panic),而error用于处理程序中可预见的 阅读全文