@@ -10,19 +10,22 @@ import (
1010)
1111
1212type 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
1617}
1718
1819func NewHeaderConverter (
20+ copyright Copyright ,
1921 config * model.Config ,
2022 date time.Time ) * HeaderConverter {
2123
2224 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 ,
2629 }
2730}
2831
@@ -34,12 +37,18 @@ func (header *HeaderConverter) Render(source string, sceneName string) string {
3437
3538 dateStr := fmt .Sprintf ("%d/%d/%d" , day , month , year )
3639
40+ copyright , err := header .copyright .Get ()
41+
42+ if err != nil {
43+ copyright = header .copyrightDefaultValue
44+ }
45+
3746 var replacedSource string = source
3847 replacedSource = strings .ReplaceAll (replacedSource , "__SCENE_NAME__" , sceneName )
3948 replacedSource = strings .ReplaceAll (replacedSource , "__TARGET_PROJECT_NAME__" , header .targetProjectName )
4049 replacedSource = strings .ReplaceAll (replacedSource , "__DATE__" , dateStr )
4150 replacedSource = strings .ReplaceAll (replacedSource , "__YEAR__" , strconv .Itoa (year ))
42- replacedSource = strings .ReplaceAll (replacedSource , "__COPYRIGHT__" , header . copyright )
51+ replacedSource = strings .ReplaceAll (replacedSource , "__COPYRIGHT__" , copyright )
4352
4453 return replacedSource
4554}
0 commit comments