Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are Some golang.org Packages Prefixed with an `x`

Why are some golang.org package names prefixed with an x? The specific package that piqued my interest was bycrypt

My main concern is the x means something like eXperimental, and I should use a different set of libraries if I want something stable. If not that, the x is there to signify something -- I'm curious what it is.

like image 827
Alan Storm Avatar asked May 19 '16 16:05

Alan Storm


People also ask

What is golang Org X?

The x means eXternal to standard libraries. So golang.org/x is the import path for sub-repositories packages.

How do you name a package in Go?

Package names should be lowercase. Don't use snake_case or camelCase in package names. The Go blog has a comprehensive guide about naming packages with a good variety of examples.

How many packages are there in golang?

As we discussed, there are two types of packages. An executable package and a utility package.

What does package mean in golang?

Go programs are organized into packages. A package is a collection of source files in the same directory that are compiled together. Functions, types, variables, and constants defined in one source file are visible to all other source files within the same package.


2 Answers

The x means external. They are developed outside of the golang core. Experimental packages are under golang.org/x/exp

Refs: https://golang.org/pkg/#subrepo https://groups.google.com/forum/#!msg/golang-nuts/eD8dh3T9yyA/l5Ail-xfMiAJ

like image 195
eSniff Avatar answered Oct 07 '22 21:10

eSniff


Packages that are prefixed with X are part of the go project but are stored in sub repos. They are not experimental.

See: https://golang.org/pkg/#subrepo

like image 42
Josh Wilson Avatar answered Oct 07 '22 23:10

Josh Wilson