@@ -219,7 +219,7 @@ func TestNewHeader(t *testing.T) {
219219 header : HeaderOpts {
220220 Template : "{{.project}} by {{.person}}" ,
221221 Author : "test" ,
222- Variables : map [string ]Var {
222+ Variables : map [string ]* Var {
223223 "project" : {Value : "project" },
224224 "person" : {Value : "person" },
225225 },
@@ -230,7 +230,7 @@ func TestNewHeader(t *testing.T) {
230230 header : HeaderOpts {
231231 Template : "{{.project}} by {{.person}}" ,
232232 Author : "test" ,
233- Variables : map [string ]Var {
233+ Variables : map [string ]* Var {
234234 "project" : {Value : "project" , Regexp : "(golicenser|project)" },
235235 "person" : {Value : "human" , Regexp : "(human|person)" },
236236 },
@@ -241,7 +241,7 @@ func TestNewHeader(t *testing.T) {
241241 header : HeaderOpts {
242242 Template : "{{.project}} by {{.person}}" ,
243243 Author : "test" ,
244- Variables : map [string ]Var {
244+ Variables : map [string ]* Var {
245245 "project" : {Value : "project" , Regexp : "(project" },
246246 "person" : {Value : "person" , Regexp : "person)" },
247247 },
@@ -341,7 +341,7 @@ func TestHeaderCreate(t *testing.T) {
341341 header : HeaderOpts {
342342 Template : "{{.project}} by {{.person}}" ,
343343 Author : "test" ,
344- Variables : map [string ]Var {
344+ Variables : map [string ]* Var {
345345 "project" : {Value : "project" },
346346 "person" : {Value : "person" },
347347 },
@@ -353,7 +353,7 @@ func TestHeaderCreate(t *testing.T) {
353353 header : HeaderOpts {
354354 Template : "{{.project}} by {{.person}}" ,
355355 Author : "test" ,
356- Variables : map [string ]Var {
356+ Variables : map [string ]* Var {
357357 "project" : {Value : "project" , Regexp : "(golicenser|project)" },
358358 "person" : {Value : "human" , Regexp : "(human|person)" },
359359 },
@@ -460,6 +460,35 @@ func TestHeaderUpdate(t *testing.T) {
460460 want : "// Copyright (c) 2025 Joshua Sing\n " ,
461461 wantModified : true ,
462462 },
463+ {
464+ name : "custom variables" ,
465+ header : HeaderOpts {
466+ Template : "Copyright (c) {{.year}} {{.author}}\n Project: {{.project}}, Greet: {{.greet}}" ,
467+ Author : "Joshua Sing" ,
468+ YearMode : YearModeThisYear ,
469+ Variables : map [string ]* Var {
470+ "project" : {Value : "project" },
471+ "greet" : {Value : "Hello world" },
472+ },
473+ },
474+ existing : "// Copyright (c) 2024 Joshua Sing\n // Project: project, Greet: Hello world" ,
475+ want : "// Copyright (c) 2025 Joshua Sing\n // Project: project, Greet: Hello world\n " ,
476+ wantModified : true ,
477+ },
478+ {
479+ name : "custom variables with regexp" ,
480+ header : HeaderOpts {
481+ Template : "Copyright (c) {{.year}} {{.author}}\n Project: {{.project}}, Greet: {{.greet}}" ,
482+ Author : "Joshua Sing" ,
483+ Variables : map [string ]* Var {
484+ "project" : {Value : "project" },
485+ "greet" : {Value : "Hello world" , Regexp : "Hello (.+)" },
486+ },
487+ },
488+ existing : "// Copyright (c) 2025 Joshua Sing\n // Project: project, Greet: Hello there!" ,
489+ want : "// Copyright (c) 2025 Joshua Sing\n // Project: project, Greet: Hello world\n " ,
490+ wantModified : true ,
491+ },
463492 {
464493 name : "change MIT to OpenBSD" ,
465494 header : HeaderOpts {
@@ -537,7 +566,7 @@ func TestHeaderMatcher(t *testing.T) {
537566 name string
538567 matcher string
539568 escape bool
540- variables map [string ]Var
569+ variables map [string ]* Var
541570 authorRegexp * regexp.Regexp
542571 wantErr bool
543572 matchTests []matchTest
@@ -574,7 +603,7 @@ func TestHeaderMatcher(t *testing.T) {
574603 name : "custom variables" ,
575604 matcher : "{{.project}} by {{.name}} - Copyright (c) {{.year}} {{.author}}" ,
576605 escape : true ,
577- variables : map [string ]Var {
606+ variables : map [string ]* Var {
578607 "project" : {Value : "golicenser" , Regexp : "golicenser" },
579608 "name" : {Value : "joshuasing" , Regexp : "joshuasing" },
580609 },
@@ -596,7 +625,7 @@ func TestHeaderMatcher(t *testing.T) {
596625 name : "custom variables with regexp" ,
597626 matcher : "{{.project}} by {{.name}} - Copyright (c) {{.year}} {{.author}}" ,
598627 escape : true ,
599- variables : map [string ]Var {
628+ variables : map [string ]* Var {
600629 "project" : {Value : "golicenser" , Regexp : "go-?licenser" },
601630 "name" : {Value : "joshuasing" , Regexp : "(joshuasing|someone)" },
602631 },
0 commit comments