LoginSignup
0
0

godocのインストール go 1.20以降

Posted at

Goのgodocを使うとエラーが出るので再インストールしました。
しかし、従来のインストールだとエラーが出てしまう。
調べたらインストール方法が変わっていました。

1.godocの最新版が利用可能かどうかを確認します:

go list -u -m -versions golang.org/x/tools/cmd/godoc

2.最新版が入手できない場合は、特定のバージョンの godoc をインストールしてみることができます。例えば、バージョン v0.1.2 をインストールするには、以下のコマンドを実行します:

   go install golang.org/x/tools/cmd/godoc@v0.1.2

最新版の godoc をインストールする場合は、コマンドの最後にあるドットを必ず削除してください。正しいコマンドは

go install golang.org/x/tools/cmd/godoc@latest

しかし、インストールは完了したのですが
エラーが出てしまいます。

(base) PS > godoc os/user Current
Unexpected arguments. Use "go doc" for command-line help output instead. For example, "go doc fmt.Printf".
usage: godoc -http=localhost:6060
  -goroot string
        Go root directory (default "C:\\Program Files\\Go")
  -http string
        HTTP service address (default "localhost:6060")
  -index
        enable search index
  -index_files string
        glob pattern specifying index files; if not empty, the index is read from these files in sorted order
  -index_interval duration
        interval of indexing; 0 for default (5m), negative to only index once at startup
  -index_throttle float

調べたら コマンドの使い方が前と変わっていました。

go doc <package-name>

これで正常にコマンドが実行できました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0