ByteNote LogoByteNote

Navigation

  • Blog
  • 工具

    © 2025 ByteNote. All rights reserved.

    Go 语言“可变参数函数”

    Dec 15, 20217 min read

    Go 语言“可变参数函数”

    image-20211215100643800

    传入已有的切片

    你可以通过向一个已有的切片添加可变参数运算符 ”…“ 后缀的方式将其传入可变参数函数。

    names := []string{"carl", "sagan"}
    
    toFullname(names...)
    
    func toFullname(names ...string) []string {
      return append(names, "hey", "what's up?")
    }
    
    toFullname()
    

    相关文章

    TypeScript Partial的用法和源码

    `Partial<T>` 是TypeScript中的一个工具类型,用于将接口类型`T`中的所有属性变为可选属性,其源码定义为`{ [P in keyof T]?: T[P]; }`,其中`keyof`用于提取类型的键名。

    Go arm64 docker-compose demo

    该内容描述了一个使用Docker和docker-compose在amd64架构上构建Go应用程序的示例,包括Dockerfile配置和docker-compose.yaml文件。

    Using async:await with a forEach loop

    To read files sequentially in JavaScript, avoid using `forEach` and opt for a `for … of` loop with `async:await` for proper asynchronous execution.

    Figma图形怎么等比缩放?

    在Figma中,通过选中图形、选择“等比缩放”、输入比例并确认,即可实现图形的等比缩放。

    Windows10 命令行设置代码

    该命令行代码用于在Windows 10中设置SOCKS5代理服务器为本地地址127.0.0.1和端口1080。