goコマンド『doc』

Go言語に組み込まれているコマンド『doc』についてまとめました。

動作環境

ホストOSWindows 10 21H1(19043.2130) 64bit
WSL2
Visual Studio Code1.70.2
Docker Desktop4.12.0(85629)
Go1.19.2

構文

# Go言語のパッケージのドキュメントを出力する
# go doc [パッケージ名]

go doc fmt

==========
package fmt // import "fmt"

Package fmt implements formatted I/O with functions analogous to C's printf and
scanf. The format 'verbs' are derived from C's but are simpler.

# Printing

The verbs:

General:

    %v  the value in a default format
        when printing structs, the plus flag (%+v) adds field names
    %#v a Go-syntax representation of the value
    %T  a Go-syntax representation of the type of the value
    %%  a literal percent sign; consumes no value
            ・
            ・
            ・