Coder Social home page Coder Social logo

Comments (4)

raphael avatar raphael commented on May 16, 2024

The code generation algorithms do their best efforts to compute the set of needed packages. There seems to be a few missing here and I'll create a PR shortly to address them. The case of "too many" imports is harder to deal with (sometimes fmt is needed sometimes it's not depending on how the types are defined in the DSL). There is logic that should detect whether it's needed though - looks like it's missing a case.

While the generator code strives to generate the right imports (and if it doesn't it's generally a bug like the cases above) the saving grace is the use of goimports. Once the generator is done it invokes goimports on the files which both fixes up the formatting and the import clauses. I'm guessing that's why nobody else has reported these issues. So TL;DR it looks like for some reason goimports is not working properly here. Could you describe a little bit your Go setup? do you have multiple GOPATH? is goimports installed and in the PATH?

from goa.

manell avatar manell commented on May 16, 2024

goimports was not installed. I've installed the package running
go get golang.org/x/tools/cmd/goimports and now it's working.

Thanks for your time!

from goa.

raphael avatar raphael commented on May 16, 2024

Great, thanks for confirming. I'll still update the generators code so they add the missing imports explicitly.

from goa.

raphael avatar raphael commented on May 16, 2024

Added the missing imports and an explicit check for goimports in goagen so that this shouldn't happen anymore.

from goa.

Related Issues (20)

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.