本文へスキップ
BecomeCoder

Goのエラー · エラー2

imported and not used ― import したのに使っていない(コンパイル)

未使用のパッケージ import もエラーです。

出るコード

import (
    "fmt"
    "strings"   // 使っていない
)
func main() { fmt.Println("hi") }

エラーメッセージ

./main.go:3:5: "strings" imported and not used

直し方

使わない import は消します。goimports を使うと保存時に自動整理されます。