- 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 }
推薦閱讀
- Linux設備驅動開發詳解:基于最新的Linux4.0內核
- 零起點學Linux系統管理
- Linux系統架構與運維實戰
- Google系統架構解密:構建安全可靠的系統
- 阿里云數字新基建系列:云原生操作系統Kubernetes
- 大學計算機應用基礎實踐教程(Windows 7+Office 2013)
- Kubernetes從入門到實踐
- STM32庫開發實戰指南:基于STM32F4
- Social Data Visualization with HTML5 and JavaScript
- Windows 7實戰從入門到精通
- Windows 10從新手到高手
- Raspberry Pi入門指南
- Agile IT Security Implementation Methodology
- Mastering Eclipse Plug-in Development
- iOS Programming Cookbook