diff --git a/cmd/generate-std-packages/main.go b/cmd/generate-std-packages/main.go index 43a28154..3c9edc18 100644 --- a/cmd/generate-std-packages/main.go +++ b/cmd/generate-std-packages/main.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "fmt" "go/importer" "go/types" @@ -9,56 +8,32 @@ import ( "log" "reflect" "strings" - "text/template" ) -func parseTmpl(tmpl string, data map[string]interface{}) ([]byte, error) { - parsedTmpl, err := template.New("tmpl").Parse(tmpl) - if err != nil { - return nil, err - } - - var result bytes.Buffer - if err := parsedTmpl.Execute(&result, data); err != nil { - return nil, err - } - - return result.Bytes(), nil +type pkgFuncType struct { + PkgName string `json:"pkg_name"` + FuncTypeName string `json:"func_type_name"` + Expr string `json:"expr"` } -func generatePackageImportCode18(pkgImportName string) ([]byte, error) { - var pkgTmpl = `package packages - -import ( - {{.import_packages}} -) - -{{.extra}} - -func init() { - {{.package_no_struct_types}} - Packages["{{.name}}"] = map[string]interface{}{ -{{.package_funcs}} - } - PackageTypes["{{.name}}"] = map[string]interface{}{ -{{.package_types}} - } -{{.import_multi_version_call}} -} -` +func dealPackageScope(pkgImportName string, goVersion version) ([]pkgFuncType, []pkgFuncType, []string) { pkg, err := importer.Default().Import(pkgImportName) if err != nil { - return nil, err + log.Fatal(err) } - var scope = pkg.Scope() - var funcOrVars []string - var typs []string + var notTypes []pkgFuncType + var typeAssigns []pkgFuncType var typeVars []string - var importPackages []string + var scope = pkg.Scope() for _, name := range scope.Names() { - if include(pkgImportName, name, black) || include(pkgImportName, name, in19) || include(pkgImportName, name, in110) { + if include(pkgImportName, name, black) { + continue + } + if goVersion.isGeneral() && (include(pkgImportName, name, in19) || include(pkgImportName, name, in110)) { + continue + } else if (goVersion.is19() && !include(pkgImportName, name, in19)) || (goVersion.is110() && !include(pkgImportName, name, in110)) { continue } @@ -71,179 +46,93 @@ func init() { varName = varName + "_" } typeVars = append(typeVars, fmt.Sprintf(` var %s %s.%s`, varName, getpackageTailName(pkgImportName), name)) - typs = append(typs, fmt.Sprintf(` "%s": reflect.TypeOf(&%s).Elem(),`, name, varName)) + typeAssigns = append(typeAssigns, pkgFuncType{pkgImportName, name, fmt.Sprintf(`reflect.TypeOf(&%s).Elem()`, varName)}) default: - funcOrVars = append(funcOrVars, fmt.Sprintf(` "%s": %s.%s,`, name, getpackageTailName(pkgImportName), name)) + notTypes = append(notTypes, pkgFuncType{pkgImportName, name, getConvertedName(pkgImportName, name)}) } } } + return notTypes, typeAssigns, typeVars +} + +func dealExtra(pkgImportName string, goVersion version) (string, []pkgFuncType, []pkgFuncType) { var extraDetail string + var notTypes []pkgFuncType + var typeAssigns []pkgFuncType + if extra, ok := extraList[pkgImportName]; ok { - extraDetail = extra.detail - if extra.packageImport != nil { - for _, v := range extra.packageImport { - funcOrVars = append(funcOrVars, fmt.Sprintf(` "%s": "%s",`, v.k, v.v)) + if goVersion.isGeneral() { + extraDetail = extra.detail + if extra.packageImport != nil { + for _, v := range extra.packageImport { + notTypes = append(notTypes, pkgFuncType{pkgImportName, v.k, v.v}) + } + } + if extra.packageTypesImport != nil { + for _, v := range extra.packageTypesImport { + typeAssigns = append(typeAssigns, pkgFuncType{pkgImportName, v.k, v.v}) + } } } - if extra.packageTypesImport != nil { - for _, v := range extra.packageTypesImport { - typs = append(typs, fmt.Sprintf(` "%s": %s,`, v.k, v.v)) + if goVersion.is18() { + extraDetail = extra.detail + if extra.packageImport != nil { + for _, v := range extra.packageImport { + notTypes = append(notTypes, pkgFuncType{pkgImportName, v.k, v.v}) + } + } + if extra.packageTypesImport != nil { + for _, v := range extra.packageTypesImport { + typeAssigns = append(typeAssigns, pkgFuncType{pkgImportName, v.k, v.v}) + } } } - } else { - pkgTmpl = strings.Replace(pkgTmpl, "{{.extra}}", "", -1) + } - importPackages = append(importPackages, fmt.Sprintf(`"%s"`, pkgImportName)) + return extraDetail, notTypes, typeAssigns +} + +func generatePackageImportCodeAll(pkgImportName string, goVersion version) ([]byte, error) { + notTypes, typeAssigns, typeVars := dealPackageScope(pkgImportName, goVersion) + extraDetail, notTypes2, typeAssigns2 := dealExtra(pkgImportName, goVersion) + + notTypes = append(notTypes, notTypes2...) + typeAssigns = append(typeAssigns, typeAssigns2...) + + var importPackages = []string{fmt.Sprintf(`"%s"`, pkgImportName)} if len(typeVars) > 0 { importPackages = append(importPackages, `"reflect"`) - } else { - pkgTmpl = strings.Replace(pkgTmpl, "{{.package_no_struct_types}}\n", "", -1) - } - - if len(typs) == 0 { - pkgTmpl = strings.Replace(pkgTmpl, "\n PackageTypes[\"{{.name}}\"] = map[string]interface{}{\n{{.package_type}}\n }", "", -1) } var importMultiVersionCall string - if v, ok := ruleList[pkgImportName]; ok && (v.in19 != nil || v.in110 != nil) { + if v, ok := ruleList[pkgImportName]; ok && goVersion.isGeneral() && (v.in19 != nil || v.in110 != nil) { importMultiVersionCall += getPackageInitName(pkgImportName) + "()\n" - build := "// +build go1.8" - if v.in19 != nil { - build += ",!go1.9,!go1.10" - } else if v.in110 != nil { - build += ",!go1.10" - } - if err = ioutil.WriteFile(go18.filename(pkgImportName), []byte(build+"\n\npackage packages\n\nfunc "+getPackageInitName(pkgImportName)+"() { }\n"), 0644); err != nil { - log.Fatal(err) - } - } else { - pkgTmpl = strings.Replace(pkgTmpl, "{{.import_multi_version_call}}", "", -1) + } + + var pkgTmpl = pkgExtraTmpl + if goVersion == gogo { + pkgTmpl = pkgNormalTmpl } return parseTmpl(pkgTmpl, map[string]interface{}{ + "build_tag": goVersion.buildTag(), "name": pkgImportName, - "package_funcs": strings.Join(funcOrVars, "\n"), - "package_types": strings.Join(typs, "\n"), + "package_funcs": notTypes, + "package_types": typeAssigns, "package_no_struct_types": strings.Join(typeVars, "\n"), "import_packages": strings.Join(importPackages, "\n"), "extra": extraDetail, + "import_func_name": getPackageInitName(pkgImportName), "import_multi_version_call": importMultiVersionCall, }) } -func generatePackageImportCode18Plus(pkgImportName string, goVersion version) ([]byte, error) { - var pkgTmpl = ` -{{.build_tag}} - -package packages - -import ( - {{.import_packages}} -) - -{{.extra}} - -func {{.import_func_name}}() { - {{.package_no_struct_types}} -{{range $index, $element := .package_funcs}} -Packages["{{.PkgName}}"]["{{.FuncTypeName}}"] = {{.Expr}} -{{end}} -{{range $index, $element := .package_types}} -PackageTypes["{{.PkgName}}"]["{{.FuncTypeName}}"] = {{.Expr}} -{{end}} -} -` - - type pkgFuncType struct { - PkgName string `json:"pkg_name"` - FuncTypeName string `json:"func_type_name"` - Expr string `json:"expr"` - } - pkg, err := importer.Default().Import(pkgImportName) - if err != nil { - return nil, err - } - - var scope = pkg.Scope() - var funcOrVars []pkgFuncType - var typs []pkgFuncType - var typeVars []string - var importPackages []string - - for _, name := range scope.Names() { - if include(pkgImportName, name, black) { - continue - } else if goVersion.is18plus() && !include(pkgImportName, name, in19) { - continue - } else if goVersion.is110() && !include(pkgImportName, name, in110) { - continue - } - - sc := scope.Lookup(name) - if sc.Exported() { - switch reflect.TypeOf(sc) { - case reflect.TypeOf(new(types.TypeName)): - varName := strings.ToLower(name) - if keyword[varName] { - varName = varName + "_" - } - typeVars = append(typeVars, fmt.Sprintf(` var %s %s.%s`, varName, getpackageTailName(pkgImportName), name)) - typs = append(typs, pkgFuncType{pkgImportName, name, fmt.Sprintf(`reflect.TypeOf(&%s).Elem()`, varName)}) - default: - funcOrVars = append(funcOrVars, pkgFuncType{pkgImportName, name, getpackageTailName(pkgImportName) + "." + name}) - } - } - } - - var extraDetail string - if extra, ok := extraList[pkgImportName]; goVersion.is18() && ok { - extraDetail = extra.detail - if extra.packageImport != nil { - for _, v := range extra.packageImport { - funcOrVars = append(funcOrVars, pkgFuncType{pkgImportName, v.k, v.v}) - } - } - if extra.packageTypesImport != nil { - for _, v := range extra.packageTypesImport { - typs = append(typs, pkgFuncType{pkgImportName, v.k, v.v}) - } - } - } else { - pkgTmpl = strings.Replace(pkgTmpl, "{{.extra}}", "", -1) - } - - importPackages = append(importPackages, fmt.Sprintf(`"%s"`, pkgImportName)) - if len(typeVars) > 0 { - importPackages = append(importPackages, `"reflect"`) - } else { - pkgTmpl = strings.Replace(pkgTmpl, "{{.package_no_struct_types}}\n", "", -1) - } - - return parseTmpl(pkgTmpl, map[string]interface{}{ - "build_tag": goVersion.buildTag(), - "name": pkgImportName, - "package_funcs": funcOrVars, - "package_types": typs, - "package_no_struct_types": strings.Join(typeVars, "\n"), - "import_packages": strings.Join(importPackages, "\n"), - "extra": extraDetail, - "import_func_name": getPackageInitName(pkgImportName), - }) -} - func runOneVersion(pkgImportName string, goVersion version) { - var result []byte - var err error - if goVersion == gogo { - if result, err = generatePackageImportCode18(pkgImportName); err != nil { - log.Fatal(err) - } - } else { - if result, err = generatePackageImportCode18Plus(pkgImportName, goVersion); err != nil { - log.Fatal(err) - } + result, err := generatePackageImportCodeAll(pkgImportName, goVersion) + if err != nil { + log.Fatal(err) } if err = ioutil.WriteFile(goVersion.filename(pkgImportName), result, 0644); err != nil { @@ -253,15 +142,25 @@ func runOneVersion(pkgImportName string, goVersion version) { func run(pkgImportName string) { if v, ok := ruleList[pkgImportName]; ok { + build := "// +build " + if v.in19 != nil { - runOneVersion(pkgImportName, go18plus) + build += "!go1.9" + runOneVersion(pkgImportName, go19) // generate pkg.19.go } if v.in110 != nil { - runOneVersion(pkgImportName, go110) + build += "!go1.10" + runOneVersion(pkgImportName, go110) // generate pkg.110.go + } + if build != "// +build " { + // generate pkg.18.go + if err := ioutil.WriteFile(go18.filename(pkgImportName), []byte(build+"\n\npackage packages\n\nfunc "+getPackageInitName(pkgImportName)+"() { }\n"), 0644); err != nil { + log.Fatal(err) + } } } - runOneVersion(pkgImportName, gogo) + runOneVersion(pkgImportName, gogo) // generate pkg.go and } func main() { diff --git a/cmd/generate-std-packages/rule.go b/cmd/generate-std-packages/rule.go index efaa5cbe..b1467a8c 100644 --- a/cmd/generate-std-packages/rule.go +++ b/cmd/generate-std-packages/rule.go @@ -18,10 +18,13 @@ var keyword = map[string]bool{ "int": true, } +type convertFunc func(string) string + type rule struct { - in19 []string // not in 18 - in110 []string // not in 18 and 19 - black []string + in19 []string // not in 18 + in110 []string // not in 18 and 19 + black []string + convert map[string]convertFunc } var ruleList = map[string]rule{ @@ -30,7 +33,9 @@ var ruleList = map[string]rule{ }, "math": { in110: []string{"Erfcinv", "Erfinv", "Round", "RoundToEven"}, - black: []string{"MaxUint64"}, + convert: map[string]convertFunc{"MaxUint64": func(s string) string { + return "uint64(math.MaxUint64)" + }}, }, "math/rand": { in110: []string{"Shuffle"}, @@ -78,3 +83,21 @@ func include(packageName, item, typ string) bool { return false } + +func getConvertedName(pkgImportName, name string) string { + n := getpackageTailName(pkgImportName) + "." + name + + rule, ok := ruleList[pkgImportName] + if !ok { + return n + } else if rule.convert == nil { + return n + } + + f, ok := rule.convert[name] + if !ok { + return n + } + + return f(name) +} diff --git a/cmd/generate-std-packages/tmpl.go b/cmd/generate-std-packages/tmpl.go new file mode 100644 index 00000000..6996d1dd --- /dev/null +++ b/cmd/generate-std-packages/tmpl.go @@ -0,0 +1,114 @@ +package main + +import ( + "bytes" + "strings" + "text/template" +) + +var ( + pkgNormalTmpl = `package packages + +import ( + {{.import_packages}} +) + +{{.extra}} + +func init() { + {{.package_no_struct_types}} + +{{if hasPkgFuncTypeField . "package_funcs"}} + Packages["{{.name}}"] = map[string]interface{}{ + {{range $index, $element := .package_funcs}} + "{{.FuncTypeName}}" : {{.Expr}}, + {{end}} + } +{{end}} + +{{if hasPkgFuncTypeField . "package_types"}} + PackageTypes["{{.name}}"] = map[string]interface{}{ + {{range $index, $element := .package_types}} + "{{.FuncTypeName}}" : {{.Expr}}, + {{end}} + } +{{end}} + +{{.import_multi_version_call}} + +} +` + + pkgExtraTmpl = ` +{{.build_tag}} + +package packages + +import ( + {{.import_packages}} +) + +{{.extra}} + +func {{.import_func_name}}() { + {{.package_no_struct_types}} + + {{range $index, $element := .package_funcs}} + Packages["{{.PkgName}}"]["{{.FuncTypeName}}"] = {{.Expr}} + {{end}} + + {{range $index, $element := .package_types}} + PackageTypes["{{.PkgName}}"]["{{.FuncTypeName}}"] = {{.Expr}} + {{end}} +} +` +) + +func hasPkgFuncTypeField(v interface{}, name string) bool { + m, ok := v.(map[string]interface{}) + if !ok { + return false + } + + n, ok := m[name] + if !ok { + return false + } + + p, ok := n.([]pkgFuncType) + + return ok && len(p) > 0 +} + +func parseTmpl(tmpl string, data map[string]interface{}) ([]byte, error) { + for k, v := range data { + if v == "" { + tmpl = strings.Replace(tmpl, "{{."+k+"}}", "", -1) + } + } + + parsedTmpl, err := template.New("tmpl").Funcs(template.FuncMap{"hasPkgFuncTypeField": hasPkgFuncTypeField}).Parse(tmpl) + if err != nil { + return nil, err + } + + var result bytes.Buffer + if err := parsedTmpl.Execute(&result, data); err != nil { + return nil, err + } + + s := strings.Split(result.String(), "\n") + var s2 []string + for i := 0; i < len(s); i++ { + if s3 := strings.TrimSpace(s[i]); s3 == "" { + continue + } + + s2 = append(s2, s[i]) + if strings.HasPrefix(s[i], "// +build") { + s2 = append(s2, "\n") + } + } + + return []byte(strings.Join(s2, "\n")), nil +} diff --git a/cmd/generate-std-packages/version.go b/cmd/generate-std-packages/version.go index b2e945ce..af43c887 100644 --- a/cmd/generate-std-packages/version.go +++ b/cmd/generate-std-packages/version.go @@ -7,32 +7,41 @@ import ( type version string const ( - gogo version = "general" - go18 version = "1.8" - go18plus version = "1.9 1.10" - go110 version = "1.10" + gogo version = "general" + go18 version = "1.8" // from Go version 1.8 onward + go19 version = "1.9" // from Go version 1.9 onward + go110 version = "1.10" // from Go version 1.10 onward ) -func (v version) is18() bool { - return v == go18 +func (v version) is19() bool { + return v == go19 } -func (v version) is18plus() bool { - return v == go18plus +func (v version) is18() bool { + return v == go18 } func (v version) is110() bool { return v == go110 } +func (v version) isGeneral() bool { + return v == gogo +} + func (v version) buildTag() string { switch v { - case go18: - return "// +build go1.8" - case go18plus: - return "// +build go1.9 go1.10" - case go110: - return "// +build go1.10" + case go18, go19, go110: + return "// +build go" + string(v) + } + + return "" +} + +func (v version) buildOppositeTag() string { + switch v { + case go18, go19, go110: + return "// +build !go" + string(v) } return "" @@ -40,17 +49,15 @@ func (v version) buildTag() string { // filename encoding/json return encoding.json.19.110.go func (v version) filename(packageImportName string) string { - name := strings.Join(strings.Split(packageImportName, "/"), ".") + pkgName := strings.Join(strings.Split(packageImportName, "/"), ".") + versionName := strings.Replace(string(v), ".", "", -1) + switch v { - case go18: - return "./packages/" + name + ".18.go" - case go18plus: - return "./packages/" + name + ".19.110.go" - case go110: - return "./packages/" + name + ".110.go" + case go18, go19, go110: + return "./packages/" + pkgName + "." + versionName + ".go" } - return "./packages/" + name + ".go" + return "./packages/" + pkgName + ".go" } func getpackageTailName(packageImportName string) string { diff --git a/packages/bytes.go b/packages/bytes.go index 754e9df4..98ed06c0 100644 --- a/packages/bytes.go +++ b/packages/bytes.go @@ -64,5 +64,4 @@ func init() { "Buffer": reflect.TypeOf(&buffer).Elem(), "Reader": reflect.TypeOf(&reader).Elem(), } - } diff --git a/packages/encoding.json.18.go b/packages/encoding.json.18.go index 8aa8549d..9fdb3888 100644 --- a/packages/encoding.json.18.go +++ b/packages/encoding.json.18.go @@ -1,4 +1,4 @@ -// +build go1.8,!go1.9,!go1.10 +// +build !go1.9 package packages diff --git a/packages/encoding.json.19.110.go b/packages/encoding.json.19.go similarity index 83% rename from packages/encoding.json.19.110.go rename to packages/encoding.json.19.go index 372dbb92..b9b256ea 100644 --- a/packages/encoding.json.19.110.go +++ b/packages/encoding.json.19.go @@ -1,4 +1,4 @@ -// +build go1.9 go1.10 +// +build go1.9 package packages @@ -7,7 +7,5 @@ import ( ) func init_encoding_json() { - Packages["encoding/json"]["Valid"] = json.Valid - } diff --git a/packages/encoding.json.go b/packages/encoding.json.go index cadbd807..a0782dcc 100644 --- a/packages/encoding.json.go +++ b/packages/encoding.json.go @@ -51,5 +51,4 @@ func init() { "UnsupportedValueError": reflect.TypeOf(&unsupportedvalueerror).Elem(), } init_encoding_json() - } diff --git a/packages/errors.go b/packages/errors.go index 984b6153..8ac16ee2 100644 --- a/packages/errors.go +++ b/packages/errors.go @@ -8,6 +8,4 @@ func init() { Packages["errors"] = map[string]interface{}{ "New": errors.New, } - PackageTypes["errors"] = map[string]interface{}{} - } diff --git a/packages/flag.go b/packages/flag.go index 833d2d97..bad3df17 100644 --- a/packages/flag.go +++ b/packages/flag.go @@ -56,5 +56,4 @@ func init() { "Getter": reflect.TypeOf(&getter).Elem(), "Value": reflect.TypeOf(&value).Elem(), } - } diff --git a/packages/fmt.go b/packages/fmt.go index ec26a40c..82c9ee57 100644 --- a/packages/fmt.go +++ b/packages/fmt.go @@ -41,5 +41,4 @@ func init() { "State": reflect.TypeOf(&state).Elem(), "Stringer": reflect.TypeOf(&stringer).Elem(), } - } diff --git a/packages/io.go b/packages/io.go index 332cdb88..a9f90ccf 100644 --- a/packages/io.go +++ b/packages/io.go @@ -79,5 +79,4 @@ func init() { "WriterAt": reflect.TypeOf(&writerat).Elem(), "WriterTo": reflect.TypeOf(&writerto).Elem(), } - } diff --git a/packages/io.ioutil.go b/packages/io.ioutil.go index 01e67bec..72a9b0fc 100644 --- a/packages/io.ioutil.go +++ b/packages/io.ioutil.go @@ -15,6 +15,4 @@ func init() { "TempFile": ioutil.TempFile, "WriteFile": ioutil.WriteFile, } - PackageTypes["io/ioutil"] = map[string]interface{}{} - } diff --git a/packages/log.go b/packages/log.go index 16cd99b6..0c8f504d 100644 --- a/packages/log.go +++ b/packages/log.go @@ -35,5 +35,4 @@ func init() { PackageTypes["log"] = map[string]interface{}{ "Logger": reflect.TypeOf(&logger).Elem(), } - } diff --git a/packages/math.110.go b/packages/math.110.go index 6eea0f24..5cea3973 100644 --- a/packages/math.110.go +++ b/packages/math.110.go @@ -7,13 +7,8 @@ import ( ) func init_math() { - Packages["math"]["Erfcinv"] = math.Erfcinv - Packages["math"]["Erfinv"] = math.Erfinv - Packages["math"]["Round"] = math.Round - Packages["math"]["RoundToEven"] = math.RoundToEven - } diff --git a/packages/math.18.go b/packages/math.18.go index a531f4e9..e17b1db2 100644 --- a/packages/math.18.go +++ b/packages/math.18.go @@ -1,4 +1,4 @@ -// +build go1.8,!go1.10 +// +build !go1.10 package packages diff --git a/packages/math.big.go b/packages/math.big.go index 5c3afef5..3b0a80fb 100644 --- a/packages/math.big.go +++ b/packages/math.big.go @@ -42,5 +42,4 @@ func init() { "RoundingMode": reflect.TypeOf(&roundingmode).Elem(), "Word": reflect.TypeOf(&word).Elem(), } - } diff --git a/packages/math.go b/packages/math.go index 8892ffe4..dbdc0460 100644 --- a/packages/math.go +++ b/packages/math.go @@ -61,6 +61,7 @@ func init() { "MaxInt8": math.MaxInt8, "MaxUint16": math.MaxUint16, "MaxUint32": math.MaxUint32, + "MaxUint64": uint64(math.MaxUint64), "MaxUint8": math.MaxUint8, "Min": math.Min, "MinInt16": math.MinInt16, @@ -95,7 +96,5 @@ func init() { "Y1": math.Y1, "Yn": math.Yn, } - PackageTypes["math"] = map[string]interface{}{} init_math() - } diff --git a/packages/math.rand.110.go b/packages/math.rand.110.go index 6994fb69..c8fa7329 100644 --- a/packages/math.rand.110.go +++ b/packages/math.rand.110.go @@ -7,7 +7,5 @@ import ( ) func init_math_rand() { - Packages["math/rand"]["Shuffle"] = rand.Shuffle - } diff --git a/packages/math.rand.18.go b/packages/math.rand.18.go index 9fd5bb17..5e7467e1 100644 --- a/packages/math.rand.18.go +++ b/packages/math.rand.18.go @@ -1,4 +1,4 @@ -// +build go1.8,!go1.10 +// +build !go1.10 package packages diff --git a/packages/math.rand.go b/packages/math.rand.go index 63f6f3f6..66487f75 100644 --- a/packages/math.rand.go +++ b/packages/math.rand.go @@ -37,5 +37,4 @@ func init() { "Zipf": reflect.TypeOf(&zipf).Elem(), } init_math_rand() - } diff --git a/packages/net.go b/packages/net.go index ff276c8e..0e01fb61 100644 --- a/packages/net.go +++ b/packages/net.go @@ -140,5 +140,4 @@ func init() { "UnixListener": reflect.TypeOf(&unixlistener).Elem(), "UnknownNetworkError": reflect.TypeOf(&unknownnetworkerror).Elem(), } - } diff --git a/packages/net.http.18.go b/packages/net.http.18.go index 26e734fd..73f67d03 100644 --- a/packages/net.http.18.go +++ b/packages/net.http.18.go @@ -1,4 +1,4 @@ -// +build go1.8,!go1.9,!go1.10 +// +build !go1.9 package packages diff --git a/packages/net.http.19.110.go b/packages/net.http.19.go similarity index 82% rename from packages/net.http.19.110.go rename to packages/net.http.19.go index ccb7b178..7730b71d 100644 --- a/packages/net.http.19.110.go +++ b/packages/net.http.19.go @@ -1,4 +1,4 @@ -// +build go1.9 go1.10 +// +build go1.9 package packages @@ -7,7 +7,5 @@ import ( ) func init_net_http() { - Packages["net/http"]["ServeTLS"] = http.ServeTLS - } diff --git a/packages/net.http.cookiejar.go b/packages/net.http.cookiejar.go index 3cccff36..e20b4031 100644 --- a/packages/net.http.cookiejar.go +++ b/packages/net.http.cookiejar.go @@ -17,5 +17,4 @@ func init() { "Options": reflect.TypeOf(&options).Elem(), "PublicSuffixList": reflect.TypeOf(&publicsuffixlist).Elem(), } - } diff --git a/packages/net.http.go b/packages/net.http.go index e357a701..c53f19f4 100644 --- a/packages/net.http.go +++ b/packages/net.http.go @@ -194,5 +194,4 @@ func init() { "Transport": reflect.TypeOf(&transport).Elem(), } init_net_http() - } diff --git a/packages/net.url.go b/packages/net.url.go index 01c61a2e..173eb6f6 100644 --- a/packages/net.url.go +++ b/packages/net.url.go @@ -31,5 +31,4 @@ func init() { "Userinfo": reflect.TypeOf(&userinfo).Elem(), "Values": reflect.TypeOf(&values).Elem(), } - } diff --git a/packages/os.110.go b/packages/os.110.go index f74028bc..8dee3592 100644 --- a/packages/os.110.go +++ b/packages/os.110.go @@ -7,9 +7,6 @@ import ( ) func init_os() { - Packages["os"]["ErrNoDeadline"] = os.ErrNoDeadline - Packages["os"]["IsTimeout"] = os.IsTimeout - } diff --git a/packages/os.18.go b/packages/os.18.go index 8df48e2d..8ad8d10d 100644 --- a/packages/os.18.go +++ b/packages/os.18.go @@ -1,4 +1,4 @@ -// +build go1.8,!go1.10 +// +build !go1.10 package packages diff --git a/packages/os.exec.go b/packages/os.exec.go index bc90da25..98e2ffb6 100644 --- a/packages/os.exec.go +++ b/packages/os.exec.go @@ -20,5 +20,4 @@ func init() { "Error": reflect.TypeOf(&error_).Elem(), "ExitError": reflect.TypeOf(&exiterror).Elem(), } - } diff --git a/packages/os.go b/packages/os.go index da77ab73..e1c9a10c 100644 --- a/packages/os.go +++ b/packages/os.go @@ -120,5 +120,4 @@ func init() { "SyscallError": reflect.TypeOf(&syscallerror).Elem(), } init_os() - } diff --git a/packages/os.signal.go b/packages/os.signal.go index 21d6a667..baf33e48 100644 --- a/packages/os.signal.go +++ b/packages/os.signal.go @@ -11,6 +11,4 @@ func init() { "Reset": signal.Reset, "Stop": signal.Stop, } - PackageTypes["os/signal"] = map[string]interface{}{} - } diff --git a/packages/path.filepath.go b/packages/path.filepath.go index f62a0b34..3a243a39 100644 --- a/packages/path.filepath.go +++ b/packages/path.filepath.go @@ -34,5 +34,4 @@ func init() { PackageTypes["path/filepath"] = map[string]interface{}{ "WalkFunc": reflect.TypeOf(&walkfunc).Elem(), } - } diff --git a/packages/path.go b/packages/path.go index e8027e26..6ab6ad6a 100644 --- a/packages/path.go +++ b/packages/path.go @@ -16,6 +16,4 @@ func init() { "Match": path.Match, "Split": path.Split, } - PackageTypes["path"] = map[string]interface{}{} - } diff --git a/packages/regexp.go b/packages/regexp.go index 4ba35942..9921f055 100644 --- a/packages/regexp.go +++ b/packages/regexp.go @@ -20,5 +20,4 @@ func init() { PackageTypes["regexp"] = map[string]interface{}{ "Regexp": reflect.TypeOf(®exp_).Elem(), } - } diff --git a/packages/runtime.go b/packages/runtime.go index 82e3cda7..4a960e23 100644 --- a/packages/runtime.go +++ b/packages/runtime.go @@ -65,5 +65,4 @@ func init() { "StackRecord": reflect.TypeOf(&stackrecord).Elem(), "TypeAssertionError": reflect.TypeOf(&typeassertionerror).Elem(), } - } diff --git a/packages/sort.go b/packages/sort.go index 91bfb335..d78e1559 100644 --- a/packages/sort.go +++ b/packages/sort.go @@ -15,7 +15,6 @@ type SortFuncsStruct struct { func (s SortFuncsStruct) Len() int { return s.LenFunc() } func (s SortFuncsStruct) Less(i, j int) bool { return s.LessFunc(i, j) } func (s SortFuncsStruct) Swap(i, j int) { s.SwapFunc(i, j) } - func init() { var float64slice sort.Float64Slice var intslice sort.IntSlice @@ -47,5 +46,4 @@ func init() { "StringSlice": reflect.TypeOf(&stringslice).Elem(), "SortFuncsStruct": &SortFuncsStruct{}, } - } diff --git a/packages/strconv.go b/packages/strconv.go index 0eb5d217..bbada45c 100644 --- a/packages/strconv.go +++ b/packages/strconv.go @@ -46,5 +46,4 @@ func init() { PackageTypes["strconv"] = map[string]interface{}{ "NumError": reflect.TypeOf(&numerror).Elem(), } - } diff --git a/packages/strings.110.go b/packages/strings.110.go index 8ca52169..54c5c09e 100644 --- a/packages/strings.110.go +++ b/packages/strings.110.go @@ -9,7 +9,5 @@ import ( func init_strings() { var builder strings.Builder - PackageTypes["strings"]["Builder"] = reflect.TypeOf(&builder).Elem() - } diff --git a/packages/strings.18.go b/packages/strings.18.go index f05cd2b1..13d61bcc 100644 --- a/packages/strings.18.go +++ b/packages/strings.18.go @@ -1,4 +1,4 @@ -// +build go1.8,!go1.10 +// +build !go1.10 package packages diff --git a/packages/strings.go b/packages/strings.go index 13821a59..9b3a011b 100644 --- a/packages/strings.go +++ b/packages/strings.go @@ -60,5 +60,4 @@ func init() { "Replacer": reflect.TypeOf(&replacer).Elem(), } init_strings() - } diff --git a/packages/time.110.go b/packages/time.110.go index e4fc55c8..f85c6dc9 100644 --- a/packages/time.110.go +++ b/packages/time.110.go @@ -7,7 +7,5 @@ import ( ) func init_time() { - Packages["time"]["LoadLocationFromTZData"] = time.LoadLocationFromTZData - } diff --git a/packages/time.18.go b/packages/time.18.go index 938f2ca1..c746f35d 100644 --- a/packages/time.18.go +++ b/packages/time.18.go @@ -1,4 +1,4 @@ -// +build go1.8,!go1.10 +// +build !go1.10 package packages diff --git a/packages/time.go b/packages/time.go index ae654dae..234e8dc3 100644 --- a/packages/time.go +++ b/packages/time.go @@ -85,5 +85,4 @@ func init() { "Weekday": reflect.TypeOf(&weekday).Elem(), } init_time() - }