Exercise 09.02 – using an external module within our module
Sometimes, in code, you need a unique identifier for an identity you provide to something. This unique identifier is often called a universally unique identifier (UUID). Google provides a package to create such a UUID. Let’s look at how to use it:
- Create a new directory called myuuidappand navigate into it:mkdir myuuidapp cd myuuidapp 
- Initialize a Go module named myuuidapp:go mod init myuuidapp 
- Verify that the go.modfile is created within your project directory with the module path set asmyuuidapp.
- Add a main.gofile.
- In main.go, add the main package name to the top of the file:package main 
- Now, add the imports we will use in this file:import ( Â Â Â Â "fmt" Â Â Â Â "github.com/google/uuid" ) 
- Create the main()function:func main() {
- Generate a new UUID using the external module package:Â Â Â Â id := uuid.New... 
 
                                             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                