ref: d50596a489b51df5603567e2784b2be6b32239c3
parent: 788f634a3cedef5d5ebc82860976320ad3584cbf
author: Philip Silva <philip.silva@protonmail.com>
date: Sat Oct 16 08:33:26 EDT 2021
add filecon util
--- /dev/null
+++ b/filecon/filecon.go
@@ -1,0 +1,33 @@
+package main
+
+import (
+ "bufio"
+ "fmt"
+ "log"
+ "os"
+)
+
+func main() {
+ fn := os.Args[1]
+ log.Printf("opening %v...", fn)
+ f, err := os.OpenFile(fn, os.O_RDWR|os.O_CREATE, 0666)
+ if err != nil {
+ log.Fatalf("%v", err)
+ }
+ defer f.Close()
+ r := bufio.NewReader(f)
+ rr := bufio.NewReader(os.Stdin)
+ for {
+ l, err := rr.ReadString('\n')
+ if err != nil {
+ log.Fatalf("%v", err)
+ }
+ log.Printf("send '%v'\n", l)
+ fmt.Fprintf(f, "%v\n", l)
+ l, err = r.ReadString('\n')
+ if err != nil {
+ log.Fatalf("%v", err)
+ }
+ log.Printf("filecon: received '%v'.", l)
+ }
+}
--- /dev/null
+++ b/filecon/go.mod
@@ -1,0 +1,3 @@
+module filecon
+
+go 1.17