淘宝api sdk golang

码农软件 · 软件分类 · 网站API · 2019-03-09 16:27:06

软件介绍

淘宝开放平台的go版的SDK. 内置sdk生成工具.

可由淘宝提供的ApiMetadata.xml,自动生成sdk. 主要有两种生成方式:

  • 分结构生成

  • 一键生成所有

示例代码:

package main

import (
    "github.com/ohohco/taobao/autosdk"
    "log"
    "os"
    "path"
)

var (
    //生成文件所在路径.
    root = "github.com/ohohco/taobao/api"
    //ApiMetadata.xml文件
    filename = "./ApiMetadata.xml"
    //api文档的调用方法
    apiMethod = "taobao.item.get"
    //生成文件所在路径(绝对路径).
    dest = path.Join(os.Getenv("GOPATH"), "src/github.com/ohohco/taobao/api")
)

func main() {
    log.SetFlags(log.Lshortfile | log.LstdFlags)

    //文件读取
    var metadata *autosdk.Metadata
    metadata, err := metadata.UnmarshalFile(filename)
    if err != nil {
        panic(err)
    }
    //文件生成
    ///////////////
    ////方式1//////
    ///////////////
    if err = metadata.GenerateByApiMethod(apiMethod, dest); err != nil {
        panic(err)
    }
    ///////////////
    ////其他方式///
    ///////////////
    if err = metadata.Generate(dest); err != nil {
        panic(err)
    }

    //代码格式化:
    if err = autosdk.Format(dest); err != nil {
        panic(err)
    }
    //代码install:
    if err = autosdk.Install(path.Join(root, "domain"),
        path.Join(root, "request"),
        path.Join(root, "response")); err != nil {
        panic(err)
    }
}
///////////////
////方式2//////
///////////////
if err = metadata.Generate(dest); err != nil {
    panic(err)
}

本文地址:https://codercto.com/soft/d/979.html

Probability and Computing: Randomization and Probabilistic Techn

Probability and Computing: Randomization and Probabilistic Techn

Michael Mitzenmacher、Eli Upfal / Cambridge University Press / 2017-7-3 / USD 62.23

Greatly expanded, this new edition requires only an elementary background in discrete mathematics and offers a comprehensive introduction to the role of randomization and probabilistic techniques in m......一起来看看 《Probability and Computing: Randomization and Probabilistic Techn》 这本书的介绍吧!

MD5 加密
MD5 加密

MD5 加密工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

html转js在线工具
html转js在线工具

html转js在线工具