Hi,

the compiler (not just the linker) needs to know, what identifiers refer to
and package imports are file-local, so they necessarily need to be included
in all files. Similarly for the package declaration, AFAIK it's used in the
object files to disambiguate symbols.
What you can do, to reduce the annoyance in generated code, is to just
include all possibly needed packages and then use them, by adding something
like "var _ bytes.Buffer" in the generated header. It then won't matter
whether the generated code actually uses the package, it counts as used for
correctness.

On Sat, Mar 18, 2017 at 12:49 PM, <u89...@gmail.com> wrote:

> Before anyone flames, I love Go! There. Ok, now to the issue at hand --
>
> The toolchain already seems to understand the directory layout then why
> bother littering the sources with package declaration? Also is there a
> point to specifying imports at a file level? I mean doesn't the linker
> bring in symbols at a package level anyway? My reason for brining this up
> is I'm trying to generate a codebase using a custom built specification and
> having to constantly tweak the imports and packages (in over 200 files) are
> getting in my way of a smooth development. I'm sure others have had the
> same problem.
>
> In the spirit of brining a solution and not just a problem, how about the
> toolchain assume a package to be "main" if there's a main function therein.
> Imports could be specified at the package level like in D or Rust in a
> separate file.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to