Skip to content

undefined: mysql.NewConnector #92

@wayneashleyberry

Description

@wayneashleyberry
../../../../go/pkg/mod/github.com/newrelic/[email protected]+incompatible/_integrations/nrmysql/nrmysql.go:79:20: undefined: mysql.NewConnector

I've started implementing the new MySQL client added in v2.8.0 and immediately get a compiler error.

It's worth noting here that I am using jmoiron/sqlx, but I am not sure if that's related. I tried with the regular standard library and got the same issue.

I did see the documentation about using nrmysql.NewConnector instead of mysql.NewConnector but I'm not calling that method anywhere in my code. The only place I can find a call to that method in my code, and all of its' dependencies, is in this library.

30:// If your code is using mysql.NewConnector, simply use nrmysql.NewConnector
76:// NewConnector can be used in place of mysql.NewConnector to get an
79:	connector, err := mysql.NewConnector(cfg)

This happened after only changing the client, nothing else. Here is that diff:

diff --git a/cmd/serve/serve.go b/cmd/serve/serve.go
index 3b721f2..f33762f 100644
--- a/cmd/serve/serve.go
+++ b/cmd/serve/serve.go
@@ -17,6 +17,9 @@ import (
        "github.com/spf13/cobra"
        "go.uber.org/zap"
+
+       // new relic mysql client
+       _ "github.com/newrelic/go-agent/_integrations/nrmysql"
 )

 // Command contains the serve command implementation
@@ -38,7 +41,7 @@ func Command() *cobra.Command {

                        conf := database.Config(spec, nil)

-                       db, err := sqlx.Connect("mysql", conf.FormatDSN())
+                       db, err := sqlx.Connect("nrmysql", conf.FormatDSN())
                        if err != nil {
                                ctxlog.Fatal(err.Error())
                        }
go version go1.12.6 darwin/amd64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions