<commit_before>package main

import (
	"fmt"
	"github.com/peterhellberg/sseclient"
	"log"
	"os"
)

var logger *log.Logger
var urlFormat, deviceId string

func init() {
	logger = log.New(os.Stdout, "", log.LstdFlags|log.Lmicroseconds)
	urlFormat = "https://api.particle.io/v1/devices/%s/events/?access_token=%s"

}

func main() {
	settings := &OakWeatherSettings{}
	var err error
	settings, err = findSettings()
	if err != nil {
		logger.Println("Could not read settings file. reason:", err)
		logger.Println("Reverting to asking for the settings.")
		settings, err = askForSettings()
		saveSettings(*settings)
	}

	listenForWeatherEvents(settings.SelectedDevice, settings.AccessToken)
}

func listenForWeatherEvents(device Device, accessToken string) {
	url := fmt.Sprintf(urlFormat, device.Id, accessToken)
	events, err := sseclient.OpenURL(url)
	if err != nil {
		logger.Println("Error:", err)
		os.Exit(1)
	}
	logger.Printf("Connected to the stream of device %s (%s)", device.Name, device.Id)
	for event := range events {
		data_decoded := NewWeatherData(event.Data)
		logger.Println(data_decoded.asString())
	}
}<commit_msg>Handle if it returns a nil<commit_after>package main

import (
	"fmt"
	"github.com/peterhellberg/sseclient"
	"log"
	"os"
)

var logger *log.Logger
var urlFormat, deviceId string

func init() {
	logger = log.New(os.Stdout, "", log.LstdFlags|log.Lmicroseconds)
	urlFormat = "https://api.particle.io/v1/devices/%s/events/?access_token=%s"

}

func main() {
	settings := &OakWeatherSettings{}
	var err error
	settings, err = findSettings()
	if err != nil {
		logger.Println("Could not read settings file. reason:", err)
		logger.Println("Reverting to asking for the settings.")
		settings, err = askForSettings()
		saveSettings(*settings)
	}

	listenForWeatherEvents(settings.SelectedDevice, settings.AccessToken)
}

func listenForWeatherEvents(device Device, accessToken string) {
	url := fmt.Sprintf(urlFormat, device.Id, accessToken)
	events, err := sseclient.OpenURL(url)
	if err != nil {
		logger.Println("Error:", err)
		os.Exit(1)
	}
	logger.Printf("Connected to the stream of device %s (%s)", device.Name, device.Id)
	for event := range events {
		data_decoded := NewWeatherData(event.Data)
		if data_decoded != nil {
			logger.Println(data_decoded.asString())
		}
	}
}
{'fraction_non_alphanumeric': 0.1373315949587136, 'fraction_numerical': 0.001738374619730552, 'mean_word_length': 4.827848101265823, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '770434', 'n_tokens_mistral': 820, 'n_tokens_neox': 793, 'n_words': 184}