我如何解析文本并设置其格式以将其作为json数据发送

I'm creating a Discord bot that listens on a channel in a very popular video games server, they have a bot in there that is manually commanded by majority commands to announce certain things like boss spawns. Here is an example of the text:

# Red Nose
Mon, 06:45 EST - Mon, 15:15 EST <Spawnable>

# Kutum
Mon, 09:25 EST - Mon, 17:55 EST [Window begins](in 2 hours)

# Karanda
Mon, 09:50 EST - Mon, 14:20 EST [Window begins](in 3 hours)

# Dastard Bheg
Mon, 11:15 EST - Mon, 19:45 EST [Window begins](in 4 hours)

# Nouver
Mon, 12:30 EST - Mon, 18:00 EST [Window begins](in 6 hours)

# Kzarka
Mon, 14:10 EST - Mon, 18:40 EST [Window begins](in 7 hours)

# Dim Tree Spirit
Mon, 15:50 EST - Tue, 00:20 EST [Window begins](in 9 hours)

# Giant Mudster
Mon, 16:55 EST - Tue, 01:25 EST [Window begins](in 10 hours)

I have my bot connected to the server and reading chat messages just fine, but I'm wondering what the cleanest way to parse this data would be. I'm going to have the data formatted like so:

type Boss struct {
    Name              string `json:"name"`
    SpawnWindowBegins string `json:"spawnWindowBegins"`
    TimeTilWindow     string `json:"timeTilWindow"`
}

So for example I need to parse

Name = Red Nose
SpawnWindowBegins = Mon, 06:45 EST - Mon, 15:15 EST
TimeTilWindow = Spawnable || in X hours

So that I can send the data through a websocket to my site and process that which I can do just fine I'm just not sure the best way to parse that text into a struct, reliably. Thanks.

In general I would recommend using a regex to do this type of parsing. Create a regex to identify your keys and then patch your data structure as needed.

nameValueParseRegex := regexp.MustCompile(`^(.*) = (.*)$?\z`)

lines := []string{
    `Name = Red Nose`,
    `SpawnWindowBegins = Mon, 06:45 EST - Mon, 15:15 EST`,
    `Wrong format line`,
    `TimeTilWindow = Spawnable || in X hours`,
}

boss := Boss{}
for _, value := range lines {
    lineResult := nameValueParseRegex.FindAllStringSubmatch(value, -1)

    if lineResult != nil && len(lineResult) > 0 {

        if lineResult[0][1] == "Name" {
            boss.Name = lineResult[0][2]
        }

        if lineResult[0][1] == "SpawnWindowBegins" {
            boss.SpawnWindowBegins = lineResult[0][2]
        }

        if lineResult[0][1] == "TimeTilWindow" {
            boss.TimeTilWindow = lineResult[0][2]
        }

    }

}

s, _ := json.Marshal(boss)
fmt.Printf("%s", s)

Output:

{"name":"Red Nose","spawnWindowBegins":"Mon, 06:45 EST - Mon, 15:15 EST","timeTilWindow":"Spawnable || in X hours"}