- Distributed Computing with Go
- V.N. Nikhil Anurag
- 97字
- 2021-06-24 18:36:09
addInt.go
The tests in variadic_test.go elaborated on the rules for the variadic function. However, you might have noticed that TestSimpleVariadicToSlice ran three tests in its function body, but go test treats it as a single test. Go provides a good way to run multiple tests within a single function, and we shall look them in addInt_test.go.
For this example, we will use a very simple function as shown in this code:
// addInt.go package main func addInt(numbers ...int) int { sum := 0 for _, num := range numbers { sum += num } return sum }
推薦閱讀
- UNIX操作系統(tǒng)設(shè)計(jì)
- 玩到極致 iPhone 4S完全攻略
- Extending Bootstrap
- 高性能Linux服務(wù)器構(gòu)建實(shí)戰(zhàn):系統(tǒng)安全、故障排查、自動(dòng)化運(yùn)維與集群架構(gòu)
- 混沌工程實(shí)戰(zhàn):手把手教你實(shí)現(xiàn)系統(tǒng)穩(wěn)定性
- Linux系統(tǒng)安全基礎(chǔ):二進(jìn)制代碼安全性分析基礎(chǔ)與實(shí)踐
- Windows 8實(shí)戰(zhàn)從入門到精通(超值版)
- Python UNIX和Linux系統(tǒng)管理指南
- Windows 7實(shí)戰(zhàn)從入門到精通(超值版)
- 電腦辦公(Windows 10 + Office 2016)入門與提高(超值版)
- Office 365 User Guide
- 辦公自動(dòng)化教程(Windows7+Office2010)
- Implementing Cloud Design Patterns for AWS(Second Edition)
- iOS Programming Cookbook
- Docker for Developers