Skip to content

Instantly share code, notes, and snippets.

@dele454
Last active August 6, 2022 03:32
Show Gist options
  • Save dele454/f58061d5a7983fc83ff61b13cd04ec85 to your computer and use it in GitHub Desktop.
Save dele454/f58061d5a7983fc83ff61b13cd04ec85 to your computer and use it in GitHub Desktop.
Part 1 - CSV Transformation
package main
import (
"flag"
"os"
"github.com/dele454/medium/csv-transform-to-html/cmd"
"github.com/dele454/medium/csv-transform-to-html/internal/errs"
)
func main() {
var file string
// accept arg from stdin
flag.StringVar(&file, "f", "", "Full path to source file for processing.")
flag.Parse()
// display usage if no arg is passed
if len(os.Args[1:]) == 0 {
flag.PrintDefaults()
return
}
// get file's info
f, err := os.Stat(file)
if err != nil {
panic(err)
}
// check its a file
if f.IsDir() {
panic(errs.ErrorArgsDirSpecified)
}
// kickoff the process
cmd.Process(file)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment