https://github.com/lylemi/passerby
Passerby is a package for hide command-line arguments for Golang program with oneline
https://github.com/lylemi/passerby
Last synced: 5 days ago
JSON representation
Passerby is a package for hide command-line arguments for Golang program with oneline
- Host: GitHub
- URL: https://github.com/lylemi/passerby
- Owner: LyleMi
- License: mit
- Created: 2024-01-15T03:45:31.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-15T03:46:53.000Z (over 2 years ago)
- Last Synced: 2024-06-21T19:56:55.899Z (about 2 years ago)
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Passerby
Passerby is a package for hide command-line arguments for Golang program.
## Features
- Hide command-line arguments from an environment variable
- Delete a file after a specified duration
## Usage
### Hooking command-line arguments
To hook command-line arguments, simply import package in your code:
```golang
import (
_ "github.com/lylemi/passerby"
)
```
The package will then read the ARG environment variable, split it by spaces, and append it to os.Args.
### Deleting a file after a duration
To delete a config file after a specified duration, call DeleteFileAfterDuration(filePath string):
```golang
import "github.com/lylemi/passerby"
func main() {
passerby.DeleteFileAfterDuration("path/to/your/file.txt")
// Your code here
}
```
By default, the file will be deleted after 60 seconds. To change the duration, set the DELETE_DURATION environment variable to a valid Go duration string (e.g., "30s" for 30 seconds, "1m" for 1 minute, etc.).
## Example
see example dir
```bash
export ARG='-name real_passed_name'
./cmdline --fake-arg fake_passed
```
```bash
export ARG='-file config.json'
export DELETE_DURATION=0
./configfile --fake-arg fake_passed
```
## Contribution
If you have any ideas or suggestions, please feel free to submit a pull request. We appreciate any contributions.
## Contact
If you have any questions or suggestions, please feel free to contact us.