| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package main
- import (
- "fmt"
- )
- func main() {
- foo1()
- /*
- value1, value2, operation := readTask()
- switch v1 := value1.(type) {
- case float64:
- break
- default:
- fmt.Printf("value=%v: %T\n", v1, v1)
- return
- }
- switch v2 := value2.(type) {
- case float64:
- break
- default:
- fmt.Printf("value=%v: %T\n", v2, v2)
- return
- }
- switch op := operation.(type) {
- case string:
- if op == "+" {
- fmt.Printf("%.4f\n", value1.(float64)+value2.(float64))
- } else if op == "-" {
- fmt.Printf("%.4f\n", value1.(float64)-value2.(float64))
- } else if op == "*" {
- fmt.Printf("%.4f\n", value1.(float64)*value2.(float64))
- } else if op == "/" {
- fmt.Printf("%.4f\n", value1.(float64)/value2.(float64))
- }
- default:
- fmt.Printf("operation=%v: %T\n", op, op)
- return
- }
- // fmt.Println("value 1 - OK")
- // fmt.Println(value1, value2, operation)
- */
- }
- func foo1() {
- // vi1, vi2, operation := readTask()
- // vi := [2]interface{}{vi1, vi2}
- var v1, v2 float64
- vf := [2]*float64{&v1, &v2}
- fmt.Println(vf)
- fmt.Printf("%v %T", vf, vf)
- }
- func readTask() (v1, v2, op interface{}) {
- v1 = 12.36
- v2 = 36.24
- op = "+"
- return
- }
|