sijie commented on a change in pull request #4746: [go function] fix: go function should parse conf content first URL: https://github.com/apache/pulsar/pull/4746#discussion_r305357179
########## File path: pulsar-function-go/conf/conf.go ########## @@ -87,17 +87,23 @@ func (c *Conf) GetConf() *Conf { flag.Usage() } + if confContent == "" && confFilePath == "" { + log.Errorf("no yaml file or conf content provided") + return nil + } + if confFilePath != "" { yamlFile, err := ioutil.ReadFile(confFilePath) - if err != nil { + if err == nil { + err = yaml.Unmarshal(yamlFile, c) + if err != nil { + log.Errorf("unmarshal yaml file error:%s", err.Error()) + return nil + } + } else if (err != nil || os.IsNotExist(err)) && confContent == "" { Review comment: yes. you need to handle two case: if the err is not IsNotExist, it means it encounters other issues on reading the configuration, it should panic. if the err is IsNotExist, then you check if confContent == "", if it doesn't exist, you panic. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services