# Map in schema for go plugin

**URL:** <https://discuss.konghq.com/t/map-in-schema-for-go-plugin/5891>\
**Category:** General\
**Created:** [March 30, 2020, 9:33am UTC](https://discuss.konghq.com/t/map-in-schema-for-go-plugin/5891 "2020-03-30T09:33:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![blacktemplar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/blacktemplar/32/1833_2.png) [@blacktemplar](https://discuss.konghq.com/u/blacktemplar)\
**Post date:** [March 30, 2020, 9:33am UTC](https://discuss.konghq.com/t/map-in-schema-for-go-plugin/5891/1 "2020-03-30T09:33:50Z")

</div>

Hi guys, I am at the moment trying to write a custom plugin in go. My config scheme should contain a map, but I can’t get it working.

My config object in my go plugin looks like that:

```
type Config struct {
    MyMap map[string]string
}

```

but whenever I try to start Kong I get:

```
Error: /usr/local/share/lua/5.1/kong/cmd/start.lua:64: nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:425: error loading plugin schemas: on plugin 'my-plugin': [off] schema violation
(fields.1: {
  fields = {
    {
      keys = {
        type = "expected a string"
      },
      values = {
        type = "expected a string"
      }
    }
  }
})

```

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![kvwork](https://avatars.discourse-cdn.com/v4/letter/k/43a26b/32.png) [@kvwork](https://discuss.konghq.com/u/kvwork)\
**Post date:** [May 13, 2020, 8:16pm UTC](https://discuss.konghq.com/t/map-in-schema-for-go-plugin/5891/2 "2020-05-13T20:16:33Z")

</div>

I am also facing the same issue with slices. Trying to use custom go plugin with kong ingress controller

```
type Config struct {
	ProtectedUrls []string `json:protectedUrls`
	. . .
}

```

I get following error

```
[error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:427: error loading plugin schemas: on plugin 'my-go-plugin': [off] schema violation (fields.1: {
  fields = {
    {
      elements = {
        type = "expected a string"
      }
    }
  }
})
stack traceback:
	[C]: in function 'assert'
	/usr/local/share/lua/5.1/kong/init.lua:427: in function 'init'
	init_by_lua:3: in main chunk
nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:427: error loading plugin schemas: on plugin 'my-go-plugin': [off] schema violation (fields.1: {
  fields = {
    {
      elements = {
        type = "expected a string"
      }
    }
  }
})
stack traceback:
	[C]: in function 'assert'
	/usr/local/share/lua/5.1/kong/init.lua:427: in function 'init'
	init_by_lua:3: in main chunk
```

---

<div class="post-metadata">

**Author:** ![blacktemplar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/blacktemplar/32/1833_2.png) [@blacktemplar](https://discuss.konghq.com/u/blacktemplar)\
**Post date:** [May 14, 2020, 7:11am UTC](https://discuss.konghq.com/t/map-in-schema-for-go-plugin/5891/3 "2020-05-14T07:11:27Z")

</div>

I think solutions to both of our problems are at the moment proposed in github as pull requests: [#19](https://github.com/Kong/go-pluginserver/pull/19) for maps and [#20](https://github.com/Kong/go-pluginserver/pull/20) for slices.

I used this to build the go-pluginserver executable for my own and then it worked for me.
