Use fork of standard library to patch go/ast

632 Views Asked by At

I fixed a tiny bug in go/ast (see the following Github issue). I would like to already use my fix in the project I am developing. The fork that contains the fix is available on https://github.com/ec-m/go.

First, I tried the following imports:

import "github.com/ec-m/go/src/go/ast"

and

import "github.com/ec-m/go"

which resulted in various go get errors like module github.com/ec-m/go/src@upgrade found (v0.0.0-20200626183851-7b0f14cb18cb), but does not contain package github.com/ec-m/go/src/go.

Then, I followed the regular approach of using forked dependencies outlined unter https://github.com/golang/go/wiki/Modules#when-should-i-use-the-replace-directive and also mentioned in various questions, f. ex. How to fix parsing go.mod module declares its path as "x" but was required as "y".

Specifically, I included the following replace command in my go.mod

replace go/ast => github.com/ec-m/go v0.0.0-20200626183851-7b0f14cb18cb

This and some other tries (std instead of go/ast etc) did not work. After some research, I found out that replacing the standard library of Go is not possible (see this Github proposal).

What other option do I have to use my fork of the standard library of Go? I would like the approach to be as simple as possible in order avoid dependency struggles for future users of my project.

0

There are 0 best solutions below