Skip to content

Commit 425a1de

Browse files
author
franck
committed
identifier names MUST start with a captial letter to be exported
1 parent 94bc7b7 commit 425a1de

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

main.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,22 @@ import (
2222

2323
var pingPollingFreq = 5 * time.Second
2424

25-
//handlerSqlConnexion is a type of variable to help us manage our connexion to the SQL databases
26-
type handlerSqlConnexion struct {
25+
// Important GOTCHA
26+
// See https://stackoverflow.com/questions/24487943/invoking-struct-function-gives-cannot-refer-to-unexported-field-or-method
27+
// An identifier may be exported to permit access to it from another package. An identifier is exported if both:
28+
// - the first character of the identifier's name is a Unicode upper case letter (Unicode class "Lu"); and
29+
// - the identifier is declared in the package block or it is a field name or method name.
30+
31+
//HandlerSqlConnexion is a type of variable to help us manage our connexion to the SQL databases
32+
type HandlerSqlConnexion struct {
2733
DSN string // aurora database connection string
2834
APIAccessToken string
2935
db *sql.DB
3036
environmentId int
3137
}
3238

33-
// environment is a type of variable to help us manage our differing {dev,demo,prod} AWS accounts
34-
type environment struct {
39+
// Environment is a type of variable to help us manage our differing {dev,demo,prod} AWS accounts
40+
type Environment struct {
3541
environmentId int
3642
Cfg aws.Config
3743
AccountID string
@@ -49,7 +55,7 @@ const (
4955
// GetSecret is the Golang equivalent for
5056
// aws --profile your-aws-cli-profile ssm get-parameters --names API_ACCESS_TOKEN --with-decryption --query Parameters[0].Value --output text
5157

52-
func (thisEnvironment environment) GetSecret(key string) string {
58+
func (thisEnvironment Environment) GetSecret(key string) string {
5359

5460
val, ok := os.LookupEnv(key)
5561
if ok {
@@ -75,7 +81,7 @@ func (thisEnvironment environment) GetSecret(key string) string {
7581
// NewConfig setups the configuration assuming various parameters have been setup in the AWS account
7682
// - DEFAULT_REGION
7783
// - STAGE
78-
func NewConfig(cfg aws.Config) (thisEnvironment environment, err error) {
84+
func NewConfig(cfg aws.Config) (thisEnvironment Environment, err error) {
7985

8086
// Save for ssm
8187
thisEnvironment.Cfg = cfg
@@ -144,7 +150,7 @@ func NewConfig(cfg aws.Config) (thisEnvironment environment, err error) {
144150
}
145151
}
146152

147-
func (thisEnvironment environment) BugzillaDSN() string {
153+
func (thisEnvironment Environment) BugzillaDSN() string {
148154

149155
// Get the value of the variable BUGZILLA_DB_USER
150156
var bugzillaDbUser string
@@ -232,7 +238,7 @@ func (thisEnvironment environment) BugzillaDSN() string {
232238

233239
// NewDbConnexion setups what we need to access the DB assuming various parameters have been setup in the AWS account
234240

235-
func NewDbConnexion() (bzDbConnexion handlerSqlConnexion, err error) {
241+
func NewDbConnexion() (bzDbConnexion HandlerSqlConnexion, err error) {
236242

237243
// We get the AWS configuration information for the default profile
238244
cfg, err := external.LoadDefaultAWSConfig()
@@ -281,7 +287,7 @@ func NewDbConnexion() (bzDbConnexion handlerSqlConnexion, err error) {
281287
}
282288

283289
// We have everything --> We create the database connexion string
284-
bzDbConnexion = handlerSqlConnexion{
290+
bzDbConnexion = HandlerSqlConnexion{
285291
DSN: thisEnvironment.BugzillaDSN(), // `BugzillaDSN` is a function that is defined in the uneet/env/main.go dependency.
286292
APIAccessToken: apiAccessToken,
287293
environmentId: thisEnvironment.environmentId,
@@ -375,7 +381,7 @@ func Towr(currentBzConnexion http.Handler) func(http.ResponseWriter, *http.Reque
375381
}
376382
}
377383

378-
func (thisEnvironment environment) Bucket(svc string) string {
384+
func (thisEnvironment Environment) Bucket(svc string) string {
379385

380386
// Most common bucket
381387
if svc == "" {
@@ -402,7 +408,7 @@ func (thisEnvironment environment) Bucket(svc string) string {
402408
}
403409
}
404410

405-
func (thisEnvironment environment) SNS(name, region string) string {
411+
func (thisEnvironment Environment) SNS(name, region string) string {
406412
// TODO: Check: if service name is empty, should this be a fatal error???
407413
if name == "" {
408414
log.Warn("SNS Warning: Service string empty")
@@ -411,7 +417,7 @@ func (thisEnvironment environment) SNS(name, region string) string {
411417
return fmt.Sprintf("arn:aws:sns:%s:%s:%s", region, thisEnvironment.AccountID, name)
412418
}
413419

414-
func (thisEnvironment environment) Udomain(service string) string {
420+
func (thisEnvironment Environment) Udomain(service string) string {
415421
if service == "" {
416422
log.Warn("Udomain warning:Service string empty")
417423
return ""

0 commit comments

Comments
 (0)