- 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系統管理
- 發布!設計與部署穩定的分布式系統(第2版)
- 高性能Linux服務器構建實戰:運維監控、性能調優與集群應用
- Linux集群和自動化運維
- Windows Vista融會貫通
- Instant Optimizing Embedded Systems using Busybox
- 網絡操作系統管理與應用(第三版)
- 8051軟核處理器設計實戰
- Joomla! 3 Template Essentials
- Introduction to R for Quantitative Finance
- Learning BeagleBone
- bash shell腳本編程經典實例(第2版)
- Azure Resource Manager Templates Quick Start Guide
- Windows 8玩全不求人
- Windows PE權威指南