Go string Stitching __go

Source: Internet
Author: User
Go string concatenation for string: direct = = for stitching
var s string 
str: = "123"
str = "123123"
str = "Qwerqwe"
1 2 3 4 use sprintf
var s string = "12312SF"
s = fmt. Sprintf ("%s%s", S, "123123")
1 2 for []string use strings. Join for Stitching
S: = "1231"
strings. Join ([]string{s, "Ewrwer"}, "")
1 2 Use []string and slice append properties for stitching
var s []string
s = append (S, "123123")
strings. Join (S, "")
1 2 3 Use bytes. Buffer
var buf bytes. Buffer
buf. WriteString ("12312")
buf. WriteString ("Werwer")
buf. String ()
1 2 3 4

The writestring () parameter must be a string, not a byte

B.writestring (String (S[len (s) -1-i])
b.writestring (S[len (s) -1-i,len (s)-i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.