๋ฌธ์ ๋ฅผ ์ ์ถํ๊ธฐ ์ ์ ๋ค์ ์ง๋ฌธ์ ๋ตํ์ญ์์ค. ๊ฐ์ฌ ํด์!
go version
)?go version go1.6 darwin/amd64
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/ash/code/go"
GORACE=""
GOROOT="/Users/ash/.homebrew/Cellar/go/1.6/libexec"
GOTOOLDIR="/Users/ash/.homebrew/Cellar/go/1.6/libexec/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
์ด ์
๋ ฅ ํ์ผ demo.go
์ด ์ฃผ์ด์ง๋ฉด :
package main
// #include <unistd.h>
import "C"
import "fmt"
func main() {
foo := 1
C.close(2)
fmt.Println(foo)
}
๋ค์ ๋ช
๋ น์ ์คํํ์ญ์์ค: gorename -offset demo.go:#78 -to bar
์ค๋ฅ ์์ด ์ด๋ฆ ๋ณ๊ฒฝ: Renamed 2 occurrences in 1 file in 1 package.
์ด ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: gorename: -offset "demo.go:#78": no identifier at this position
/cc @alandonovan
๊ฐ์ ๋ฌธ์ ๊ฐ ์๋๋ฐ ์ด์ ๋ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๊น?
์ธ์ ์ธ์ง(์ ๋ 1.9.2๋ก ์งํ ์ค) ์ค๋ฅ๊ฐ ๋ค์๊ณผ ๊ฐ์ด ๋ณ๊ฒฝ๋์์ต๋๋ค. "gorename: DO NOT EDIT ๋ง์ปค๊ฐ ํฌํจ๋ ์์ฑ๋ ํ์ผ์ ์๋ณ์ ์ด๋ฆ์ ๋ฐ๊ฟ ์ ์์ต๋๋ค"
๊ทธ๋ฆฌ๊ณ gorename์ด cgo ํ์ผ์์ ์๋ํ์ง ์๋๋ค๋ ๊ฒ์ ์์๋ด๋ ๋ฐ ์๊ฐ์ด ๊ฑธ๋ ธ์ต๋๋ค. ์กฐ๋ง๊ฐ ์์ ์ฌํญ์ด ์์ ๊ฒฝ์ฐ ์ต์ํ ์ค๋ฅ ๋ฉ์์ง๋ฅผ ๋ณ๊ฒฝํด์ผ ํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๊ฐ์ ๋ฌธ์ ๊ฐ ์๋๋ฐ ์ด์ ๋ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๊น?