当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 0

ks3sdk / aws-sdk-go
关闭

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
load.go 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
lijunwei123 提交于 2015-06-08 15:20 . first
package api
import (
"encoding/json"
"fmt"
"os"
)
// Load takes a set of files for each filetype and returns an API pointer.
// The API will be initialized once all files have been loaded and parsed.
//
// Will panic if any failure opening the definition JSON files, or there
// are unrecognized exported names.
func Load(api, docs, paginators, waiters string) *API {
a := API{}
a.Attach(api)
a.Attach(docs)
a.Attach(paginators)
a.Attach(waiters)
return &a
}
// Attach opens a file by name, and unmarshal its JSON data.
// Will proceed to setup the API if not already done so.
func (a *API) Attach(filename string) {
f, err := os.Open(filename)
defer f.Close()
if err != nil {
panic(err)
}
json.NewDecoder(f).Decode(a)
if !a.initialized {
a.Setup()
}
}
// AttachString will unmarshal a raw JSON string, and setup the
// API if not already done so.
func (a *API) AttachString(str string) {
json.Unmarshal([]byte(str), a)
if !a.initialized {
a.Setup()
}
}
// Setup initializes the API.
func (a *API) Setup() {
a.unrecognizedNames = map[string]string{}
a.writeShapeNames()
a.resolveReferences()
a.fixStutterNames()
a.renameExportable()
a.renameToplevelShapes()
a.updateTopLevelShapeReferences()
a.createInputOutputShapes()
a.customizationPasses()
if !a.NoRemoveUnusedShapes {
a.removeUnusedShapes()
}
if len(a.unrecognizedNames) > 0 {
msg := []string{
"Unrecognized inflections for the following export names:",
"(Add these to inflections.csv with any inflections added after the ':')",
}
fmt.Fprintf(os.Stderr, "%s\n%s\n\n", msg[0], msg[1])
for n, m := range a.unrecognizedNames {
if n == m {
m = ""
}
fmt.Fprintf(os.Stderr, "%s:%s\n", n, m)
}
os.Stderr.WriteString("\n\n")
panic("Found unrecognized exported names in API " + a.PackageName())
}
a.initialized = true
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/ks3sdk/aws-sdk-go.git
git@gitee.com:ks3sdk/aws-sdk-go.git
ks3sdk
aws-sdk-go
aws-sdk-go
v1.0.4

搜索帮助

344bd9b3 5694891 D2dac590 5694891