Skip to content

Commit 9ac645a

Browse files
committed
update
1 parent 6603b3c commit 9ac645a

File tree

3 files changed

+32
-25
lines changed

3 files changed

+32
-25
lines changed

common/tplfunc.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
1717
*/
1818

19-
//Package common This package provides basic constants used by forms packages.
19+
// Package common This package provides basic constants used by forms packages.
2020
package common
2121

2222
import (
2323
"html/template"
24+
"io"
2425
"io/fs"
25-
"io/ioutil"
26+
"os"
2627
"path/filepath"
2728
)
2829

@@ -35,7 +36,7 @@ func ParseFiles(files ...string) (*template.Template, error) {
3536
return ParseFS(FileSystem, files...)
3637
}
3738
name := filepath.Base(files[0])
38-
b, err := ioutil.ReadFile(files[0])
39+
b, err := os.ReadFile(files[0])
3940
if err != nil {
4041
return nil, err
4142
}
@@ -56,7 +57,7 @@ func ParseFS(fs fs.FS, files ...string) (*template.Template, error) {
5657
if err != nil {
5758
return tmpl, err
5859
}
59-
b, err := ioutil.ReadAll(fp)
60+
b, err := io.ReadAll(fp)
6061
fp.Close()
6162
if err != nil {
6263
return tmpl, err

forms.go

+25-19
Original file line numberDiff line numberDiff line change
@@ -343,23 +343,29 @@ func (f *Form) GenChoicesForField(name string, lenType interface{}, fnType inter
343343
}
344344

345345
// GenChoices generate choices
346-
// type Data struct{
347-
// ID string
348-
// Name string
349-
// }
350-
// data:=[]*Data{
351-
// &Data{ID:"a",Name:"One"},
352-
// &Data{ID:"b",Name:"Two"},
353-
// }
354-
// GenChoices(len(data), func(index int) (string, string, bool){
355-
// return data[index].ID,data[index].Name,false
356-
// })
346+
//
347+
// type Data struct{
348+
// ID string
349+
// Name string
350+
// }
351+
//
352+
// data:=[]*Data{
353+
// &Data{ID:"a",Name:"One"},
354+
// &Data{ID:"b",Name:"Two"},
355+
// }
356+
//
357+
// GenChoices(len(data), func(index int) (string, string, bool){
358+
// return data[index].ID,data[index].Name,false
359+
// })
360+
//
357361
// or
358-
// GenChoices(map[string]int{
359-
// "":len(data),
360-
// }, func(group string,index int) (string, string, bool){
361-
// return data[index].ID,data[index].Name,false
362-
// })
362+
//
363+
// GenChoices(map[string]int{
364+
// "":len(data),
365+
// }, func(group string,index int) (string, string, bool){
366+
//
367+
// return data[index].ID,data[index].Name,false
368+
// })
363369
func (f *Form) GenChoices(lenType interface{}, fnType interface{}) interface{} {
364370
return GenChoices(lenType, fnType)
365371
}
@@ -396,9 +402,9 @@ func (form *Form) unWindStructure(m interface{}, baseName string) ([]interface{}
396402
options[opt] = struct{}{}
397403
}
398404
}
399-
}
400-
if _, ok := options["-"]; ok {
401-
continue
405+
if _, ok := options["-"]; ok {
406+
continue
407+
}
402408
}
403409
widget := common.TagVal(t, i, "form_widget")
404410
var f fields.FieldInterface

json.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package forms
1818
import (
1919
"encoding/json"
2020
"fmt"
21-
"io/ioutil"
2221
"net/url"
22+
"os"
2323
"path/filepath"
2424
"reflect"
2525
"strconv"
@@ -41,7 +41,7 @@ func UnmarshalFile(filename string) (r *config.Config, err error) {
4141
return
4242
}
4343
return common.GetOrSetCachedConfig(filename, func() (*config.Config, error) {
44-
b, err := ioutil.ReadFile(filename)
44+
b, err := os.ReadFile(filename)
4545
if err != nil {
4646
return nil, err
4747
}

0 commit comments

Comments
 (0)