proxytoworld
V2EX  ›  问与答

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

  •  
  •   proxytoworld · Jul 14, 2022 · 1246 views
    This topic created in 1597 days ago, the information mentioned may be changed or developed.

    同理还有 bytes.TrimLeft 和 bytes.TrimPrefix

    5 replies  •  2022-07-14 14:12:51 +08:00
    misaka19000
    misaka19000
    Jul 14, 2022
    1
    文档没写吗
    proxytoworld
    proxytoworld
    OP
    Jul 14, 2022
    2
    @misaka19000 没看懂,英文不咋好
    misaka19000
    misaka19000
    Jul 14, 2022
    4
    TrimRight 是把右边所有在 cutset 里面的字符给干掉
    TrimSuffix 是把后缀按照 suffix 给干掉

    一个是基于字符,一个是基于字符串
    proxytoworld
    proxytoworld
    OP
    Jul 14, 2022
    5
    @misaka19000 懂了 谢谢老哥,我原先吧 bytes.TrimLeft 的 cutset 理解成了字符串,没想到是一个集合
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   898 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 516ms · UTC 22:34 · PVG 06:34 · LAX 14:34 · JFK 17:34
    ♥ Do have faith in what you're doing.