ByteNote LogoByteNote

Navigation

  • Blog
  • 工具

    © 2025 ByteNote. All rights reserved.

    vscode go struct生成 tags

    Jul 2, 20227 min read
    type Config struct {
    	AppName string
    	AppPort string
    	AppMode string
    }
    

    在struct上右键选择 Go: Add Tags To Struct Fields

    package tool
    
    type Config struct {
    	AppName string `json:"app_name,omitempty"`
    	AppPort string `json:"app_port,omitempty"`
    	AppMode string `json:"app_mode,omitempty"`
    }
    

    omitempty的作用是当一个field的值是empty的时候,序列化JSON时候忽略这个field

    相关文章

    TypeScript 基本知识梳理

    TypeScript 是 JavaScript 的强类型版本,提供了类型检查和更好的开发体验,支持多种类型如 number, string, boolean, array, any, void, object 等,并通过接口(interface)和类型推断增强代码的健壮性和可读性。

    JSON2Dart

    JSON2Dart is a tool available at https://javiercbk.github.io/json_to_dart/ that converts JSON data into Dart code.

    如何为rtl网站适配?最佳方案分享!

    为RTL网站适配的最佳方案包括使用CSS框架、特定CSS属性、样式表翻转工具和调整设计布局。

    node 报错 ReferenceError: Request is not defined

    要解决`Request`未定义的错误,可在浏览器中使用`fetch`API或在Node.js中使用`http`或`https`模块来发送HTTP请求。

    GitHub Actions脚本 运行 node 定时脚本

    GitHub Actions脚本配置为每小时在Ubuntu最新版本上运行Node.js 16.x的定时任务,使用`GITHUB_TOKEN`进行身份验证和操作。