Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: running asynce code in golang for read dir

Nina S:

For my program to start the works this is mandatory to read some yaml file to get description and run the logic according to it.

for this I do this

func main()
file, err := ioutil.ReadFile(path)
if err != nil {
log.Printf("File Loder: #%v ", err)
err := yaml.Unmarshal([]byte(file), &obj)
if err != nil {
log.Printf("File is not valid, Error: " + err.Error())




while this is async code, this works (i've checked it for file with size of 2000kb) but my question is

  1. If I use it for larger files this will not work
  2. in Node/js there is promises and in Go i found the sync package, should I use it in this case ?

While debug the code I see in the debugger that when I'm executing ioutil.ReadFile(path) the curser jump to latter line and then go back and the logic is working...

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered

This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: running asynce code in golang for read dir


Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription