diff options
author | Agniva De Sarker <agnivade@yahoo.co.in> | 2018-04-14 00:23:09 +0530 |
---|---|---|
committer | Andrew Bonventre <andybons@golang.org> | 2018-04-13 19:50:50 +0000 |
commit | 7edc962a942e4a9d5e06dde79299f7fc5605f000 (patch) | |
tree | d05d3cbb132e60ace21a28184833cc4b31ef59c3 /content/organizing-go-code.article | |
parent | efc7460c787535c46feadda9f7c395f16a615306 (diff) |
content: update all golang.org links to https
Ran sed -i 's/\[\[http:\/\/golang.org/\[\[https:\/\/golang.org/g' *.article
Change-Id: I88acc5104e1a3fc5e9a1cf11b600b657202d8997
Reviewed-on: https://go-review.googlesource.com/106955
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Diffstat (limited to 'content/organizing-go-code.article')
-rw-r--r-- | content/organizing-go-code.article | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/content/organizing-go-code.article b/content/organizing-go-code.article index 147bee2..49fd728 100644 --- a/content/organizing-go-code.article +++ b/content/organizing-go-code.article @@ -12,9 +12,9 @@ Go code is organized differently to that of other languages. This post discusses The names you choose affect how you think about your code, so take care when naming your package and its exported identifiers. -A package's name provides context for its contents. For instance, the [[http://golang.org/pkg/bytes/][bytes package]] from the standard library exports the `Buffer` type. On its own, the name `Buffer` isn't very descriptive, but when combined with its package name its meaning becomes clear: `bytes.Buffer`. If the package had a less descriptive name, like `util`, the buffer would likely acquire the longer and clumsier name `util.BytesBuffer`. +A package's name provides context for its contents. For instance, the [[https://golang.org/pkg/bytes/][bytes package]] from the standard library exports the `Buffer` type. On its own, the name `Buffer` isn't very descriptive, but when combined with its package name its meaning becomes clear: `bytes.Buffer`. If the package had a less descriptive name, like `util`, the buffer would likely acquire the longer and clumsier name `util.BytesBuffer`. -Don't be shy about renaming things as you work. As you spend time with your program you will better understand how its pieces fit together and, therefore, what their names should be. There's no need to lock yourself into early decisions. (The [[http://golang.org/cmd/gofmt/][gofmt command]] has a `-r` flag that provides a syntax-aware search and replace, making large-scale refactoring easier.) +Don't be shy about renaming things as you work. As you spend time with your program you will better understand how its pieces fit together and, therefore, what their names should be. There's no need to lock yourself into early decisions. (The [[https://golang.org/cmd/gofmt/][gofmt command]] has a `-r` flag that provides a syntax-aware search and replace, making large-scale refactoring easier.) A good name is the most important part of a software interface: the name is the first thing every client of the code will see. A well-chosen name is therefore the starting point for good documentation. Many of the following practices result organically from good naming. @@ -44,10 +44,10 @@ It is easy to just throw everything into a "grab bag" package, but this dilutes On the other hand, it is also easy to go overboard in splitting your code into small packages, in which case you will likely becomes bogged down in interface design, rather than just getting the job done. -Look to the Go standard libraries as a guide. Some of its packages are large and some are small. For instance, the [[http://golang.org/pkg/net/http/][http package]] comprises 17 go source files (excluding tests) and exports 109 identifiers, and the [[http://golang.org/pkg/hash/][hash package]] consists of one file that exports just three declarations. There is no hard and fast rule; both approaches are appropriate given their context. +Look to the Go standard libraries as a guide. Some of its packages are large and some are small. For instance, the [[https://golang.org/pkg/net/http/][http package]] comprises 17 go source files (excluding tests) and exports 109 identifiers, and the [[https://golang.org/pkg/hash/][hash package]] consists of one file that exports just three declarations. There is no hard and fast rule; both approaches are appropriate given their context. -With that said, package main is often larger than other packages. Complex commands contain a lot of code that is of little use outside the context of the executable, and often it's simpler to just keep it all in the one place. For instance, the go tool is more than 12000 lines spread across [[http://golang.org/src/cmd/go/][34 files]]. +With that said, package main is often larger than other packages. Complex commands contain a lot of code that is of little use outside the context of the executable, and often it's simpler to just keep it all in the one place. For instance, the go tool is more than 12000 lines spread across [[https://golang.org/src/cmd/go/][34 files]]. * Document your code -Good documentation is an essential quality of usable and maintainable code. Read the [[http://golang.org/doc/articles/godoc_documenting_go_code.html][Godoc: documenting Go code]] article to learn how to write good doc comments. +Good documentation is an essential quality of usable and maintainable code. Read the [[https://golang.org/doc/articles/godoc_documenting_go_code.html][Godoc: documenting Go code]] article to learn how to write good doc comments. |