Add mathutil package and constants
Introduce a new package for math utilities, including an Add function and Euler's number. Also, add constants for Celsius conversion and basic arithmetic.
This commit is contained in:
@@ -3,3 +3,4 @@
|
|||||||
https://www.youtube.com/watch?v=ID9NZ88JeOE
|
https://www.youtube.com/watch?v=ID9NZ88JeOE
|
||||||
|
|
||||||
1. (00:04:58) Package
|
1. (00:04:58) Package
|
||||||
|
2. (00:15:14) Func
|
||||||
|
|||||||
32
main.go
32
main.go
@@ -2,8 +2,40 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"curso-goland/mathutil"
|
||||||
|
"math"
|
||||||
|
)
|
||||||
|
|
||||||
|
const GrauCelsius = 273.15
|
||||||
|
|
||||||
|
const (
|
||||||
|
A = 1
|
||||||
|
B = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
fmt.Println("Hello, World!")
|
fmt.Println("Hello, World!")
|
||||||
|
|
||||||
|
fmt.Println(mathutil.Add(1, 2))
|
||||||
|
|
||||||
|
fmt.Println(math.Sqrt(144))
|
||||||
|
|
||||||
|
var x int = 10
|
||||||
|
x = x + 1
|
||||||
|
fmt.Println(x)
|
||||||
|
|
||||||
|
var a, b int = 1, 2
|
||||||
|
c := a + b
|
||||||
|
fmt.Println(c)
|
||||||
|
|
||||||
|
nombre, edad := "Juan", 30
|
||||||
|
fmt.Println(nombre, edad)
|
||||||
|
|
||||||
|
fmt.Println(mathutil.EulersNumber)
|
||||||
|
|
||||||
|
fmt.Println(math.Pi)
|
||||||
|
|
||||||
|
fmt.Println(GrauCelsius)
|
||||||
|
|
||||||
|
fmt.Println(A + B)
|
||||||
}
|
}
|
||||||
|
|||||||
7
mathutil/mathutil.go
Normal file
7
mathutil/mathutil.go
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package mathutil
|
||||||
|
|
||||||
|
var EulersNumber float64 = 2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274
|
||||||
|
|
||||||
|
func Add(a, b int) int {
|
||||||
|
return a + b
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user