func WriteJSONOutput(host, ip string, ports map[int]struct{}, writer io.Writer) error {
	encoder := json.NewEncoder(writer)
	data := JSONResult{}
	if host != ip {
		data.Host = host
	}
	data.IP = ip
	for port := range ports {
		data.Port = port
		err := encoder.Encode(&data)
		if err != nil {
			return err
		}
	}
	return nil
}
WriteJSONOutput writes the output list of subdomain in JSON to an io.Writer
package runner
import (
	"bufio"
	"encoding/json"
	"io"
	"strconv"
	"strings"
)
type JSONResult struct {
	Host string `json:"host,omitempty"`
	IP   string `json:"ip,omitempty"`
	Port int    `json:"port"`
}
func WriteHostOutput(host string, ports map[int]struct{}, writer io.Writer) error {
	bufwriter := bufio.NewWriter(writer)
	sb := &strings.Builder{}
	for port := range ports {
		sb.WriteString(host)
		sb.WriteString(":")
		sb.WriteString(strconv.Itoa(port))
		sb.WriteString("\n")
		_, err := bufwriter.WriteString(sb.String())
		if err != nil {
			bufwriter.Flush()
			return err
		}
		sb.Reset()
	}
	return bufwriter.Flush()
}