def build()

in aws_lambda_builders/workflows/go_modules/builder.py [0:0]


    def build(self, source_dir_path, output_path):
        """Builds a go project onto an output path.

        :type source_dir_path: str
        :param source_dir_path: Directory with the source files.

        :type output_path: str
        :param output_path: Filename to write the executable output to.
        """
        env = {}
        env.update(self.osutils.environ)
        env.update({"GOOS": "linux", "GOARCH": self.goarch})
        runtime_path = self.binaries[self.LANGUAGE].binary_path
        cmd = [runtime_path, "build"]
        if self.trim_go_path:
            LOG.debug("Trimpath requested: Setting go build configuration to -trimpath")
            cmd += ["-trimpath"]
        if self.mode and self.mode.lower() == BuildMode.DEBUG:
            LOG.debug("Debug build requested: Setting configuration to Debug")
            cmd += ["-gcflags", "all=-N -l"]
        cmd += ["-o", output_path, source_dir_path]

        p = self.osutils.popen(cmd, cwd=source_dir_path, env=env, stdout=self.osutils.pipe, stderr=self.osutils.pipe)
        out, err = p.communicate()

        if p.returncode != 0:
            LOG.debug(err.decode("utf8").strip())
            LOG.debug("Go files not found. Attempting to build for Go files in a different directory")
            process, p_out, p_err = self._attempt_to_build_from_handler(cmd, source_dir_path, env)
            if process.returncode != 0:
                raise BuilderError(message=p_err.decode("utf8").strip())
            return p_out.decode("utf8").strip()

        return out.decode("utf8").strip()