<commit_before>package main

import (
	"github.com/elastic/libbeat/logp"
	"net"
)

type Target struct {
	name      string
	tag       string
	ipv4Addrs []net.IPAddr
	ipv6Addrs []net.IPAddr
}

func (t *Target) Init(name string, tag string) {
	t.name = name
	t.tag = tag
	logp.Debug("target", "Getting IP addresses for %s:\n", t.name)
	addrs, err := net.LookupIP(t.name)
	if err != nil {
		logp.Err("target", "Failed to resolve %s to IP address\n", t.name)
	}
	for j := 0; j < len(addrs); j++ {
		if addrs[j].To4() != nil {
			logp.Debug("target", "IPv4: %s\n", addrs[j].String())
			t.ipv4Addrs = append(t.ipv4Addrs, net.IPAddr{IP: addrs[j]})
		} else {
			logp.Debug("target", "IPv6: %s\n", addrs[j].String())
			t.ipv6Addrs = append(t.ipv6Addrs, net.IPAddr{IP: addrs[j]})
		}
	}
}<commit_msg>Better handling of failure to resolve target to IP address.<commit_after>package main

import (
	"github.com/elastic/libbeat/logp"
	"net"
)

type Target struct {
	name      string
	tag       string
	ipv4Addrs []net.IPAddr
	ipv6Addrs []net.IPAddr
}

func (t *Target) Init(name string, tag string) {
	t.name = name
	t.tag = tag
	logp.Debug("target", "Getting IP addresses for %s:\n", t.name)
	addrs, err := net.LookupIP(t.name)
	if err != nil {
		logp.Warn("Failed to resolve %s to IP address, ignoring this target.\n", t.name)
	} else {
		for j := 0; j < len(addrs); j++ {
			if addrs[j].To4() != nil {
				logp.Debug("target", "IPv4: %s\n", addrs[j].String())
				t.ipv4Addrs = append(t.ipv4Addrs, net.IPAddr{IP: addrs[j]})
			} else {
				logp.Debug("target", "IPv6: %s\n", addrs[j].String())
				t.ipv6Addrs = append(t.ipv6Addrs, net.IPAddr{IP: addrs[j]})
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.1803968731208659, 'fraction_numerical': 0.012026458208057728, 'mean_word_length': 3.437333333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '553314', 'n_tokens_mistral': 734, 'n_tokens_neox': 705, 'n_words': 162}