File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -159,12 +159,12 @@ func (question questionType) PackageName() string {
159
159
func (question questionType ) SaveCodeSnippet () {
160
160
for _ , code := range question .CodeSnippets {
161
161
if code .LangSlug == "golang" {
162
- file := question .getFilePath (question .TitleSnake () + ".go" )
162
+ filePath := question .getFilePath (question .TitleSnake () + ".go" )
163
163
var buf bytes.Buffer
164
164
buf .WriteString (fmt .Sprintf ("package %s\n \n " , question .PackageName ()))
165
165
buf .WriteString (code .Code )
166
166
buf .WriteString ("\n " )
167
- filePutContents (file , buf .Bytes ())
167
+ filePutContents (filePath , buf .Bytes ())
168
168
buf .Reset ()
169
169
// match function name
170
170
reg := regexp .MustCompile (`func (\w+?)\(` )
@@ -179,6 +179,9 @@ func (question questionType) SaveCodeSnippet() {
179
179
"{{funcName}}" , strings .Title (funcName ),
180
180
).Replace (testTpl ))
181
181
filePutContents (fileTest , buf .Bytes ())
182
+ } else if len (question .CodeSnippets ) == 1 {
183
+ filePath := question .getFilePath (question .TitleSnake () + "." + code .LangSlug )
184
+ filePutContents (filePath , []byte (code .Code ))
182
185
}
183
186
}
184
187
}
You can’t perform that action at this time.
0 commit comments