S
S
Salim_Gareev2018-04-07 17:35:14
go
Salim_Gareev, 2018-04-07 17:35:14

Import code into main file?

Good afternoon.
Just started learning Go and faced a difficult task. How to import all packages from a directory into the main file. But the number of packages in the directory is unknown:

package main

import{
"/packages" // Из этой папки нужно импортировать все пакеты
}

Or inline the script in a function:
func main(){
import("/packages/pack")  // Загрузить код из этого файла
}

How to do it? Tell me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
chromimon, 2018-04-07
@chromimon

1) Why import them? If you don't use them.
2) As soon as you start using them, they can be automatically imported via goimports
3) Display all directories in the console and write the output of the console function to a file. For example, like this:
dir /AD /B > myfile

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question