godef icon indicating copy to clipboard operation
godef copied to clipboard

godef might be extremly slow in Go packages using cgo when using go/packages

Open segevfiner opened this issue 7 years ago • 0 comments

I noticed that godef is now conditionally using go/packages . I had an encountered an issue with gogetdoc that is caused by go/packages. go/packages invokes go list -compiled (golang/tools/go/packages/golist.go#L630) unconditionally, which compiles any cgo packages in the list, without any caching.

This can get prohibitively slow to the point that it made gogetdoc unusable when such packages are in the list.

Steps to reproduce

You need to have ImageMagick available. (See https://github.com/gographics/imagick)

  1. Save the following as main.go in a new go package directory:
package main

import "gopkg.in/gographics/imagick.v2/imagick"

func main() {
	imagick.Initialize()
}
  1. dep init.
  2. godef -pos main.go:#87.

I haven't yet gotten around to check if this reproduces.

godetdoc issue: https://github.com/zmb3/gogetdoc/issues/47

segevfiner avatar Dec 25 '18 00:12 segevfiner