File tree Expand file tree Collapse file tree 2 files changed +24
-23
lines changed 
examples/string-formatting Expand file tree Collapse file tree 2 files changed +24
-23
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ func main() {
5050
5151    // There are also several formatting options for 
5252    // floats. For basic decimal formatting use `%f`. 
53-     fmt .Printf ("%f" , 78.9 )
53+     fmt .Printf ("%f\n " , 78.9 )
5454
5555    // `%e` and `%E` format the float in (slightly 
5656    // different versions of) scientific notation. 
@@ -99,7 +99,7 @@ func main() {
9999    // So far we've seen `Printf`, which prints the 
100100    // formatted string to `os.Stdout`. `Sprintf` formats 
101101    // and returns a string without printing it anywhere. 
102-     s  :=  fmt .Sprintf ("a %s  " , "string" )
102+     s  :=  fmt .Sprintf ("a %s" , "string" )
103103    fmt .Println (s )
104104
105105    // You can format+print to `io.Writers` other than 
Original file line number Diff line number Diff line change 1- $ go run string-formatting.go 
2- {1 2} 
3- {x:1 y:2} 
4- main.point{x:1, y:2} 
5- main.point 
6- true  
7- 123 
8- 1110 
9- !  
10- 1c8 
11- 78.9000001.234000e+08 
12- 1.234000E+08 
13- " string" 
14- " \" string\" " 
15- 6865782074686973 
16- 0x42134100 
17- |     12|    345|  
18- |   1.20|   3.45|  
19- | 1.20  | 3.45  |  
1+ $ go run string-formatting.go
2+ {1 2}
3+ {x:1 y:2}
4+ main.point{x:1, y:2}
5+ main.point
6+ true 
7+ 123
8+ 1110
9+ ! 
10+ 1c8
11+ 78.900000
12+ 1.234000e+08
13+ 1.234000E+08
14+ " string" 
15+ " \" string\" " 
16+ 6865782074686973
17+ 0x42135100
18+ |     12|    345| 
19+ |   1.20|   3.45| 
20+ | 1.20  | 3.45  | 
2021|    foo|      b| 
2122| foo   | b     | 
22- a string  
23- an error  
23+ a string
24+ an error
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments