Golang separate on multiple files
- Clone or initialize empty git project
- Example: git clone https://github.com/egevorkyan/multi.git
- Enter to cloned project folder and prepare project structure
- Example: project multi will have 2 packages: employee and sources
- Enter following commang to initialize
- Example: go mod init github.com/egevorkyan/multi
- Example Output: go: creating new go.mod: module github.com/egevorkyan/multi
- Finished tructure of my project created, time to write code
- main function must be placed in root folder of your project
- Example: empsalary.go, locates on same level as go.mod
- Simplefile employees.txt created which contains below information (Full Name, basic salary, tax)
Edi Tester,100000,33 Ben Parcker,1500000,40 Bill Nelson,45000,3
- Result - it can be any name of file and location, application will ask to input source file
Enter Employees source file: /Users/eduardgevorkyan/Documents/GOLEARN/employees.txt Employee Id: 0 Employee Name: Edi Tester Employee Salary: 67000 Employee Id: 1 Employee Name: Ben Parcker Employee Salary: 900000 Employee Id: 2 Employee Name: Bill Nelson Employee Salary: 43650