Compare commits
No commits in common. "943191e9dd7e86fe64bbab67538bbe7fae57518a" and "34b69520f3d3748efad2fc02b2461158eb664735" have entirely different histories.
943191e9dd
...
34b69520f3
@ -1,24 +0,0 @@
|
|||||||
// from chapter 10
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"git.linuxhg.com/Go_Training/calendar"
|
|
||||||
)
|
|
||||||
|
|
||||||
func companyCalendar() {
|
|
||||||
event := calendar.Event{}
|
|
||||||
err := event.SetTitle("Mom's Birthday")
|
|
||||||
Error(err)
|
|
||||||
err = event.SetYear(2019)
|
|
||||||
Error(err)
|
|
||||||
err = event.SetMonth(5)
|
|
||||||
Error(err)
|
|
||||||
err = event.SetDay(27)
|
|
||||||
Error(err)
|
|
||||||
|
|
||||||
fmt.Println(event.Title())
|
|
||||||
fmt.Println(event.Year())
|
|
||||||
fmt.Println(event.Month())
|
|
||||||
fmt.Println(event.Day())
|
|
||||||
}
|
|
@ -5,62 +5,12 @@ package main
|
|||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
type Liters float64
|
type Liters float64
|
||||||
|
|
||||||
func (l Liters) String() string {
|
|
||||||
return fmt.Sprintf("%0.2f L", l)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Gallons float64
|
type Gallons float64
|
||||||
|
|
||||||
func (g Gallons) String() string {
|
|
||||||
return fmt.Sprintf("%0.2f gal", g)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Milliliters float64
|
|
||||||
|
|
||||||
func (m Milliliters) String() string {
|
|
||||||
return fmt.Sprintf("%0.2f mL", m)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l Liters) ToGallons() Gallons {
|
|
||||||
return Gallons(l * 0.264)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m Milliliters) ToGallons() Gallons {
|
|
||||||
return Gallons(m * 0.000264)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g Gallons) ToLiters() Liters {
|
|
||||||
return Liters(g * 3.785)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g Gallons) ToMilliliters() Milliliters {
|
|
||||||
return Milliliters(g * 3785.41)
|
|
||||||
}
|
|
||||||
|
|
||||||
func fuel() {
|
func fuel() {
|
||||||
// long version
|
var carFuel Gallons
|
||||||
//var carFuel Gallons
|
var busFuel Liters
|
||||||
//var busFuel Liters
|
carFuel = Gallons(10.0)
|
||||||
//carFuel = Gallons(10.0)
|
busFuel = Liters(240.0)
|
||||||
//busFuel = Liters(240.0)
|
fmt.Println(carFuel, busFuel)
|
||||||
// short version
|
|
||||||
soda := Liters(2)
|
|
||||||
fmt.Printf("%0.0f liters equals %0.3f gallons\n", soda, soda.ToGallons())
|
|
||||||
water := Milliliters(500)
|
|
||||||
fmt.Printf("%0.0f milliliters equals %0.3f gallons \n", water, water.ToGallons())
|
|
||||||
//carFuel := Gallons(10.0)
|
|
||||||
//busFuel := Liters(240.0)
|
|
||||||
//
|
|
||||||
////if you want to convert between types, save variable with correct calculation
|
|
||||||
//carFuel += ToGallons(Liters(40.0))
|
|
||||||
//busFuel += ToLiters(Gallons(30.0))
|
|
||||||
//fmt.Printf("Car Fuel: %0.1f gallons\n", carFuel)
|
|
||||||
//fmt.Printf("Bus Fuel: %0.1f liters\n", busFuel)
|
|
||||||
milk := Gallons(2)
|
|
||||||
fmt.Printf("%0.0f gallons equals %0.3f liters\n", milk, milk.ToLiters())
|
|
||||||
fmt.Printf("%0.0f gallons equals %0.3f milliliters\n", milk, milk.ToMilliliters())
|
|
||||||
fmt.Println(Gallons(12.09285934))
|
|
||||||
fmt.Println(Liters(12.09285934))
|
|
||||||
fmt.Println(Milliliters(12.09285934))
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131153240-372e0ebc267d // indirect
|
|
||||||
github.com/atotto/clipboard v0.1.4 // indirect
|
github.com/atotto/clipboard v0.1.4 // indirect
|
||||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||||
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
|
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
|
||||||
|
@ -1,11 +1,3 @@
|
|||||||
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131021259-9a867797a789 h1:NjOZBosOrGRV87iw30jOyH8UNKv7bVNxtix+BguskVA=
|
|
||||||
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131021259-9a867797a789/go.mod h1:E6GYPXO26PAOFhtrQ3d9K+yG0j6e4nFORZT5zlD7HOc=
|
|
||||||
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131145407-3e70d7233820 h1:/n9lYFbddduk4UoGW0Jh12synMzF02ciC3gCkrqph5g=
|
|
||||||
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131145407-3e70d7233820/go.mod h1:E6GYPXO26PAOFhtrQ3d9K+yG0j6e4nFORZT5zlD7HOc=
|
|
||||||
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131150458-66340adc88a8 h1:UTF7JbrCemR61hRKderfV3Au3/0CFDIIefp70YalEww=
|
|
||||||
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131150458-66340adc88a8/go.mod h1:E6GYPXO26PAOFhtrQ3d9K+yG0j6e4nFORZT5zlD7HOc=
|
|
||||||
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131153240-372e0ebc267d h1:wKAe1v8k2qmtJUo/FgE2xqdLRNN31u01bT9/FQGr0MI=
|
|
||||||
git.linuxhg.com/Go_Training/calendar v0.0.0-20240131153240-372e0ebc267d/go.mod h1:E6GYPXO26PAOFhtrQ3d9K+yG0j6e4nFORZT5zlD7HOc=
|
|
||||||
git.linuxhg.com/Go_Training/datafile v0.0.0-20240111160218-6989e96515a9 h1:jjPk3X9lZ6bZhsjBvEJUGyqfNalUDG0Lt5UvaPrKFtM=
|
git.linuxhg.com/Go_Training/datafile v0.0.0-20240111160218-6989e96515a9 h1:jjPk3X9lZ6bZhsjBvEJUGyqfNalUDG0Lt5UvaPrKFtM=
|
||||||
git.linuxhg.com/Go_Training/datafile v0.0.0-20240111160218-6989e96515a9/go.mod h1:iRnsnz7UZZtIhCX3KTblxBxtEuvPZ8MMi5GDWGIt+dw=
|
git.linuxhg.com/Go_Training/datafile v0.0.0-20240111160218-6989e96515a9/go.mod h1:iRnsnz7UZZtIhCX3KTblxBxtEuvPZ8MMi5GDWGIt+dw=
|
||||||
git.linuxhg.com/Go_Training/keyboard v0.0.0-20240111160241-d208f095efce h1:S9raWDpQtH3at5D4Bm0bfnvPd3ATGGMuZ8eQMrLddFM=
|
git.linuxhg.com/Go_Training/keyboard v0.0.0-20240111160241-d208f095efce h1:S9raWDpQtH3at5D4Bm0bfnvPd3ATGGMuZ8eQMrLddFM=
|
||||||
|
@ -110,12 +110,6 @@ func main() {
|
|||||||
fuel()
|
fuel()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "Calendar",
|
|
||||||
launchFunction: func() {
|
|
||||||
companyCalendar()
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
menu := wmenu.NewMenu("Choose a program.")
|
menu := wmenu.NewMenu("Choose a program.")
|
||||||
menu.Action(func(opts []wmenu.Opt) error {
|
menu.Action(func(opts []wmenu.Opt) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user