7.Packages/

directory
v0.0.0-...-878d094 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2018 License: MIT

README

What is a Package?

  • A focused area of functionality
  • Most Go programs are broken into multiple packages
  • Each directory in a go program is associated with a unique package

How to use a Package?

  • We use packages by importing them
import (
    "fmt"  // package1
    "strings" //package2
)
// How we use the functions/variables contained in a imported package
// packagename.function()or variable
fmt.Println("This is how we use the functions from imported packages")
  • In Go programming language packages can be define in three categories. They are

    1. Own packages (Packages you create)
    2. Third-party packages (Packages created by someone)
    3. Packages that are in Go standard library
  • In a package if we want to make variable/function public then the first letter should be capitalized

  • Using relative path for importing local packages is considered bad practice

Resources

Directories

Path Synopsis
1.stdlib

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL