Implement out directory
This commit is contained in:
7
types.go
7
types.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -39,7 +40,7 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func (c *Class) GetOutFile() (*os.File, error) {
|
||||
func (c *Class) GetOutFile(root string) (*os.File, error) {
|
||||
if c.ClassName == "" {
|
||||
return nil, fmt.Errorf("ClassName is empty")
|
||||
}
|
||||
@@ -48,7 +49,9 @@ func (c *Class) GetOutFile() (*os.File, error) {
|
||||
filename = strings.ReplaceAll(filename, "-", "")
|
||||
filename = strings.ReplaceAll(filename, ",", "")
|
||||
filename = strings.ReplaceAll(filename, ":", "")
|
||||
f, err := os.Create(filename)
|
||||
filePath := filepath.Join(root, filename)
|
||||
filePath = filepath.Clean(filePath)
|
||||
f, err := os.Create(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user