Is there a way or tool in Emacs, specifically by use of go-mode, to automatically add the lines of code to the import
statement, while writing code that uses those packages? Let us assume those packages is got by go get
or in some other way at a time before, they are somewhere in the src
dir or they are just built-in go packages.
Like, in following go program, two built-in packages are used, os
and fmt
; however only one of them are imported, os
. While typing the first line in the main, that uses fmt
package, is it possible some tool, existence is in question here, can add the package name to to import
s.
package main
import (
"os"
)
func getHome() {
return os.Getenv("HOME")
}
func main() {
fmt.Println("this is my go playground.")
h := os.Getenv("HOME")
g := os.Getenv("GOPATH")
p := os.Getenv("PATH")
getHome()
}