Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass #1

Open
violaso opened this issue Jun 14, 2022 · 0 comments
Open

Pass #1

violaso opened this issue Jun 14, 2022 · 0 comments

Comments

@violaso
Copy link

violaso commented Jun 14, 2022

Very well done Felix!

Tour of Go

Foster variables are blähhh! #rant

func fibonacci() func() int {
	f := []int{0, 1} // child
	count := 0 // child
	//...
}

func main() {
	f := fibonacci() // parent
	//...
}

Alarm Clock

You have an idle main thread with select {}.

Your code:

func Remind(text string, seconds int64) {
	//...
}

func main() {
	go Remind("Time to eat", 10)
	go Remind("Time to work", 30)
	go Remind("Time to sleep", 60)
	select {}
}

With three threads:

func Remind(text string, delay time.Duration) {
	//...
}

func main() {
	go Remind("Time to eat", 10)
	go Remind("Time to work", 30)
	Remind("Time to sleep", 60)
}

Also, I did not know of this feature: t := time.Now().Local().Format("The time is 15.04.05:"). Nice!

Keep it up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant