aboutsummaryrefslogtreecommitdiff
path: root/nvdmirror/util.go
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2022-02-23 22:13:21 -0500
committerPaul Duncan <pabs@pablotron.org>2022-02-23 22:13:21 -0500
commitc83d762a75aebaf075bfc454e3d0485b1fe1e4c9 (patch)
tree2c17b1128051544a13cb1cdea7b09b1d5b14bdf3 /nvdmirror/util.go
parentaad9d14bd0c7ee01e058908de29a6319668ffae5 (diff)
downloadcvez-c83d762a75aebaf075bfc454e3d0485b1fe1e4c9.tar.bz2
cvez-c83d762a75aebaf075bfc454e3d0485b1fe1e4c9.zip
nvdmirror: add nvdmirror/util.go
Diffstat (limited to 'nvdmirror/util.go')
-rw-r--r--nvdmirror/util.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/nvdmirror/util.go b/nvdmirror/util.go
new file mode 100644
index 0000000..9cf7d3a
--- /dev/null
+++ b/nvdmirror/util.go
@@ -0,0 +1,29 @@
+package nvdmirror
+
+import (
+ "github.com/rs/zerolog"
+ "github.com/rs/zerolog/log"
+ "os"
+)
+
+// Get file size, in bytes.
+func getFileSize(path string) (uint64, error) {
+ // verify that full path exists
+ if st, err := os.Stat(path); err != nil {
+ return 0, err
+ } else {
+ return uint64(st.Size()), err
+ }
+}
+
+// log array of strings
+func logArray(key string, strs []string) {
+ // populate array
+ a := zerolog.Arr()
+ for _, v := range(strs) {
+ a.Str(v)
+ }
+
+ // log array
+ log.Info().Array(key, a).Send()
+}