Skip to content

Commit

Permalink
add main package to check use of module
Browse files Browse the repository at this point in the history
  • Loading branch information
CamJN committed Mar 1, 2024
1 parent 69988ab commit 056f65f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/main/main
2 changes: 2 additions & 0 deletions go.mod
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 => ./
32 changes: 32 additions & 0 deletions main/main.go
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
}
}

0 comments on commit 056f65f

Please sign in to comment.