-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add main package to check use of module
- Loading branch information
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/main/main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
module github.com/getargv/getargv.go | ||
|
||
go 1.22.0 | ||
|
||
replace github.com/getargv/getargv.go => ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/binary" | ||
"flag" | ||
"fmt" | ||
"os" | ||
"strconv" | ||
"github.com/getargv/getargv.go" | ||
) | ||
|
||
func main() { | ||
var skip = flag.Uint("s", 0, "number of leading args to skip") | ||
var nuls = flag.Bool("0", false, "convert nuls to spaces") | ||
flag.Parse() | ||
if (flag.NArg() != 1) { | ||
fmt.Println("a single pid must be provided as an argument") | ||
return | ||
} | ||
var err error | ||
pid, err := strconv.ParseUint(flag.Arg(0), 10, 32) | ||
if err != nil { | ||
fmt.Println("binary.Write failed:", err) | ||
return | ||
} | ||
byts, err := getargv.AsBytes(uint(pid), *skip, *nuls) | ||
err = binary.Write(os.Stdout, binary.NativeEndian, byts) | ||
if err != nil { | ||
fmt.Println("binary.Write failed:", err) | ||
return | ||
} | ||
} |