Formatted output in Go

Source: Internet
Author: User

//Code_002_basedata project Main.gopackage mainimport ("FMT") type Power struct {age int high int name String}func Main () {var str string str = "ABC" ch: = str[0] FMT. Printf ("str=%s, len=%d \ n", str, Len (str)) FMT. Printf ("str[0]=%c, ch =%c\n", str[0], ch) str2: = ' Hello mike \ r Test ' FMT. Println ("str2=", str2) var v1 complex64 v1 = 3.2 + 12i v2: = 3.2 + 12i v3: = Complex (3.2, +) FMT. Println (v1, v2, v3) fmt. Println (Real (v1), Imag (v1)) fmt. Println ("============") var i Power = power{18, 178, "Tom"} FMT. Printf ("type:%t\n", i) fmt. Printf ("value:%v\n", i) fmt. Printf ("value:%+v\n", i) fmt. Printf ("value:% #v \ n", i)/* ============ Type:main. Power value:{18 178 Tom} value:{age:18 high:178 Name:tom} value:main. Power{age:18, high:178, Name: "Tom"} */FMT. Println ("=====intervface=======") var interstr interface{} = i fmt. Printf ("%v\n", Interstr) fmt. PRINTLN (INTERSTR)/* =====intervface======={18 178 tom}{18 178 Tom} */}//commonly used formatting characters:%s,%d,%c,%T,%v,%p

Formatted output in Go

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.