Is it recommended to store program sources in a single file (as opposed to lib sources)?

I’m taking the first steps and, obviously, I’m reasoning from what I’m used to in other languages, but don’t understand what needs to be done regarding specifics and styles.

I decided to rewrite the work with the ruby ​​background that I have in order to take a lot of time. It iterates over a huge table in my database and processes the data separately for each row, so this is a good candidate for parallelization.

Based on the ruby ​​on rails task and the use of orm, this should have been, as I thought, a fairly simple two-file program: one that will contain the structure type and its methods for representing and working with the string and the main file for working with the database data and a loop in lines (perhaps the third file for abstract database access logic if it gets too heavy in my main file). This file splitting, I assumed, was intended for code clarity, more than anything to do with the final binary.

I read and saw several things on topics, including questions and answers here, and they are always inclined to allow writing code in the form of libraries, installing them, and then using them in one file system (in the main program).

I read that it is possible to transfer multiple files to build / run, but he complains if there are several package names (so basically everything should be in main), and this does not seem to be common.

So my questions are:

  • I understood this correctly and had the code mostly as a library with one file program importing its path?
  • if so, how do you deal with the need to re-create libraries? Do you create / install with each change in the library code base before execution (which is less convenient than a promise go run), or is there something in common that I don’t know about in order to quickly and quickly execute a library-dependent program, when working these libraries are encoded?
+4
source share
2 answers

No.

Go go ( go run , ): Go, . , , , ..

:

?

. , . lib + , . : ​​ . 12 , . , , . .

, ? / ( , , ), - , , , , ?

go , . , main.go, foo. go run main.go, foo , . , : go install foo; go run main. foo, bar waz, , foo, bar waz.

+10

. Go .

+2

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


All Articles