Golang MongoDB ODM mgm使用

(本文大部分内容根据官方文档翻译而来) 环境准备 golang 1.10+ mongodb mgm 模型定义 定义 定义模型 type Book struct { // DefaultModel adds _id, created_at and updated_at fields to the Model mgm.DefaultModel `bson:",inline"` Name string `json:"name" bson:"name"` Pages int `json:"pages" bson:"pages"` } func NewBook(name string, pages int) *Book { return &Book{ Name: name, Pages: pages, } } mgm 在创建表时会自动检测Model生成的Collection名称 book:=Book{} // Print your model collection name. collName := mgm.CollName(&book) fmt.Println(collName) // 打印: books 如果要自定义生成Collection的名称。需要实现CollectionNameGetter接口。 ...

2022-05-31 · 7 分钟 · czyt

Flutter开发Maven配置

在Flutter开发时,可能因为网络等原因导致maven不能正常工作,造成Flutter项目卡住的情况。下面是解决办法。原文链接 https://flutter.cn/community/china 如果你在国内使用 Flutter,那么你可能需要找一个与官方同步的可信的镜像站点,帮助你的 Flutter 命令行工具到该镜像站点下载其所需的资源。你需要为此设置两个环境变量:PUB_HOSTED_URL 和 FLUTTER_STORAGE_BASE_URL,然后再运行 Flutter 命令行工具。 以 macOS 或者与 Linux 相近的系统为例,这里有以下步骤帮助你设定镜像。在系统终端里执行如下命令设定环境变量,并通过 GitHub 检出 Flutter SDK: content_copy $ export PUB_HOSTED_URL=https://pub.flutter-io.cn $ export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn $ git clone -b dev https://github.com/flutter/flutter.git $ export PATH="$PWD/flutter/bin:$PATH" $ cd ./flutter $ flutter doctor Flutter SDK配置修改 flutter的maven设置在<安装目录>\packages\flutter_tools\gradle\flutter.gradle 打包配置 buildscript { repositories { maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://maven.aliyun.com/repository/central' } maven { url 'https://maven.aliyun.com/repository/jcenter' } // google() // jcenter() } dependencies { /* When bumping, also update ndkVersion above. */ classpath 'com.android.tools.build:gradle:4.1.0' } } FlutterPlugin配置 class FlutterPlugin implements Plugin<Project> { // private static final String DEFAULT_MAVEN_HOST = "https://storage.googleapis.com"; private static final String MAVEN_REPO = "https://storage.flutter-io.cn/download.flutter.io"; 所有项目设置 rootProject.allprojects { repositories { maven { url repository } // 添加下面的内容 maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/jcenter' } maven { url 'https://maven.aliyun.com/repository/public' } } } Flutter项目配置修改 修改Flutter项目下的android下的build.gradle ...

2022-05-27 · 1 分钟 · czyt

MongoDB操作指北

TL;DR 环境准备 mongoDB 预备知识 MongoDB常见的数据类型 数据类型 示例 说明 Null {"x" : null} Boolean {"x" : true} Number {"x" : 3.14} {"x" : 3} {"x" : NumberInt("3")} {"x" : NumberLong("3")} 默认64位浮点数,整数需要使用NumberInt和NumberLong String {"x" : "foobar"} 编码格式为UTF-8 Date {"x" : new Date()} 64位时间戳(从January 1, 1970),不存时区。通过new Date()进行调用。 Regular expression {"x" : /foobar/i} javascript 正则 Array {"x" : ["a", "b", "c"]} Embedded document {"x" : {"foo" : "bar"}} Object ID {"x" : ObjectId()} 文档12字节的ID Binary data 一个任意字节的字符串。是保存非UTF-8字符串到数据库的唯一方法。 Code {"x" : function() { /* ... */ }} 数据操作 数据库连接 连接字符串 MongoDB的连接字符串为如下格式 ...

2022-05-26 · 12 分钟 · czyt

通过注册表禁用windows10自动更新

缘起 近期项目上设备会自动更新windows10为windows11,通过搜索,搜索到第三方工具windows-update-blocker ,因为改工具支持命令行参数,故也很方便于集成。批处理大致如下 @echo off pushd %~dp0 echo 开始禁用windows更新服务 %~dp0Wub_x64.exe /D /P timeout 3 背后的操作 作为技术人,还是需要知道软件做了什么背后的操作,通过TotalUninstaller监控,获取到软件写入的注册表如下,实现的手段就是镜像劫持windows更新的进程,并且更新windows的组策略选项: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer] "NoWindowsUpdate"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options] "WubBlockLists"=hex(7):57,00,61,00,61,00,53,00,4D,00,65,00,64,00,69,00,63,00,\ 2E,00,65,00,78,00,65,00,00,00,57,00,61,00,61,00,73,00,4D,00,65,00,64,00,69,\ 00,63,00,41,00,67,00,65,00,6E,00,74,00,2E,00,65,00,78,00,65,00,00,00,57,00,\ 69,00,6E,00,64,00,6F,00,77,00,73,00,31,00,30,00,55,00,70,00,67,00,72,00,61,\ 00,64,00,65,00,2E,00,65,00,78,00,65,00,00,00,57,00,69,00,6E,00,64,00,6F,00,\ 77,00,73,00,31,00,30,00,55,00,70,00,67,00,72,00,61,00,64,00,65,00,72,00,41,\ 00,70,00,70,00,2E,00,65,00,78,00,65,00,00,00,55,00,70,00,64,00,61,00,74,00,\ 65,00,41,00,73,00,73,00,69,00,73,00,74,00,61,00,6E,00,74,00,2E,00,65,00,78,\ 00,65,00,00,00,55,00,73,00,6F,00,43,00,6C,00,69,00,65,00,6E,00,74,00,2E,00,\ 65,00,78,00,65,00,00,00,72,00,65,00,6D,00,73,00,68,00,2E,00,65,00,78,00,65,\ 00,00,00,45,00,4F,00,53,00,6E,00,6F,00,74,00,69,00,66,00,79,00,2E,00,65,00,\ 78,00,65,00,00,00,53,00,69,00,68,00,43,00,6C,00,69,00,65,00,6E,00,74,00,2E,\ 00,65,00,78,00,65,00,00,00,75,00,70,00,66,00,63,00,2E,00,65,00,78,00,65,00,\ 00,00,49,00,6E,00,73,00,74,00,61,00,6C,00,6C,00,41,00,67,00,65,00,6E,00,74,\ 00,2E,00,65,00,78,00,65,00,00,00,4D,00,75,00,73,00,4E,00,6F,00,74,00,69,00,\ 66,00,69,00,63,00,61,00,74,00,69,00,6F,00,6E,00,2E,00,65,00,78,00,65,00,00,\ 00,4D,00,75,00,73,00,4E,00,6F,00,74,00,69,00,66,00,69,00,63,00,61,00,74,00,\ 69,00,6F,00,6E,00,55,00,78,00,2E,00,65,00,78,00,65,00,00,00,00,00,00,00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\EOSnotify.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\InstallAgent.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MusNotification.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MusNotificationUx.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\remsh.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\SihClient.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\UpdateAssistant.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\upfc.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\UsoClient.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\WaaSMedic.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\WaasMedicAgent.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Windows10Upgrade.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\Windows10UpgraderApp.exe] "Debugger"="/" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings] "TrayIconVisibility"=dword:00000000 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft] "WindowsStore"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate] "DisableOSUpgrade"=dword:00000001 "DisableWindowsUpdateAccess"=dword:00000001 [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU] "NoAutoUpdate"=dword:00000001 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DoSvc] "Start"=dword:00000004 "WubLock"=dword:00000001 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsoSvc] "Start"=dword:00000003 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc] "Start"=dword:00000004 "WubLock"=dword:00000001 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv] "Start"=dword:00000004 "WubLock"=dword:00000001 恢复为默认更新配置的注册表项 ...

2022-05-19 · 2 分钟 · czyt

Golang监测Linux网络事件

代码 package main import ( "fmt" "syscall" ) func main() { l, _ := ListenNetlink() for { msgs, err := l.ReadMsgs() if err != nil { fmt.Println("Could not read netlink: %s", err) } for _, m := range msgs { if IsNewAddr(&m) { fmt.Println("New Addr") } if IsDelAddr(&m) { fmt.Println("Del Addr") } } } } type NetlinkListener struct { fd int sa *syscall.SockaddrNetlink } func ListenNetlink() (*NetlinkListener, error) { groups := (1 << (syscall.RTNLGRP_LINK - 1)) | (1 << (syscall.RTNLGRP_IPV4_IFADDR - 1)) | (1 << (syscall.RTNLGRP_IPV6_IFADDR - 1)) s, err := syscall.Socket(syscall.AF_NETLINK, syscall.SOCK_DGRAM, syscall.NETLINK_ROUTE) if err != nil { return nil, fmt.Errorf("socket: %s", err) } saddr := &syscall.SockaddrNetlink{ Family: syscall.AF_NETLINK, Pid: uint32(0), Groups: uint32(groups), } err = syscall.Bind(s, saddr) if err != nil { return nil, fmt.Errorf("bind: %s", err) } return &NetlinkListener{fd: s, sa: saddr}, nil } func (l *NetlinkListener) ReadMsgs() ([]syscall.NetlinkMessage, error) { defer func() { recover() }() pkt := make([]byte, 2048) n, err := syscall.Read(l.fd, pkt) if err != nil { return nil, fmt.Errorf("read: %s", err) } msgs, err := syscall.ParseNetlinkMessage(pkt[:n]) if err != nil { return nil, fmt.Errorf("parse: %s", err) } return msgs, nil } func IsNewAddr(msg *syscall.NetlinkMessage) bool { if msg.Header.Type == syscall.RTM_NEWADDR { return true } return false } func IsDelAddr(msg *syscall.NetlinkMessage) bool { if msg.Header.Type == syscall.RTM_DELADDR { return true } return false } // rtm_scope is the distance to the destination: // // RT_SCOPE_UNIVERSE global route // RT_SCOPE_SITE interior route in the // local autonomous system // RT_SCOPE_LINK route on this link // RT_SCOPE_HOST route on the local host // RT_SCOPE_NOWHERE destination doesn't exist // // The values between RT_SCOPE_UNIVERSE and RT_SCOPE_SITE are // available to the user. func IsRelevant(msg *syscall.IfAddrmsg) bool { if msg.Scope == syscall.RT_SCOPE_UNIVERSE || msg.Scope == syscall.RT_SCOPE_SITE { return true } return false } 参考 https://stackoverflow.com/questions/36347807/how-to-monitor-ip-address-change-using-rtnetlink-socket-in-go-language ...

2022-05-17 · 2 分钟 · czyt

Golang False sharing

缘起 来自于一段prometheus 代码 type stripeLock struct { sync.RWMutex // Padding to avoid multiple locks being on the same cache line. _ [40]byte } 简单地讲就是因为CPU读取数据的缓存机制问题,可能导致性能上的不同差异。参考资料见后文。 常见类型的内存占用大小(Go101 ): Kinds of Types Value Size Required by Go Specification bool 1 byte not specified int8, uint8 (byte) 1 byte 1 byte int16, uint16 2 bytes 2 bytes int32 (rune), uint32, float32 4 bytes 4 bytes int64, uint64, float64, complex64 8 bytes 8 bytes complex128 16 bytes 16 bytes int, uint 1 word architecture dependent, 4 bytes on 32-bit architectures and 8 bytes on 64-bit architectures uintptr 1 word large enough to store the uninterpreted bits of a pointer value string 2 words not specified pointer (safe or unsafe) 1 word not specified slice 3 words not specified map 1 word not specified channel 1 word not specified function 1 word not specified interface 2 words not specified struct (the sum of sizes of all fields) + (the number of padding bytes) the size of a struct type is zero if it contains no fields that have a size greater than zero array (element value size) * (array length) the size of an array type is zero if its element type has zero size 参考 https://medium.com/@genchilu/whats-false-sharing-and-how-to-solve-it-using-golang-as-example-ef978a305e10 https://dariodip.medium.com/false-sharing-an-example-with-go-bc7e90594f3f https://github.com/glebarez/false-sharing-demo https://betterprogramming.pub/when-io-bound-hides-inside-cpu-e6e7f9df3187 https://colobu.com/2019/01/24/cacheline-affects-performance-in-go/ https://www.shouxicto.com/article/3984.html https://www.wangt.cc/2021/11/golang-%E5%86%85%E5%AD%98%E5%AF%B9%E9%BD%90%E5%92%8C%E4%BC%AA%E5%85%B1%E4%BA%ABfalse-sharing/

2022-05-12 · 1 分钟 · czyt

WPF与虚拟键盘的那些事

缘起 近期项目使用到相关技术,故整理文章一篇。 获取可用输入设备 软件的本质无非是输入和输出,那么WPF如何获取电脑是否有可用输入设备呢?查询了Google,在StackOverflow上找到一个提问,原帖地址 ,代码如下: KeyboardCapabilities keyboardCapabilities = new Windows.Devices.Input.KeyboardCapabilities(); return keyboardCapabilities.KeyboardPresent != 0 ? true : false; 如果没有可用输入设备,那么就该虚拟键盘上场了。windows里面有两个虚拟键盘的程序,一个是TabTip.exe一个是osk.exe,可以直接调用进程,也可以使用 WPF的第三方组件https://github.com/maximcus/WPFTabTip 详细实现可以参考后面的链接。 平板模式 下面代码将当前系统的运行模式改为平板模式 public static readonly Guid CLSID_ImmersiveShell = new Guid("C2F03A33-21F5-47FA-B4BB-156362A2F239"); [ComImport()] [Guid("4FDA780A-ACD2-41F7-B4F2-EBE674C9BF2A")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITabletModeController { int GetMode(ref int mode); int SetMode(int mode, int modeTrigger); } [ComImport] [Guid("6D5140C1-7436-11CE-8034-00AA006009FA")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] internal interface IServiceProvider { [return: MarshalAs(UnmanagedType.IUnknown)] object QueryService(ref Guid service, ref Guid riid); } 调用 var pSP = (IServiceProvider)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_ImmersiveShell)); var pTMC = (ITabletModeController)pSP.QueryService(typeof(ITabletModeController).GUID, typeof(ITabletModeController).GUID); if (pTMC != null) { // 0 = Desktop, 1 = Tablet int nMode = 0; int nRet = pTMC.GetMode(ref nMode); nRet = pTMC.SetMode(nMode==0?1:0, 4); } 系统运行模式检测 [DllImport("user32.dll")] static extern int GetSystemMetrics(SystemMetric smIndex); //http://www.pinvoke.net/default.aspx/Enums/SystemMetric.html public enum SystemMetric { SM_CXSCREEN = 0, // 0x00 SM_CYSCREEN = 1, // 0x01 SM_CXVSCROLL = 2, // 0x02 SM_CYHSCROLL = 3, // 0x03 SM_CYCAPTION = 4, // 0x04 SM_CXBORDER = 5, // 0x05 SM_CYBORDER = 6, // 0x06 SM_CXDLGFRAME = 7, // 0x07 SM_CXFIXEDFRAME = 7, // 0x07 SM_CYDLGFRAME = 8, // 0x08 SM_CYFIXEDFRAME = 8, // 0x08 SM_CYVTHUMB = 9, // 0x09 SM_CXHTHUMB = 10, // 0x0A SM_CXICON = 11, // 0x0B SM_CYICON = 12, // 0x0C SM_CXCURSOR = 13, // 0x0D SM_CYCURSOR = 14, // 0x0E SM_CYMENU = 15, // 0x0F SM_CXFULLSCREEN = 16, // 0x10 SM_CYFULLSCREEN = 17, // 0x11 SM_CYKANJIWINDOW = 18, // 0x12 SM_MOUSEPRESENT = 19, // 0x13 SM_CYVSCROLL = 20, // 0x14 SM_CXHSCROLL = 21, // 0x15 SM_DEBUG = 22, // 0x16 SM_SWAPBUTTON = 23, // 0x17 SM_CXMIN = 28, // 0x1C SM_CYMIN = 29, // 0x1D SM_CXSIZE = 30, // 0x1E SM_CYSIZE = 31, // 0x1F SM_CXSIZEFRAME = 32, // 0x20 SM_CXFRAME = 32, // 0x20 SM_CYSIZEFRAME = 33, // 0x21 SM_CYFRAME = 33, // 0x21 SM_CXMINTRACK = 34, // 0x22 SM_CYMINTRACK = 35, // 0x23 SM_CXDOUBLECLK = 36, // 0x24 SM_CYDOUBLECLK = 37, // 0x25 SM_CXICONSPACING = 38, // 0x26 SM_CYICONSPACING = 39, // 0x27 SM_MENUDROPALIGNMENT = 40, // 0x28 SM_PENWINDOWS = 41, // 0x29 SM_DBCSENABLED = 42, // 0x2A SM_CMOUSEBUTTONS = 43, // 0x2B SM_SECURE = 44, // 0x2C SM_CXEDGE = 45, // 0x2D SM_CYEDGE = 46, // 0x2E SM_CXMINSPACING = 47, // 0x2F SM_CYMINSPACING = 48, // 0x30 SM_CXSMICON = 49, // 0x31 SM_CYSMICON = 50, // 0x32 SM_CYSMCAPTION = 51, // 0x33 SM_CXSMSIZE = 52, // 0x34 SM_CYSMSIZE = 53, // 0x35 SM_CXMENUSIZE = 54, // 0x36 SM_CYMENUSIZE = 55, // 0x37 SM_ARRANGE = 56, // 0x38 SM_CXMINIMIZED = 57, // 0x39 SM_CYMINIMIZED = 58, // 0x3A SM_CXMAXTRACK = 59, // 0x3B SM_CYMAXTRACK = 60, // 0x3C SM_CXMAXIMIZED = 61, // 0x3D SM_CYMAXIMIZED = 62, // 0x3E SM_NETWORK = 63, // 0x3F SM_CLEANBOOT = 67, // 0x43 SM_CXDRAG = 68, // 0x44 SM_CYDRAG = 69, // 0x45 SM_SHOWSOUNDS = 70, // 0x46 SM_CXMENUCHECK = 71, // 0x47 SM_CYMENUCHECK = 72, // 0x48 SM_SLOWMACHINE = 73, // 0x49 SM_MIDEASTENABLED = 74, // 0x4A SM_MOUSEWHEELPRESENT = 75, // 0x4B SM_XVIRTUALSCREEN = 76, // 0x4C SM_YVIRTUALSCREEN = 77, // 0x4D SM_CXVIRTUALSCREEN = 78, // 0x4E SM_CYVIRTUALSCREEN = 79, // 0x4F SM_CMONITORS = 80, // 0x50 SM_SAMEDISPLAYFORMAT = 81, // 0x51 SM_IMMENABLED = 82, // 0x52 SM_CXFOCUSBORDER = 83, // 0x53 SM_CYFOCUSBORDER = 84, // 0x54 SM_TABLETPC = 86, // 0x56 SM_MEDIACENTER = 87, // 0x57 SM_STARTER = 88, // 0x58 SM_SERVERR2 = 89, // 0x59 SM_MOUSEHORIZONTALWHEELPRESENT = 91, // 0x5B SM_CXPADDEDBORDER = 92, // 0x5C SM_DIGITIZER = 94, // 0x5E SM_MAXIMUMTOUCHES = 95, // 0x5F SM_REMOTESESSION = 0x1000, // 0x1000 SM_SHUTTINGDOWN = 0x2000, // 0x2000 SM_REMOTECONTROL = 0x2001, // 0x2001 SM_CONVERTABLESLATEMODE = 0x2003, SM_SYSTEMDOCKED = 0x2004, } // should handle in event SystemEvents.UserPreferenceChanging which e.Category == UserPreferenceCategory.General if (GetSystemMetrics(SystemMetric.SM_CONVERTABLESLATEMODE) == 0) { Debug.WriteLine("detected slate mode"); } else if (GetSystemMetrics(SystemMetric.SM_SYSTEMDOCKED) == 0) { Debug.WriteLine("detected docked mode"); } 修改键盘布局 ...

2022-04-25 · 3 分钟 · czyt

Keep运动接口

基础接口 授权 curl --location --request POST 'https://api.gotokeep.com/v1.1/users/login' \ --header 'Content-Type: application/json' \ --data-raw '{"mobile": 18888888888, "password": "aa"}' 返回token内容需要作为后续请求的header传递,返回示例: { "ok": true, "data": { "userId": "011981111e131", "level": 0, "goal": 0, "gender": "M", "token": "xxxxxxxxxxxx", "userRegisterInfo": null }, "errorCode": "0", "now": "2022-04-21T05:02:57Z", "version": "1.0.0", "text": null, "more": {} } 动作库 获取动作分类 curl --location --request GET 'https://api.gotokeep.com/training/v2/trainingpoints/exerciselib' \ --header 'Authorization: Bearer xxxxxxxxx' 返回 { "ok": true, "data": [ { "name": "胸部", "_id": "54826e417fb786000069ad82", "url": "http://static1.keepcdn.com/misc/2016/08/05/12/55963b0e73800000.png" }, { "name": "背部", "_id": "54826e417fb786000069ad84", "url": "http://static1.keepcdn.com/misc/2016/08/05/12/55963ab1a4c00000.png" }, { "name": "肩部", "_id": "54826e417fb786000069ad83", "url": "http://static1.keepcdn.com/misc/2016/08/05/12/55963b1db3c00000.png" }, { "name": "手臂", "_id": "54826e417fb786000069ad88", "url": "http://static1.keepcdn.com/misc/2016/08/05/12/559639a46e400000.png" }, { "name": "颈部", "_id": "55cb1b72bfbf17f934371eba", "url": "http://static1.keepcdn.com/misc/2016/08/05/12/55963afccdc00000.png" }, { "name": "腹部", "_id": "54826e417fb786000069ad86", "url": "http://static1.keepcdn.com/misc/2016/08/05/12/55963b3fc0400000.png" }, { "name": "腰部", "_id": "55cb1ca06fe674f94036d581", "url": "http://static1.keepcdn.com/misc/2016/08/05/12/55963b2cc0800000.png" }, { "name": "臀部", "_id": "54826e417fb786000069ad87", "url": "http://static1.keepcdn.com/misc/2016/08/05/12/559639594f800000.png" }, { "name": "腿部", "_id": "54826e417fb786000069ad85", "url": "http://static1.keepcdn.com/misc/2016/08/05/12/55963ad31b400000.png" }, { "name": "全身", "_id": "54826e417fb786000069ad81", "url": "http://static1.keepcdn.com/misc/2016/08/05/12/559638c467800000.png" } ], "errorCode": 0, "text": "" } 获取动作库某个分类下的动作 ...

2022-04-21 · 1 分钟 · czyt

为Kratos prtobuf文件添加多种编译输出

Csharp 安装Grpc.tools https://www.nuget.org/packages/Grpc.Tools/ 下载解压 nupkg文件(改扩展名为zip),也可以使用附件的7z包 解压 找到tools中对应系统架构的软件,设置下环境变量,让系统可以找到就行。 Linux 需要创建一个符号链接 ln -s `which grpc_csharp_plugin` /usr/bin/protoc-gen-grpc-csharp 修改Kratos项目的Make文件 在api这个make任务中添加下面内容 --csharp_out=./api/pipe/v1 \ --grpc-csharp_out=./api/pipe/v1 \ 完整内容为 .PHONY: api # generate api proto api: protoc --proto_path=./api \ --proto_path=./third_party \ --go_out=paths=source_relative:./api \ --go-http_out=paths=source_relative:./api \ --go-grpc_out=paths=source_relative:./api \ --csharp_out=./api/pipe/v1 \ --grpc-csharp_out=./api/pipe/v1 \ --openapi_out==paths=source_relative:. \ 参考 https://github.com/grpc/grpc/blob/master/src/csharp/BUILD-INTEGRATION.md 📎tools.7z Python 安装必要包 pip install grpclib protobuf 查询路径 which protoc-gen-grpclib_python 或者 which protoc-gen-python_grpc我这里返回信息如下: ➜ czyt which protoc-gen-grpclib_python /usr/sbin/protoc-gen-grpclib_python 如法炮制,创建软链接 ln -s /usr/sbin/protoc-gen-grpclib_python /usr/sbin/protoc-gen-grpc_python 修改Makefile 添加下面的内容,再执行make api生成api即可。 --python_out=./api \ --grpc_python_out=./api \ Dart 安装插件 dart pub global activate protoc_plugin 将插件工具加入环境变量 export PATH="$PATH:$HOME/.pub-cache/bin" 脚本添加--dart_out=选项 --dart_out=./api \ TypeScript 纯typescript类 ts-proto typescript类+服务 安装proto工具 go get go.einride.tri p tech/protoc-gen-typescript-http ...

2022-04-08 · 1 分钟 · czyt

个人Golang环境安装快速设置

下载 官方下载 https://go.dev/dl/ Google 香港镜像 Golang Downloads Mirrors 更多请参考 Thanks Mirror 环境设置 设置proxy go env -w GOPROXY=https://goproxy.io,https://goproxy.cn,direct 安装相关工具 进程工具 goreman go install github.com/mattn/goreman@latest 框架Cli kratos go install github.com/go-kratos/kratos/cmd/kratos/v2@latest wire go install github.com/google/wire/cmd/wire@latest ent go install entgo.io/ent/cmd/ent@latest entimport go install ariga.io/entimport/cmd/entimport@latest entproto go install entgo.io/contrib/entproto/cmd/entproto@latest 代码Lint golangci-lint go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest golines go install github.com/segmentio/golines@latest Go into the Goland settings and click “Tools” -> “File Watchers” then click the plus to create a new file watcher Set the following properties and confirm by clicking OK: Name: golines File type: Go files Scope: Project Files Program: golines Arguments: $FilePath$ -w Output paths to refresh: $FilePath$ gofumpt go install mvdan.cc/gofumpt@latest goland设置 ...

2022-03-24 · 2 分钟 · czyt