ProductLang.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package Product
  2. // 产品语言
  3. type ProductLang struct {
  4. Id int `json:"Id"`
  5. T_name string `json:"T_name"` // 协议语言
  6. T_code string `json:"T_code"` // 协议语言
  7. }
  8. var ProductLangList = []ProductLang{}
  9. // ---------------- 方法 -------------------
  10. func init() {
  11. ProductLangAdd(ProductLang{
  12. Id: 0,
  13. T_name: "无解析",
  14. T_code: "",
  15. })
  16. ProductLangAdd(ProductLang{
  17. Id: 1,
  18. T_name: "Goland",
  19. 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}",
  20. })
  21. ProductLangAdd(ProductLang{
  22. Id: 2,
  23. T_name: "C",
  24. 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}",
  25. })
  26. //Add(ProductLang{
  27. // Id: 3,
  28. // T_name: "Python",
  29. //})
  30. //Add(ProductLang{
  31. // Id: 4,
  32. // T_name: "JavaScript",
  33. //})
  34. }
  35. // 添加
  36. func ProductLangAdd(t ProductLang) {
  37. ProductLangList = append(ProductLangList, t)
  38. }
  39. // 获取列表
  40. func ProductLangLists() (r []ProductLang, Total int64) {
  41. return ProductLangList, int64(len(ProductLangList))
  42. }