Comments (5)
I'm not quite sure what the right thing to do here is. When there's a file in
the top-level cmd folder, e.g. cmd1.go, the builder assumes that it's a
stand-alone file that should be compiled into cmd1.exe. If you create a
sub-folder of cmd called "subf" and put the files in there, the builder will
compile them together to make an executable called subf.exe. This would solve
the problem of referencing fromCmd1 and fromCmd2, but causes an error because
of the redefinition of func main.
For reference executing 8g cmd1.go cmd2.go also results in an error:
"cmd2.go:3: main redeclared in this block previous declaration at cmd1.go:3"
The other way to handle it, of course is to put fromCmd1 and fromCmd2 in
packages under src/pkg.
Original comment by [email protected]
on 3 Nov 2010 at 1:41
from goclipse.
yes, you are right. I did not compile by hand the sample I gave you. Of course
it would give an error about the redefinition of main. However I think it was
my example that wrongly did this redefinition. The gocode has only one main
function in the main package, as expected.
so building with:
8g cmd1.go cmd2.go
8g cmd2.go cmd1.go
would generate .8 files for both cmd1 and cmd2
then the linker would be called only for the one that actually has main. They
can still refer each other in other forms (through other functions)
Your suggestion is actually what I did to compile gocode. I moved all code from
the main package to a new package in the pkg, then created a cmd that actually
calls the main() function from gocode.go which is now well packed in it's
package.
But this is not something we can ask of developers. If they decide to use
multiple files at the main package level, I think they should be able to do it.
Original comment by [email protected]
on 3 Nov 2010 at 2:05
from goclipse.
Right, I had forgotten you were compiling gocode. You can get it to work by
putting all the top-level source files into a subfolder of cmd called "gocode".
Then put the "goconfig" files into src/pkg/configfile. Then the only problem
is the 'import cfg "./configfile"' in config.go. If you change that to "import
cfg "configfile"' it works fine.
So once again, it comes down to how to handle an import prefixed with "./" Is
the answer simply to look for local packages in the pkg folder? If so, what is
the best way to get the go toolchain to do that?
Original comment by [email protected]
on 3 Nov 2010 at 7:36
from goclipse.
I did not expect to have a folder in cmd. This works great :)
I think we do need to handle the ./ packages somehow. People seem to use it. I
wonder how is usually handled in linux. Is the make build doing something to
change the ./ notation to a global one? or the packaging works file with ./ ?
I've tried to find some docs about gopack but the only thing I found is a link
to a different tool in Plan9 which has different sets of parameters now.
Original comment by [email protected]
on 6 Nov 2010 at 6:52
from goclipse.
Original comment by [email protected]
on 10 Jun 2012 at 10:46
- Changed state: Fixed
from goclipse.
Related Issues (20)
- Gocode Plugin failed to kill gocode process on Windows XP home Edition
- Can't use imported packages HOT 2
- Build Errors Don't Stop Execution HOT 1
- Unchecking "Start Gocode server automatically" has no effect HOT 1
- Let Go projects being created in arbitrary directories
- Handle Go line directives correctly
- Build produce no output in Console HOT 3
- No automatic indentation
- Error with documentation popup
- Not compiling on save HOT 2
- Go uses weird date format (probably US, or iranian) HOT 2
- Linked folders cause project name to be prepended to file paths, causing Resource Not Found stack traces. HOT 1
- External Packages Aren't Added to Pkg Directory
- ctrl-clic can show to wrong function
- Debugging: adding a breakpoint results in -break-insert error messages from gdb into the console HOT 1
- UTF-8 chinese character GoCode
- Content assist does not work for some source code file HOT 1
- Create markers when formatting fails HOT 2
- unexpected char: }
- .exe file doesn't exist HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goclipse.