github.com/pkujhd/goloader@v0.0.0-20240411034752-1a28096bd7bd/examples/const/const.go (about) 1 package constant 2 3 import "fmt" 4 5 func addfloat64(a, b float64) float64 { 6 if b < 0 { 7 fmt.Println("addfloat64:Do not add negative number") 8 } 9 return a + b 10 } 11 12 func addfloat32(a, b float32) float32 { 13 if b < 0 { 14 fmt.Println("addfloat32:Do not add negative number") 15 } 16 return a + b 17 } 18 19 func addint64(a, b int64) int64 { 20 if b < 0 { 21 fmt.Println("addfloat32:Do not add negative number") 22 } 23 return a + b 24 } 25 26 func LoaderString(value interface{}) bool { 27 fmt.Println("LoaderString:", fmt.Sprint(value)) 28 return false 29 } 30 31 func main() { 32 LoaderString(0) 33 LoaderString(1) 34 35 f32_x := float32(1.0) 36 f32_y := float32(2.0) 37 f32_z := float32(-1.0) 38 f32_val := float32(0.0) 39 f32_val = addfloat32(f32_x, f32_z) 40 fmt.Printf("f32 %f + %f = %f\n", f32_x, f32_z, f32_val) 41 f32_val = addfloat32(f32_x, f32_y) 42 fmt.Printf("f32 %f + %f = %f\n", f32_x, f32_y, f32_val) 43 44 f64_x := float64(1.0) 45 f64_y := float64(2.0) 46 f64_z := float64(-1.0) 47 f64_val := float64(0.0) 48 f64_val = addfloat64(f64_x, f64_z) 49 fmt.Printf("f64 %f + %f = %f\n", f64_x, f64_z, f64_val) 50 f64_val = addfloat64(f64_x, f64_y) 51 fmt.Printf("f64 %f + %f = %f\n", f64_x, f64_y, f64_val) 52 53 i64_x := int64(1.0) 54 i64_y := int64(2.0) 55 i64_z := int64(-1.0) 56 i64_val := int64(0.0) 57 i64_val = addint64(i64_x, i64_z) 58 fmt.Printf("i64 %d + %d = %d\n", i64_x, i64_z, i64_val) 59 i64_val = addint64(i64_x, i64_y) 60 fmt.Printf("i64 %d + %d = %d\n", i64_x, i64_y, i64_val) 61 62 }