Reading a process name how it is displayed in Windows Task Manager in Golang


I’m currently trying to read the name of a process in Go how it is represented in the windows task manager.

However, when I read it in Go it is displayed always as the executable. I’m trying to get it how it is named in the task manager.


package main

import (


func main() {
    p, _ := process.Processes()
    for _, pr := range p {

This outputs all process names but none match how it is shown here:

enter image description here

I am trying to read the Spotify process name that is displayed with the song title.


Get window title

Each time you open the "Windows Task Manager" it searches for .Net process.MainWindowTitle property, so you cant grep Windows title using gopsutil … you have to use some Go wrapper for the .NET Core Runtime , not sure maybe this one would be helpful … or even use C# instead of Golang

Get currently playing track on Spotify

Spotify has awesome docs with API usage for such case
so you only need to generate auth token and convert next curl request to golang fetch function

curl -X "GET" "" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer <<YOUR TOKEN>>"

Answered By – madzohan

Answer Checked By – Katrina (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.