1

I am fairly new to using Go and I have noticed when I build the Go project I have cloned from GitHub via:

$ go build

The executable is built, but when I run:

$ mediamtx --version

I get v0.0.0

I Googled the issue and found that I could set the Idflags parameter to set the version on build so I tried:

go build -ldflags="-X 'github.com/bluenviron/mediamtx/internal/core.Version=v1.5.0'"

Unfortunately, I ended up with the exact same problem, and Idflags appears to do nothing, with no errors the executable still builds. I have tried deleting and starting again from a git clone and running the command with sudo, haven't managed to get it to work, and not sure what I am doing wrong. This is what I am trying to go build with Idflags :

MediaMTX

This is the content of my main.go which I got my path for GitHub to include in my Idflags directive

// main executable.
package main

import ( "os"

    "github.com/bluenviron/mediamtx/internal/core"

)

func main() { s, ok := core.New(os.Args[1:]) if !ok { os.Exit(1) } s.Wait() }

1 Answers1

1

The answer is the "version" parameter in Idflags is case sensitive I was using an uppercase V "Version" when I should have been using a lower case v "version"

go build -ldflags="-X 'github.com/bluenviron/mediamtx/internal/core.version=v1.5.0'"

is the correct CLI command

Your best reference for fixing this is to refer to your core.go file to find the version variable declaration:

~/mediamtx/internal/core/ [main] vi core.go

In my case the version variable was defined as:

var version = "v0.0.0"

The issue is now resolved and:

mediamtx --version

Now outputs:

v1.5.0