@@ -60,40 +60,40 @@ type Stanza struct {
60
60
}
61
61
62
62
// GetInput implements input.File
63
- func (g * GopkgToml ) GetInput () (input.Input , error ) {
64
- if g .Path == "" {
65
- g .Path = "Gopkg.toml"
63
+ func (f * GopkgToml ) GetInput () (input.Input , error ) {
64
+ if f .Path == "" {
65
+ f .Path = "Gopkg.toml"
66
66
}
67
- if g .ManagedHeader == "" {
68
- g .ManagedHeader = DefaultGopkgHeader
67
+ if f .ManagedHeader == "" {
68
+ f .ManagedHeader = DefaultGopkgHeader
69
69
}
70
70
71
71
// Set the user content to be used if the Gopkg.toml doesn't exist
72
- if g .DefaultUserContent == "" {
73
- g .DefaultUserContent = DefaultGopkgUserContent
72
+ if f .DefaultUserContent == "" {
73
+ f .DefaultUserContent = DefaultGopkgUserContent
74
74
}
75
75
76
76
// Set the user owned content from the last Gopkg.toml file - e.g. everything before the header
77
- lastBytes , err := ioutil .ReadFile (g .Path )
77
+ lastBytes , err := ioutil .ReadFile (f .Path )
78
78
if err != nil {
79
- g .UserContent = g .DefaultUserContent
80
- } else if g .UserContent , err = g .getUserContent (lastBytes ); err != nil {
79
+ f .UserContent = f .DefaultUserContent
80
+ } else if f .UserContent , err = f .getUserContent (lastBytes ); err != nil {
81
81
return input.Input {}, err
82
82
}
83
83
84
- g .Input .IfExistsAction = input .Overwrite
85
- g .TemplateBody = depTemplate
86
- return g .Input , nil
84
+ f .Input .IfExistsAction = input .Overwrite
85
+ f .TemplateBody = depTemplate
86
+ return f .Input , nil
87
87
}
88
88
89
- func (g * GopkgToml ) getUserContent (b []byte ) (string , error ) {
89
+ func (f * GopkgToml ) getUserContent (b []byte ) (string , error ) {
90
90
// Keep the users lines
91
91
scanner := bufio .NewScanner (bytes .NewReader (b ))
92
92
userLines := []string {}
93
93
found := false
94
94
for scanner .Scan () {
95
95
l := scanner .Text ()
96
- if l == g .ManagedHeader {
96
+ if l == f .ManagedHeader {
97
97
found = true
98
98
break
99
99
}
0 commit comments