我可以在map [string] interface {}上定义一个函数吗

I have tried

 func (m map[string]interface{}) Foo() {
     ...
    }

and

 func (m *map[string]interface{}) Foo() {
     ...
    }

but go test errors with

invalid receiver type map[string]interface {} (map[string]interface {} is an unnamed type)

so I have to add some more text to keep SO happy here

You need to define a new type to be able to attach a method to it.

package main

import "fmt"

type MyMap map[string]interface{}

func (m MyMap) Foo() {
        fmt.Println("You fool!")
}

func main(){
  m := new(MyMap)
  m.Foo()
}