Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create folder, delete folder and list folder contents ? #196

Open
gedw99 opened this issue Dec 8, 2023 · 4 comments
Open

How to create folder, delete folder and list folder contents ? #196

gedw99 opened this issue Dec 8, 2023 · 4 comments

Comments

@gedw99
Copy link
Contributor

gedw99 commented Dec 8, 2023

anyone know the commands for managing directories ? I see examples using files but nothing for Directories.

I need the cross platform equivalent of these linux commands so they work on Windows, Mac and Linux.

mkdir -p "folder path" to create and not error if already there.
rm -rf "folder path" to delete it and everything inside.
ls -al "folder path" to list everything inside.

thanks in advance @bitfield !!

@bitfield
Copy link
Owner

bitfield commented Dec 8, 2023

@gedw99, you can use the standard library's os package for these:

In addition, script has the ListFiles and FindFiles methods for doing some operation on your specified files.

I hope this helps!

@gedw99
Copy link
Contributor Author

gedw99 commented Dec 9, 2023

ah bummer. I wanted to use script as a cli to do all this from a makefile file with no golang code.

just install script and then call it as a cli.

@bitfield
Copy link
Owner

bitfield commented Dec 9, 2023

Maybe something like this is what you're looking for? https://til.simonwillison.net/bash/go-script

@gedw99
Copy link
Contributor Author

gedw99 commented Dec 9, 2023

Ah . Yes I could write a tiny bit o golang around an import of script and just go run . It .
That will do the trick.

I need it to augment this make file

https://github.com/dawenxi-tech/2fa/blob/main/Makefile

just create and delete and list folder contents to allow the build and packaging make tergets to do their thing.

the makefile is used locally and in ci . Single source of truth instead of complex GitHub actions . Simple dimple stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants