A single Go source file is not allowed to be in more than one package.

On Wed, Apr 26, 2017 at 8:52 AM Tong Sun <suntong...@gmail.com> wrote:

> Hi,
>
> I'm trying to put different code collection into the same Go source file,
> (from here
> <https://medium.com/golangspec/type-assertions-in-go-e609759c42e1>, if
> you want to know), because the knowledge is related thus better keep in one
> demo file instead of several. However, the challenge to me is that, it
> keeps reusing the same variable name for different purposes (which I think
> IS good practice). E.g.,
>
> In one section the type A is defined as
>
> type A struct {
> }
>
> In another section the type A is defined as
>
> type A struct {
>     name string
> }
>
>
> In C#, this is not a problem at all, as I can just put different cases
> into different namespaces.
>
> How to do it (putting different code collection into the same Go source
> file) in Go?
>
> I tried to separate different sections with
>
> package next_section
>
> but got the error
>
> expected declaration, found 'package'
>
> What's the easiest way to do it? please help.
>
> 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