What is the point of "examples" in the go (golang) testing framework? -


i reading on testing , examples in go testing framework , did not understand for. see documentation says:

the package runs , verifies example code. example functions may include concluding line comment begins "output:" , compared standard output of function when tests run. (the comparison ignores leading , trailing space.)

however, don't appreciate reason exist. write tests, seems should more clear how use code reading unit tests , benchmarks. additional motivation example section provide? seems redundant me, however, sure inventors of go put reason, specially because seem empathizes programming practice design of language. hope understand either motivation or how part of language can used in positive way in golang project! :)

in go, source code used generate documentation. examples not meant testing rather documentation. having compiled examples, can make sure working using them.

examples found in standard libraries can run directly in browser when using golang.org browse documentation. godoc.org instead links example code directly play.golang.org can try out.

as example or example usage, see: http://golang.org/pkg/sort/


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -