Obtain Image ID after building image from golang client

hi i am building image by using golang client

func main() {
	df, err := os.Open("docker/Dockerfile")
	defer df.Close()
	if err != nil {
		panic(err)
		return
	}
	x,err:=ioutil.ReadAll(df)
	if err!=nil{
		log.Println(err)
		return
	}
	buf := new(bytes.Buffer)
	tw := tar.NewWriter(buf)
	defer tw.Close()
	tarHeader := &tar.Header{
		Name: "Dockerfile",
		Size: int64(len(x)),
	}
	err = tw.WriteHeader(tarHeader)
	if err != nil {
		log.Fatal(err, " :unable to write tar header")
	}
	_, err = tw.Write(x)
	if err != nil {
		log.Fatal(err, " :unable to write tar body")
	}
	dockerFileTarReader := bytes.NewReader(buf.Bytes())

	ctx := context.Background()
	cli, err := client.NewClientWithOpts(client.FromEnv)
	if err != nil {
		log.Println("Client err:",err)
		panic(err)

	}
	out:=[]types.ImageBuildOutput{
		{Type:"string",
			Attrs:map[string]string{
				"ID":"ID",
			}},
	}
	cli.NegotiateAPIVersion(ctx)
	resp, err := cli.ImageBuild(ctx, dockerFileTarReader, types.ImageBuildOptions{
		Tags:       []string{"ccxtrest/ccxt-rest:1.12.7"},
		Remove:     true,
		Outputs: out,


	})
	if err != nil {
		log.Print(err, " :unable to build docker image")
		return
	}
	defer resp.Body.Close()
	rd := bufio.NewReader(resp.Body)
	for {
		n, _, err := rd.ReadLine()
		if err != nil && err == io.EOF {
			break
		} else if err != nil {
			log.Println(err)
			return
		}
		fmt.Println(string(n))
	}
}

it works well and build image and if there is something wrong in Dockerfle e.g copying a file that doesn’t exist then it doesn’t give an error instead output stream or stdout prints the error
i want to know is there any way by which i can check image is either built successfully or failed if built successfully then i need image id