On Monday, 6 October 2014 19:20:52 UTC+11, Mohammad Nawazish Khan wrote:
... If I am correct, the start of every GO code must be contained in
'main' package inside 'main' function.
If you're talking about Go program, then, yes, every Go program must have
"main" package that must have "main" function. And the program will start
with that "main" function.
... And now if I have two application (implying two entry points to two
different applications), it would become obligatory that they both have
same 'main' package and function.
They don't have "same" "main" package. Their "main" packages are unrelated
to each other. "main" package is special in Go as I have described above.
You also cannot import "main" package.
... Then in this situation how would you configure the GOPATH, if it were
you. I think I was able to explain the situation.
I think your confusion is because you have made your GOPATH consist of 2
separate directories. Do not do that. Until you have good reason to have
it, and you have understanding of consequences of that decision. For
example, if you do GOPATH=C:\GoProgramming, then you can have 2 separate
programs in C:\GoProgramming\src\hello1 and C:\GoProgramming\src\hello2
directories. They can both be package "main", and therefore have "main"
function. But they will be independent of each other. You could build them
with correspondent commands:
go build hello1
go build hello2
Or you could install them with
go install hello1
go install hello2,
which will build them and copy executables into C:\GoProgramming\bin
directory. So after install commands you will have
C:\GoProgramming\bin\hello1.exe and C:\GoProgramming\bin\hello2.exe in
You should read http://golang.org/doc/code.html
It will explain everything
much better then I do.
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 firstname.lastname@example.org.
For more options, visit https://groups.google.com/d/optout.