-
Notifications
You must be signed in to change notification settings - Fork 225
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
CLI example in a single commit #32
base: master
Are you sure you want to change the base?
Conversation
Sorry if sidetracking.
Is this check suggested for users of this library? I have been relying on |
in BSD gpio mapped to a different place (as far as i understand to |
b7cb3fb
to
418411f
Compare
} | ||
} else { | ||
switch *set { | ||
case 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If *set
is String and not Int, you can check for multiple choices, eg.: case: "0", "L", "low":
and case: "1", "H", "high":
pinNumber = flag.Int("p", 0, " number of pin to use") | ||
high = flag.Bool("h", false, " return 0 if value is HIGH, omit to set value") | ||
low = flag.Bool("l", false, " return 0 if value is LOW, omit to set value") | ||
set = flag.Int("s", 0, " set pin value to high(1) or low(-1)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make more sense to name this option v as value instead of s as set.
Also use 0 for low value makes more sense to me, than -1.
You can parse this as String
instead of Int
, to avoid issue with third unset value (empty string).
flag.Parse() | ||
|
||
if os.Geteuid() != 0 { | ||
fmt.Println("This program have to be run as root, or SUID/GUID set to 0 on execution!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It actually does not have to be run as root, if /dev/gpiomem
exists.
} | ||
|
||
if runtime.GOARCH != "arm" { | ||
fmt.Println("This program can be unpredictable on other machines rather than Raspberry Pi") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other machines
ratherthan Raspberry Pi
;)
Just a replacement for PR #5 in a single commit