@@ -10,19 +10,22 @@ import (
10
10
)
11
11
12
12
type HeaderConverter struct {
13
- targetProjectName string
14
- copyright string
15
- date time.Time
13
+ copyright Copyright
14
+ targetProjectName string
15
+ copyrightDefaultValue string
16
+ date time.Time
16
17
}
17
18
18
19
func NewHeaderConverter (
20
+ copyright Copyright ,
19
21
config * model.Config ,
20
22
date time.Time ) * HeaderConverter {
21
23
22
24
return & HeaderConverter {
23
- targetProjectName : config .TargetProjectName ,
24
- copyright : config .Copyright ,
25
- date : date ,
25
+ copyright : copyright ,
26
+ targetProjectName : config .TargetProjectName ,
27
+ copyrightDefaultValue : config .Copyright ,
28
+ date : date ,
26
29
}
27
30
}
28
31
@@ -34,12 +37,18 @@ func (header *HeaderConverter) Render(source string, sceneName string) string {
34
37
35
38
dateStr := fmt .Sprintf ("%d/%d/%d" , day , month , year )
36
39
40
+ copyright , err := header .copyright .Get ()
41
+
42
+ if err != nil {
43
+ copyright = header .copyrightDefaultValue
44
+ }
45
+
37
46
var replacedSource string = source
38
47
replacedSource = strings .ReplaceAll (replacedSource , "__SCENE_NAME__" , sceneName )
39
48
replacedSource = strings .ReplaceAll (replacedSource , "__TARGET_PROJECT_NAME__" , header .targetProjectName )
40
49
replacedSource = strings .ReplaceAll (replacedSource , "__DATE__" , dateStr )
41
50
replacedSource = strings .ReplaceAll (replacedSource , "__YEAR__" , strconv .Itoa (year ))
42
- replacedSource = strings .ReplaceAll (replacedSource , "__COPYRIGHT__" , header . copyright )
51
+ replacedSource = strings .ReplaceAll (replacedSource , "__COPYRIGHT__" , copyright )
43
52
44
53
return replacedSource
45
54
}
0 commit comments