func (o *OutPutter) WriteHostIP(results map[string]resolve.Result, writer io.Writer) error {
	var err error
	if o.JSON {
		err = writeJSONHostIP(results, writer)
	} else {
		err = writePlainHostIP(results, writer)
	}
	return err
}
WriteHostIP writes the output list of subdomain to an io.Writer
package runner
import (
	"bufio"
	"errors"
	"io"
	"os"
	"path/filepath"
	"strings"
	jsoniter "github.com/json-iterator/go"
	"github.com/projectdiscovery/subfinder/v2/pkg/resolve"
)
type OutPutter struct {
	JSON bool
}
type jsonResult struct {
	Host   string `json:"host"`
	IP     string `json:"ip"`
	Source string `json:"source"`
}
type jsonSourceResult struct {
	Host    string   `json:"host"`
	Sources []string `json:"sources"`
}
func NewOutputter(json bool) *OutPutter {
	return &OutPutter{JSON: json}
}
func (o *OutPutter) createFile(filename string, appendtoFile bool) (*os.File, error) {
	if filename == "" {
		return nil, errors.New("empty filename")
	}
	dir := filepath.Dir(filename)
	if dir != "" {
		if _, err := os.Stat(dir); os.IsNotExist(err) {
			err := os.MkdirAll(dir, os.ModePerm)
			if err != nil {
				return nil, err
			}
		}
	}
	var file *os.File
	var err error
	if appendtoFile {
		file, err = os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
	} else {
		file, err = os.Create(filename)
	}
	if err != nil {
		return nil, err
	}
	return file, nil
}