|
Golang Packaging Guidelines
|
Golang -paketoinnin ohjeet
|
|
This document details best practices for packaging Golang packages. Most of it is automated by an extensive use of macros.
|
Tässä asiakirjassa kuvataan parhaita käytäntöjä Golang-pakettien paketoimiseen. Suurin osa paketoinnista on automatisoitu käyttämällä laajasti makroja.
|
|
https://pagure.io/GoSIG/go2rpm/[go2rpm] is tool that automates many of these steps. It is advisable to try `+go2rpm import_path+` first before attempting to write a SPEC by hand.
|
https://pagure.io/GoSIG/go2rpm/[go2rpm] on työkalu, joka automatisoi monet näistä vaiheista. On suositeltavaa kokeilla `+go2rpm import_path+` ennen kuin yrität kirjoittaa SPEC:n käsin.
|
|
Import Path
|
Tuontipolku
|
|
In Golang, packages are referenced by full URLs. Since this URL is referenced in several places throughout the rpmspec, set the base import path as a global define at the top of the spec file
|
Golangissa paketteihin viitataan täydellä URL-osoitteella. Koska tähän URL-osoitteeseen viitataan useissa paikoissa rpmspecissä, aseta perustuontipolku globaaliksi määritteeksi spesifikaatiotiedoston alussa
|
|
%global goipath github.com/kr/pretty
|
%global goipath github.com/kr/pretty
|
|
All macros, including package name, source URL, will be computed from this value.
|
Kaikki makrot, mukaan lukien paketin nimi ja lähde-URL, johdetaan tästä arvosta.
|
|
*Take the time to identify it accurately.* Changing it later will be inconvenient.
|
*Käytä aikaa sen tarkkaan tunnistamiseen.* Sen vaihtaminen myöhemmin on hankalaa.
|
|
it may differ from the repository URL;
|
se voi poiketa arkiston URL-osoitteesta;
|
|
generally, the correct value will be the one used by the project in its documentation, coding examples, and build assertions;
|
yleensä oikea arvo on se, jota projekti käyttää dokumentaatiossaan, koodausesimerkeissä ja koontivahvistuksissa;
|
|
use the gopkg import path for all code states when a project uses it.
|
käytä gopkg-tuontipolkua kaikissa kooditiloissa, kun projekti käyttää sitä.
|
|
If upstream confused itself after multiple forks and renamings, you will need to fix references to past names in the Go source files, unit tests included. Perform this fixing in `+%prep+`.
|
Jos yläjuoksu meni sekaisin useiden haarojen ja uudelleennimeämisen jälkeen, sinun on korjattava viittaukset menneisiin nimiin Go-lähdetiedostoissa, mukaan lukien yksikkötestit. Suorita tämä korjaus kohdassa `+%prep+`.
|
|
Naming
|
Nimeäminen
|
|
Source packages (src.rpm)
|
Lähdepaketit (src.rpm)
|
|
Golang source packages MUST be named after their main import path. This process is automated by the `+%{goname}+` macro. This macro will remove any capitalization, "go" keywords, and any duplication in the import path.
|
Golang-lähdepaketit TÄYTYY nimetä niiden päätuontipolun mukaan. Tämä prosessi on automatisoitu makrolla `+%{goname}+`. Tämä makro poistaa kaikki isot kirjaimet, "go"-avainsanat ja päällekkäisyydet tuontipolusta.
|
|
For example:
|
Esimerkiksi:
|
|
the import path `+github.com/kr/pretty+` will become `+golang-github-kr-pretty+`
|
tuontipolusta `+github.com/kr/pretty+` tulee `+golang-github-kr-pretty+`
|
|
the import path `+github.com/DATA-DOG/go-txdb+` will become `+golang-github-data-dog-txdb+`
|
tuontipolusta `+github.com/DATA-DOG/go-txdb+` tulee `+golang-github-data-dog-txdb+`
|
|
the import path `+github.com/gopherjs/gopherjs+` will become `+golang-github-gopherjs+`
|
tuontipolusta `+github.com/gopherjs/gopherjs+` tulee `+golang-github-gopherjs+`
|
|
The filename of spec MUST match the name of the package.
|
Spec tiedostonimen TÄYTYY vastata paketin nimeä.
|