V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
proxytoworld
V2EX  ›  问与答

go 的 bytes.TrimRight 和 bytes.TrimSuffix 有啥区别,感觉都是去除右边的字符串

  •  
  •   proxytoworld · 2022-07-14 11:25:13 +08:00 · 566 次点击
    这是一个创建于 657 天前的主题,其中的信息可能已经有所发展或是发生改变。

    同理还有 bytes.TrimLeft 和 bytes.TrimPrefix

    5 条回复    2022-07-14 14:12:51 +08:00
    misaka19000
        1
    misaka19000  
       2022-07-14 11:26:45 +08:00
    文档没写吗
    proxytoworld
        2
    proxytoworld  
    OP
       2022-07-14 11:27:08 +08:00
    @misaka19000 没看懂,英文不咋好
    misaka19000
        3
    misaka19000  
       2022-07-14 11:29:12 +08:00
    misaka19000
        4
    misaka19000  
       2022-07-14 11:32:35 +08:00
    TrimRight 是把右边所有在 cutset 里面的字符给干掉
    TrimSuffix 是把后缀按照 suffix 给干掉

    一个是基于字符,一个是基于字符串
    proxytoworld
        5
    proxytoworld  
    OP
       2022-07-14 14:12:51 +08:00
    @misaka19000 懂了 谢谢老哥,我原先吧 bytes.TrimLeft 的 cutset 理解成了字符串,没想到是一个集合
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   927 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 23:01 · PVG 07:01 · LAX 16:01 · JFK 19:01
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.