Coder Social home page Coder Social logo

Comments (7)

nathany avatar nathany commented on May 23, 2024

Hm. I've had problems with goimports removing needed imports in the past, but I haven't had any trouble with the current version. So you're saying it behaves differently than on the command line? Do you perhaps have multiple copies of goimports with TextMate picking up an outdated copy?

Do you have TM_GOFMT set to the full path to goimports?

from golang.tmbundle.

willfaught avatar willfaught commented on May 23, 2024

I saw that my TM_GODOC was pointing to /usr/local/Cellar/go/1.4.1/libexec/bin/godoc, which no longer exists. Not sure if that's related, don't see how it could be, but I fixed it to point to 1.5.1, the version I have installed now.

I now have:

TM_GOCODE=/Users/myuser/bin/gocode
TM_GODOC=/usr/local/Cellar/go/1.5.1/libexec/bin/godoc
TM_GOFMT=/Users/myuser/bin/goimports
TM_GOPATH=/Users/myuser

Are those right? I kind of fumbled through setting stuff to get things to work.

I don't see the problem right now in the files I have open, but I'll post back here if I see it again in the next few days.

Thanks for responding!

from golang.tmbundle.

willfaught avatar willfaught commented on May 23, 2024

Come to think of it, it would be really helpful for the README to say which environment variables should be set to what.

from golang.tmbundle.

nathany avatar nathany commented on May 23, 2024

Yes, it sure would. Or at least what environment variables there are to set. The values will depend on how you installed Go, but perhaps there could be suggestions for the common installations?

I bet @syscrusher would accept a PR. 😉

from golang.tmbundle.

willfaught avatar willfaught commented on May 23, 2024

Still seeing it. For example:

$ go build
$
[Save with no changes in TextMate, which then removes an import]
$ go build
# my/import/path
./foo.go:123: undefined: bar in bar.Baz
$ goimports -e -l -w
foo.go
$ go build
$

Don't know if this could be related, but the import removed is for a package with a name different than its directory name (e.g. directory "go-foo" for package "foo"). If I add an alias for the package, the import is no longer removed and the behavior matches that on the command line.

from golang.tmbundle.

willfaught avatar willfaught commented on May 23, 2024

I'm seeing some strange behavior. If I Ctrl-Shift-H (goimports), the package with the name that doesn't match the directory name (e.g. go-foo) immediately disappears, then the editor freezes for a couple seconds (I suspect this is because it's a somewhat large file) and then the import pops in again. I can keep invoking goimports like that it over and over and that happens every time. If I Cmd-S save, it removes the import but doesn't bring it back, and saving again doesn't change anything. If I goimports after that, it behaves as described before.

from golang.tmbundle.

willfaught avatar willfaught commented on May 23, 2024

Looked into how goimports works and figured it out. I removed all variables except PATH, prefixed PATH with $PATH:, and then added the GOPATH variable. So now I have:

PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/go/1.5.1/libexec/bin:/Users/Will/bin
GOPATH=/Users/Will

from golang.tmbundle.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.