tcexe

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2021 License: GPL-3.0 Imports: 1 Imported by: 18

README

TC-EXE

exe runner for windows.

A Go module that provides a alternative to exec.LookPath() on Windows.

The following, relatively common approach to running external commands has a vulnerability on Windows:

import "os/exec"

func goMod() error {
    cmd := exec.Command("go", "mod", "download)
    return cmd.Run()
}

Searching the current directory (surprising behavior) before searching folders listed in the PATH environment variable (expected behavior) seems to be intended in Go and unlikely to be changed: https://github.com/golang/go/issues/38736

Example use:

import (
    "os/exec"
    tcexe "github.com/Timothee-Cardoso/tc-exe"
)

func goMod() error {
    goPath, err := tcexe.LookPath("git")

    if err != nil {
        return err
    }

    cmd := exec.Command(goPath, "mod", "download")
    return cmd.Run()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LookPath

func LookPath(file string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL