A good question is a question that is clear for everyone, on-topic, useful for future visitors and answerable in a few paragraphs.
Your question has three paragraphs and a closing sentence.
First paragraph:
I'm new to the Go language and I have a small project that I'd like to write it in Go mostly as a practice, but if it turns out to be good enough, I will use it in the future. Here's the deal:
It doesn't matter what your motivation is to post a question. It doesn't matter for the answer, it doesn't matter for future visitors that try to solve the same problem. Remember the tour? This site is all about getting answers. It's not a discussion forum. There's no chit-chat.
There are a bunch of JSON files scattered in a series of directories. What I want is to read all these files and use them in HTTP requests as POST input. The HTTP response (JSON encoded) is just a boolean flag if all went ok and a string indicating the error in case that something went wrong. I already have this written in PHP and it's a bit slow, since it runs in a serialized order. I thought that go routines would be a way to make this faster and spawn a concurrent number of routines that make the HTTP requests and wait for the response. What troubles me is how to implement this in Go.
What troubles do you have? Reading a file? Creating an HTTP request? Decoding JSON? Determining the difference between a boolean and a string? Performance? Waiting for the response?
I'm thinking of reading all the files in a map structure (the files are small, the size of all of them in the directories is 11MiB) and depending on the number of routines that I need spawned, feed each one with a item from the map. I've read that maps are not concurrent safe, would this be a problem in this case? Would a channel help where I feed the channel with the content of a file while reading all the files from the main thread and having the routines read from it?
Great ideas. We don't know yet if channel
can work, but you're the first person to give that a try and then ask about any issue you run into. The same goes for the use of a map. There isn't any harm with using it and then raise a question on an issue found.
Ideas would be greatly appreciated!
I think this is the main problem. Questions on Stack Overflow are not great for gathering ideas. You're more or less in the design phase and that requires a whiteboard and brainstorming. That is simply not covered here. Chat, Discord, and forums are better equipped to handle that.
This basically sums up why a question that is clear to you and where responses would have great value for you, isn't well received by the community. Idea generation and/or where-to-start type of questions aren't deemed a valuable addition to the body of knowledge we build here. This due to the broadness of such question, lack of one right answer and no lasting value for visitors to come.
Once you have code that compiles, but doesn't work as hoped, we're happy to take questions to help you get those specific programming issues fixed.