uudashr / go-module

Go module file parsing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

⛔ [DEPRECATED] This project is no longer maintained. Use official module golang.org/x/mod, link https://pkg.go.dev/golang.org/x/mod


Build Status GoDoc

go-module

This are project for fun. Parse and read go module. Read go module

Usage

Install go get -u github.com/uudashr/go-module

Example

Given go.mod file

module my/thing
require other/thing v1.0.2
require new/thing v2.3.4
exclude old/thing v1.2.3
replace bad/thing v1.4.5 => good/thing v1.4.5
package main

import module "github.com/uudashr/go-module"

func main() {
    b, err := ioutil.ReadFile("go.mod")
    if err != nil {
        panic(err)
    }
    
    mod, err := module.Parse(string(b))
    if err != nil {
        panic(err)
    }
    
    _ = mod // now we have mod file
    // mod.Requires
    // mod.Excludes
    // mod.Repalces
}

About

Go module file parsing


Languages

Language:Go 97.5%Language:Makefile 2.5%