MCPcopy
hub / github.com/sqlc-dev/sqlc / StartMySQLServer

Function StartMySQLServer

internal/sqltest/native/mysql.go:19–42  ·  view source on GitHub ↗

StartMySQLServer starts an existing MySQL installation natively (without Docker).

(ctx context.Context)

Source from the content-addressed store, hash-verified

17
18// StartMySQLServer starts an existing MySQL installation natively (without Docker).
19func StartMySQLServer(ctx context.Context) (string, error) {
20 if err := Supported(); err != nil {
21 return "", err
22 }
23 if mysqlURI != "" {
24 return mysqlURI, nil
25 }
26 value, err, _ := mysqlFlight.Do("mysql", func() (interface{}, error) {
27 uri, err := startMySQLServer(ctx)
28 if err != nil {
29 return "", err
30 }
31 mysqlURI = uri
32 return uri, nil
33 })
34 if err != nil {
35 return "", err
36 }
37 data, ok := value.(string)
38 if !ok {
39 return "", fmt.Errorf("returned value was not a string")
40 }
41 return data, nil
42}
43
44func startMySQLServer(ctx context.Context) (string, error) {
45 // Standard URI for test MySQL

Callers 3

TestExpandMySQLFunction · 0.92
TestReplayFunction · 0.92
MySQLFunction · 0.92

Calls 2

SupportedFunction · 0.85
startMySQLServerFunction · 0.70

Tested by 2

TestExpandMySQLFunction · 0.74
TestReplayFunction · 0.74