Skip to content

Interfaces or pointers in struct definitions #10

Description

@ivancorrales

Just wondering if gocofig will consider dealing with interfaces and pointers in struct definitions

Currently I have the below code :

package core

import (
	"github.com/fulldump/goconfig"
	"laika/pkg/provider"
)

var Config *LaikaConfig

type LaikaConfig struct {
	Provider Provider
}

func init(){
	Config = defaultConfiguration()
	goconfig.Read(Config)
}

func defaultConfiguration() *LaikaConfig {
	return &LaikaConfig{
		Provider: Slack{
			Token: "********,
		},
	}
}

type Provider interface {
	GetSecurityInfo() map[string]string
}


type Slack struct {
	//Token field
	Token string
	//Channel field
	Channel string
}


func (slack Slack) GetSecurityInfo() map[string]string{
	return map[string]string{
		provider.SlackToken: slack.Token,
	}
}

and the attached error occurs.

Error when making use of itnerfaces

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions