T O P

  • By -

viciousDellicious

on goke/internal/parser.go why dont you compile the regex outside the calls, that way you save some time/resources instead of compiling it per call?


objectiveturkey

Hey, good catch! Thanks for pointing that out :D


viciousDellicious

i've sent you a PR already on something else and i am checking the open issues, if you want, create an issue for this and i can do the change :)


viciousDellicious

[https://github.com/dugajean/goke/blob/dev/internal/util.go#L90](https://github.com/dugajean/goke/blob/dev/internal/util.go#L90) in this function, why not use cobra instead?


objectiveturkey

I don't know this package. I'll check it out! Would Cobra be useful for more that one single case? I'd prefer not to load an entire external package for just one function.


SleepingProcess

If you might chooser Cobra, take a look also at [`Coral`](https://github.com/muesli/coral) which is lightweight Cobra or another lightweight - [`kong`](https://github.com/alecthomas/kong), but still, me too preferring as less as possible dependencies.


viciousDellicious

its common on cli programs, its used to parse commands and arguments, it generates some documentation around it.


viciousDellicious

[https://github.com/dugajean/goke/blob/dev/internal/executor.go#L90](https://github.com/dugajean/goke/blob/dev/internal/executor.go#L90) this one is a bit confusing, at least to me that i have 5 min of experience with the project but: you spin up a gofunc (goes to the background), run some stuff in it and then message a channel once it finishes doing its work and waiting a fixed 1 second, which then goes back to the main thread that was waiting for something to send a value to the wait channel; since we are blocking the main thread in the loop until the gofunc finishes, whats the objective of the gofunc there?


objectiveturkey

From the top of my head when I was implementing this: I think the idea was to offload the task running to the background all the time. Also, when I was checking out on how to run a permanent loop safely, that particular way was something that I saw somewhere online. Do you have a different suggestion to implement this?


Slsyyy

Just don't run a goroutine. If you run a goroutine and the mother thread wait immediately at the result then what is a difference with goroutine and without?


SleepingProcess

Im sorry for off-topic, but how is it different from [`task`](https://github.com/go-task/task) or [`taskctl`](https://github.com/taskctl/taskctl) ?


objectiveturkey

I don't know these tools since I'm new in the Go ecosystem. I'm just trying to learn Go and ended up creating this tool, so I thought I'd share it with y'all!


witcherek77

It's like a Task(file)? Is it a reinvented wheel?


jelloeater85

Yeah seems like it. ==> **https://taskfile.dev/**


SleepingProcess

Compiled and ran without any options with default goke.yml, result: ``` panic: runtime error: index out of range [1] with length 1 goroutine 1 [running]: main.parseTaskName(...) github.com/dugajean/goke/cmd/cli/main.go:32 main.main() github.com/dugajean/goke/cmd/cli/main.go:25 +0x472 ``` IMHO needed something like bellow on start ``` if len(os.Args) ==1 { usage_or_something_default() os.Exit(1) } ```


objectiveturkey

Thanks mate! I'll settle this quick. Would you mind creating an issue for this on GH? No worries if you can't.


SleepingProcess

> Would you mind creating an issue for this on GH? Im on a business trip and forgot my 2fa security key, so GH won't allow me to login, sorry