Skip to content

"github.com/kffl/gocannon" is a program, not an importable package on build when using as a library #58

@DistributedMadlad

Description

@DistributedMadlad

I'm getting the following error when I try to use gocannon as a library in a program:

> go build
main.go:9:2: import "github.com/kffl/gocannon" is a program, not an importable package

Code:

package main

import (
	"fmt"
	"os"
	"runtime"
	"time"

	gocannon "github.com/kffl/gocannon"
	"github.com/kffl/gocannon/common"
)

func main() {
	duration := time.Second * 1
	connections := 50
	cpus := runtime.NumCPU()
	timeout := time.Millisecond * 200
	mode := "reqlog"
	outputFile := ""
	interval := time.Millisecond * 250
	preallocate := 1000
	method := "GET"
	body := common.RawRequestBody{}
	header := common.RequestHeaders{}
	trustAll := false
	format := "default"
	plugin := ""
	target := "http://localhost:8080/v1/dict/roles"

	cfg := common.Config{
		Duration:    &duration,
		Connections: &connections,
		CPUs:        &cpus,
		Timeout:     &timeout,
		Mode:        &mode,
		OutputFile:  &outputFile,
		Interval:    &interval,
		Preallocate: &preallocate,
		Method:      &method,
		Body:        &body,
		Headers:     &header,
		TrustAll:    &trustAll,
		Format:      &format,
		Plugin:      &plugin,
		Target:      &target,
	}
	g, err := gocannon.NewGocannon(cfg)

	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	g.Run()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions