skip to Main Content

I am learning Go lang by this video tutorial https://youtu.be/LOn1GUsjOF4?t=163 . My environment: Windows 11 x64, Visual Studio Code 1.75.1 (latest), Go v1.20.1 (latest).

File main.go

package main

import "fmt"

func main() {
    fmt.Println("We good")
}

File go.mod

module newsfeeder

go 1.20

File makefile

dev:
    go run main.go  

enter image description here

PS D:temp2023_02_24newfeeder> go mod init newsfeeder
go: creating new go.mod: module newsfeeder
go: to add module requirements and sums:
        go mod tidy
PS D:temp2023_02_24newfeeder> go run .main.go
hi
PS D:temp2023_02_24newfeeder> go run .main.go
hi
PS D:temp2023_02_24newfeeder> go run .main.go
function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ make dev
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (make:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS D:temp2023_02_24newfeeder>

How can I fix it?

2

Answers


  1. Chosen as BEST ANSWER

    go to https://sourceforge.net/projects/mingw/postdownload , download, install

    enter image description here

    Set environment PATH , run "C:MinGWbinmingw-get.exe"

    Microsoft Windows [Version 10.0.22621.1265]
    (c) Microsoft Corporation. All rights reserved.
    
    C:Usersadmin>cd C:WindowsSystem32cmd.exe
    The directory name is invalid.
    
    C:Usersadmin>cd D:temp2023_02_24newfeeder
    
    C:Usersadmin>cd /d D:temp2023_02_24newfeeder
    
    D:temp2023_02_24newfeeder>mingw32-make
    go run main.go
    We good
    
    D:temp2023_02_24newfeeder>
    

  2. The ms-vscode.makefile-tools extension does not come with an installation of the make program.

    See this quote from bobrow, one of the maintainers of the extension on GitHub:

    The extension does not install make. It is usually installed with your compiler (in the same folder). It doesn’t have a standalone installer which is why we don’t provide instructions on how to get it.

    For your learning purposes, all I did to find that GitHub issue (where the issue ticket raiser pretty much has the same problem as you- or at least- has the same error message as you), is google ""function, script file, or operable program" site:github.com/Microsoft/vscode-makefile-tools/issues".

    You need to make sure your either already have it installed with your (C or C++) compiler or install it yourself, and make sure that it is visible in the PATH environment variable when you run VS Code (which usually means adding the directory containing the executable to your system path, which will usually be done for you when running installers or installing things via package-management systems). Since in your case you are on Windows, and you are using Makefiles for Go programming (interesting / eyebrow raiser), you probably don’t have the make program installed yet. As others have said, you can install it from https://sourceforge.net/projects/mingw/postdownload, or from a package manager like Chocolatey (see https://community.chocolatey.org/packages/make).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search