mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 01:55:35 +08:00
fix: coding style and file format for chapter 10.
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
// celsius.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Celsius float64
|
||||
|
||||
func (c Celsius) String() string {
|
||||
return "The temperature is: " + strconv.FormatFloat(float64(c),'f', 1, 32) + " °C"
|
||||
}
|
||||
|
||||
func main() {
|
||||
var c Celsius = 18.36
|
||||
fmt.Println(c)
|
||||
}
|
||||
// The temperature is: 18.4 °C
|
||||
// celsius.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Celsius float64
|
||||
|
||||
func (c Celsius) String() string {
|
||||
return "The temperature is: " + strconv.FormatFloat(float64(c), 'f', 1, 32) + " °C"
|
||||
}
|
||||
|
||||
func main() {
|
||||
var c Celsius = 18.36
|
||||
fmt.Println(c)
|
||||
}
|
||||
|
||||
// The temperature is: 18.4 °C
|
||||
|
Reference in New Issue
Block a user