西维蜀黍

【Golang】类型 - map 深入

  ...


【Golang】godoc

Overview

Comments on package declarations should provide general package documentation. These comments can be short, like the sort package’s brief description:

// Package sort provides primitives for sorting slices and user-defined
// collections.
package sort
  ...


【Golang】Generating Code

  ...


【Golang】Linters - goimports

With goimports, you can automatically update your Go import lines (add missing and remove unreferenced imports).

In addition to fixing imports, goimports also formats your code in the same style as gofmt so it can be used as a replacement for your editor’s gofmt-on-save hook.

  • goimports is a superset of gofmt which additionally adds (and removes) import lines as necessary.
  ...


【Golang】Linters - gofmt

Introduction

Gofmt is a tool that automatically formats Go source code.

Gofmt’d code is:

  • easier to write: never worry about minor formatting concerns while hacking away,
  • easier to read: when all code looks the same you need not mentally convert others’ formatting style into something you can understand.
  • easier to maintain: mechanical changes to the source don’t cause unrelated changes to the file’s formatting; diffs show only the real changes.
  • uncontroversial: never have a debate about spacing or brace position ever again!
  ...