V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
proxytoworld
V2EX  ›  问与答

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

  •  
  •   proxytoworld · Jul 14, 2022 · 917 views
    This topic created in 1387 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
        1
    misaka19000  
       Jul 14, 2022
    文档没写吗
    proxytoworld
        2
    proxytoworld  
    OP
       Jul 14, 2022
    @misaka19000 没看懂,英文不咋好
    misaka19000
        3
    misaka19000  
       Jul 14, 2022
    misaka19000
        4
    misaka19000  
       Jul 14, 2022
    TrimRight 是把右边所有在 cutset 里面的字符给干掉
    TrimSuffix 是把后缀按照 suffix 给干掉

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