1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package Product
- // 产品语言
- type ProductLang struct {
- Id int `json:"Id"`
- T_name string `json:"T_name"` // 协议语言
- T_code string `json:"T_code"` // 协议语言
- }
- var ProductLangList = []ProductLang{}
- // ---------------- 方法 -------------------
- func init() {
- ProductLangAdd(ProductLang{
- Id: 0,
- T_name: "无解析",
- T_code: "",
- })
- ProductLangAdd(ProductLang{
- Id: 1,
- T_name: "Goland",
- T_code: "import (\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"strings\"\n)\n/*\n设备->平台\n*/\nfunc T(t string, b []byte) string {\n\treturn string(b)\n}\n/*\n平台->设备\n*/\nfunc R(sn string, b string) (string, []byte) {\n\tt := sn\n\treturn t, []byte(b)\n}",
- })
- ProductLangAdd(ProductLang{
- Id: 2,
- T_name: "C",
- T_code: "#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#define LEN 1024\n\n// 设备->平台\nvoid T(const char *t, const char *b, char **r_b) {\n size_t len1 = strlen(t);\n size_t len2 = strlen(b);\n *r_b = (char *)malloc(len1 + len2 + 1);\n strcpy(*r_b, t);\n strcat(*r_b, b);\n}\n// 平台->设备\nvoid R(const char *t, const char *b, char **r_t, char **r_b) {\n size_t len1 = strlen(t);\n size_t len2 = strlen(b);\n *r_t = (char *)malloc(len1 + 1);\n *r_b = (char *)malloc(len2 + 1);\n strcpy(*r_t, t);\n strcpy(*r_b, b);\n}",
- })
- //Add(ProductLang{
- // Id: 3,
- // T_name: "Python",
- //})
- //Add(ProductLang{
- // Id: 4,
- // T_name: "JavaScript",
- //})
- }
- // 添加
- func ProductLangAdd(t ProductLang) {
- ProductLangList = append(ProductLangList, t)
- }
- // 获取列表
- func ProductLangLists() (r []ProductLang, Total int64) {
- return ProductLangList, int64(len(ProductLangList))
- }
|