Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 4, 2022 11:56 am GMT

Contributing to a Go open source repository

In this post we are going to list the first steps to contribute to a Go lang open source project.

In this example, we'll simulate a contribution to Bubbletea repository.

1) Fork the project

The first step is to fork the project you want to contribute. Search the project on GitHub and click on Fork: you'll get your own version of the repository <your_name>/bubbletea.
Image description

2) Clone the fork project into your computer

Clone the forked version of bubbletea into your computer. For the sake of this example, let's say you've cloned the repository at /home/forked_bubbletea on your computer.

3) Use your local forked repository

We'll create a new folder at /home/test_bubble. Create a file main.go with a simple example:

package mainimport (    "fmt"    "os"    tea "github.com/charmbracelet/bubbletea")...func main() {    p := tea.NewProgram(initialModel())    if err := p.Start(); err != nil {        fmt.Printf("Alas, there's been an error: %v", err)        os.Exit(1)    }}

Create a go.mod file by doing:

go mod init test_bubble

Then, we need to replace the library we want to contribute by our own version of the library. For this, we need to append this line at the end of the go.mod file:

...replace github.com/charmbracelet/bubbletea v0.20.0 => /home/forked_bubbletea

By doing this, when we call in main.go the library bubbletea, we are going to call our local version of the library. Therefore, we can change our local version of the library and instantly see the effects in our code.

4) Raise a pull request

Finally, after we changed and committed our local version of the repository, all we need to do is raise a pull request to the repository we want to contribute. For this, go to the repository you want to contribute and click Compare & pull request.

Image description


Original Link: https://dev.to/rafaquelhodev/contributing-to-a-go-open-source-repository-58le

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To