I have a Go project and I don’t know how to make it work. I want my program to create new gifs with 3 types of sorting.
Link to the git repo: https://github.com/bareyowsky/Algorithms-Visualisation
Can anyone tell me what I’m doing wrong?
Hi @barejs what exactly doesn’t work?
When I type:
go run main.go
it doesn’t work and shows that function newGIF is undefined (though I have imported the package it is).
Not sure if this is relevant, but if I try to go get
your project, I get this output:
PS C:\Users\skillian> go get github.com/bareyowsky/Algorithms-Visualisation
go: downloading github.com/bareyowsky/Algorithms-Visualisation v0.0.0-20210614080206-eabc2e49d8f5
go get: github.com/bareyowsky/Algorithms-Visualisation@none updating to
github.com/bareyowsky/Algorithms-Visualisation@v0.0.0-20210614080206-eabc2e49d8f5: parsing go.mod:
module declares its path as: github.com/bareyowsky/Algoritms-Visualisation
but was required as: github.com/bareyowsky/Algorithms-Visualisation
How do I correct that?
I’m running your project with go run .
and everything works
EDIT:
Thats because by go run main.go
you’re running only main.go
file, but this file uses newGIF
function, which is declared in gif.go
so you need to run main package, not file containing main.go
yah, because name of the repo is Algorithms-Visualisation
but module name in go.mod is Algoritms-Visualisation
. @barejs needs to change a name of module in go.mod (or a name of repository)
Thanks, I changed the module names, my program launches, but I doesn’t do what I want.
I get the following status.
Why my program returns error from ‘‘isexist’’?
It’s from this condition:
I made this change (added line 54):
and then it works, it generates selection.gif and there is my sort gif in the folder. But how can I make the user pick the sortName from flags instead of line 54 of my code?
You can add a check at the beginning of main
to see if sortName == ""
which tells you the user did not provide a sort name.
But how do I get sortName from user?
It looks like you’re already getting it as a flag: https://github.com/bareyowsky/Algorithms-Visualisation/blob/eabc2e49d8f5ee0d7163ba68892bd97edbbace71/main.go#L43
EDIT: Are you saying that even when you provide the sortName, it’s not working?
It kind of works when I input sortName in main.go
I mean that you have a “-sorting” flag that you should be able to specify on the command line and that will set the sortName
.
Okay, I specified --sorting flag and it works. Thanks!
One more question, does my program run the algorithms from my “sort” folder?
It appears to I haven’t debugged it to see how that works, but It looks like you’re registering the functions from your
sort
package and then after getting them out of the map, passing them to newGIF
and then use them. You could trace the execution of your program to see if the functions are indeed being called. If you need help with that, I recommend starting a new question.
I’m going to do just as you told me! Thank you very much Sir!