Skip to main content
Filter by
Sorted by
Tagged with
0 votes
2 answers
236 views

I'm using Go 1.24.3, installed via Homebrew on an Apple M1, running Sequoia 15.5. I have a main: //main.go package main import "fmt" func main() { fmt.Println("Hello, world!") }...
GKelly's user avatar
  • 3,949
0 votes
1 answer
138 views

I modified a function from a book I was reading, the function writes "ping" to a writer at a predefined interval. The program runs in a go routine so I appended a context so the function can ...
Dassy Areg's user avatar
1 vote
2 answers
293 views

I have a program that calls a web service and I want to write a unit test that checks the correct failure handling (nothing fancy). I use net/http/httptest to simulate the web service (backend). But I ...
Thomas W.'s user avatar
  • 824
-1 votes
1 answer
69 views

I have a generator which generates me code in Go, for example: foo.go bar.go ... After generation, I need to test if my generator is doing good job. For every generated file, I have a test ...
GreyCat's user avatar
  • 17.2k
-3 votes
1 answer
347 views

As far as I tested, go test -- <custom flag(s)> works but I couldn't find any documentation for it. I have this test code: package main import ( "os" "testing" ) ...
ynn's user avatar
  • 5,077
1 vote
0 answers
147 views

This is my test: // A test of TestSuite func (ts *TestSuite) TestMyThing() { cmd := RootCmd() b := bytes.NewBufferString("") cmd.SetOut(b) cmd.SetErr(b) err := cmd....
red888's user avatar
  • 32.3k
4 votes
1 answer
5k views

I'm currently running a suite of tests in Go using the go test ./... command. This suite contains multiple test functions, and the execution time exceeds 10 minutes. Unfortunately, the go test command ...
Sruthi CP's user avatar
  • 452
2 votes
1 answer
41 views

I am a Go newbie. I have written an API server built on the Echo server, using the DeepMap OpenAPI generator and Postgres using pgxpool. It is working well enough and has been in use for a year, but ...
Drew's user avatar
  • 121
2 votes
0 answers
611 views

I have a project in go lang, I can run tests and sonar can identify the total percentage of test coverage. But I want to know if I can generate any metrics in this coverage.out file that can show how ...
Murilo Alves's user avatar
-1 votes
1 answer
156 views

I am having trouble testing foo_handler in my Go project. My project has the following structure: ├── Makefile ├── cmd │ └── main.go ├── go.mod ├── go.sum └── internal ├── api │ ├── router....
Dana 's user avatar
  • 57
1 vote
1 answer
541 views

I was looking at some benchmark tests from https://github.com/RoaringBitmap/roaring When running a specific benchmark using -run - (as mentioned in there comments): go test -bench BenchmarkNexts -...
Chris's user avatar
  • 585
0 votes
1 answer
1k views

In golang, I often see a member function calling another member function of the same object. For example check following golang code: type Obj struct{} func (o Obj) First() { // do something ...
Vikas Kaushik's user avatar
1 vote
0 answers
65 views

Consider the following code: package ifaces import ( "fmt" "testing" ) type IFace1 interface { Do1() } type IFace2 interface { ...
caxcaxcoatl's user avatar
  • 9,040
5 votes
1 answer
1k views

In my Go code, I have to use filepath.Abs() several times, which may lead to different errors that my method returns. func (s *service) myFunc(path string) error { dir := s.Component().Dir() ...
Apollo's user avatar
  • 1,908
2 votes
0 answers
564 views

I am trying to test a gRPC service locally. Here is the sample code type TestGrpcServer struct { t *testing.T Server *grpc.Server Lis *bufconn.Listener Conn *grpc.ClientConn }...
Sanath Manavarte's user avatar
-1 votes
1 answer
3k views

I compiled a Go test library by running go test -c ./model. According to Go docs it can be run using go run -exec xprog command, however, I keep getting errors while trying to run my generated model....
mevoker659's user avatar
0 votes
2 answers
2k views

I try to test function StartP, Expect that Start() should be called 1 times, Done() should be called 1 times but I have trouble that test will block when run this step <-ps.Done() I expect <-ps....
Y. Ryan's user avatar
  • 11
1 vote
0 answers
188 views

I'm running gotestsum --junitfile-testcase-classname=short --junitfile-testsuite-name=relative \ -- -coverprofile=coverage.out ./serviceName/... The structure looks like this: serviceName ...
treesan's user avatar
  • 49
5 votes
0 answers
474 views

I am using the -cover to collect coverage in my Go project. However, it seems that the tests have to be 100% success rate in order to get the coverage report. Is there any way I can get the coverage ...
cxc's user avatar
  • 263
1 vote
1 answer
89 views

Consider a multi binary project with the following structure. . ├── bin1 │   ├── config │   │   ├── config.go │   │   └── config_test.go │   └── utils │   ├── utils.go │   └── utils_test.go ├──...
kexic63212's user avatar
1 vote
1 answer
703 views

I am new to golang, I have a task to collect the application logs, application is running as deployment in k8s cluster, there are 4 pods in total. As part of test automation, I need to collect the ...
Karthic.K's user avatar
  • 446
1 vote
1 answer
181 views

I am writing e2e tests for a command line app where I have to do file manipulation (such as cp, mv, rm, touch, and mkdir). The tests can execute just fine in my local environment. The problem occurs ...
cxc's user avatar
  • 263
1 vote
0 answers
360 views

I have many classes of test, which are marked with build constraints, e.g.: //go:build all || (!foo && !bar && !baz && quux) for the test class quux. This is okay, as far as ...
YoureIt's user avatar
  • 21
1 vote
1 answer
3k views

For example, I have this test here assert.Contains(t, "HELLO WORLD", "hello world) and I want this to return true. Obviously, I can clean up the string with strings.TrimSpace(), ...
cxc's user avatar
  • 263
7 votes
1 answer
7k views

I understand that in order to avoid cached results in Go tests you can use the -count=1 flag in the go test command, but why? This is from the docs: The idiomatic way to disable test caching ...
asaf92's user avatar
  • 1,901