Fastly execute scripts/remove initial delay?

Hey, first of all I’d want to say that I’m very new to this language. I came to use this language to use an trading API, which I’ve gotten to work and functions nicely. However, the GoLang script takes a long time (2-3 seconds) to execute, which is a big problem for me as it’s a long time in regards of trading, hindering me from being one of the first buyers/sellers when trading.

I did some testing and managed to check how many milliseconds my calls were taking, which was very fast and wasn’t the problem for the long script execution time. The problem is for the script to actually start, after I call the script to run such as with “go run C:\Go\GoCode\api\src\main\test.go” in CMD, the first print message (which is the first line in main) takes 2-3 seconds to show up.

The initial delay/start time wouldn’t be a problem if all my code was written in GoLang I assume, however my main application is Java, which I use to start these GoLang scripts, hence why the initial script start delay is a problem when trading.

So is there anything I can do to solve this initial delay, so the start time is less than 50 ms instead of over 2000 ms? Thanks in advance for any help :slight_smile:

Go is not a scripting language. Your “go run” command loads the compiler, compiles your program, then runs it and discards the compiled binary.

Instead, “go install” your program and then run it.

Better yet, keep it running and let it react to events some way while running - using an HTTP API or whatever is convenient.

3 Likes

That makes sense and also solved it. Thank you very much for your help :smiley:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.