Using the import statement

I’ve been training for a couple of weeks, and so far so good. Now I am writing a program broken into different files:

.
|-- geometry
|   |-- cone
|   `-- cone.go
|-- main.go
|-- Makefile

The problem is that I cannot import cone.go into main.go, the compiler does not find it. Is anyone

+3
source share
2 answers

If you don't mind reading a bit, this link has a lengthy discussion of the issue you're asking for.

Here is a short answer.

$GOROOT/pkg (IIRC), . , make "", make go, (. ), make -I, ./geometry

+2

gc docs:

Flags:

-o file     
       output file, default 6.out for 6g, etc.
-e  normally the compiler quits after 10 errors; -e prints all errors
-I dir1 -I dir2     
       add dir1 and dir2 to the list of paths to check for imported packages
-N  disable optimization
-S  write assembly language text to standard output
-V  print the compiler version

-I geometry .

0

Source: https://habr.com/ru/post/1749573/


All Articles