Relative Content

Tag Archive for go

How to skip a package-level example in Go?

I have a package level example which I would like to skip running if an environmental variable is not provided. If I just return from it, then output does not match the expected output and when it runs as a test, the test fails.

How to use maths as package in main file in golang

I have a Golang folder with test.go file that contains main function and part of package main. Now I have a subfolder, sibling of test.go named maths which contain a add.go file. Now I want to know how can i get this add method from maths folder to test.go to execute.

Go test mock cron job

To mock the cron job( robfig cron ) or to assert the job was invoked at least once from the func abc(). When running the test, it calls the real cron job and waits till the schedule starts.

Updating a slice from a goroutine

I’m having trouble trying to work out how to update a slice from parallel goroutines. I initially came up with this code (that I knew wasn’t the correct way to do it!):