mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-06 21:37:47 +02:00
refactor: output browsing data package
This commit is contained in:
@@ -13,13 +13,13 @@ import (
|
||||
"hack-browser-data/internal/browingdata"
|
||||
)
|
||||
|
||||
type outPutter struct {
|
||||
type OutPutter struct {
|
||||
json bool
|
||||
csv bool
|
||||
}
|
||||
|
||||
func New(flag string) *outPutter {
|
||||
o := &outPutter{}
|
||||
func New(flag string) *OutPutter {
|
||||
o := &OutPutter{}
|
||||
if flag == "json" {
|
||||
o.json = true
|
||||
} else {
|
||||
@@ -28,7 +28,7 @@ func New(flag string) *outPutter {
|
||||
return o
|
||||
}
|
||||
|
||||
func (o *outPutter) Write(data browingdata.Source, writer io.Writer) error {
|
||||
func (o *OutPutter) Write(data browingdata.Source, writer io.Writer) error {
|
||||
switch o.json {
|
||||
case true:
|
||||
encoder := jsoniter.NewEncoder(writer)
|
||||
@@ -45,7 +45,7 @@ func (o *outPutter) Write(data browingdata.Source, writer io.Writer) error {
|
||||
}
|
||||
}
|
||||
|
||||
func (o *outPutter) CreateFile(dir, filename string) (*os.File, error) {
|
||||
func (o *OutPutter) CreateFile(dir, filename string) (*os.File, error) {
|
||||
if filename == "" {
|
||||
return nil, errors.New("empty filename")
|
||||
}
|
||||
@@ -68,3 +68,11 @@ func (o *outPutter) CreateFile(dir, filename string) (*os.File, error) {
|
||||
}
|
||||
return file, nil
|
||||
}
|
||||
|
||||
func (o *OutPutter) Ext() string {
|
||||
if o.json {
|
||||
return ".json"
|
||||
} else {
|
||||
return ".csv"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user