// Example 1: Reading an integer value with a default fallback port := viper.GetInt("server.port", 8080) // Example 2: Reading an integer value and checking for errors port, err := viper.GetInt("server.port") if err != nil { log.Fatalf("Error reading server port: %s", err) } // Example 3: Using sub-configuration to read an integer value dbPort := viper.Sub("database").GetInt("port") // Example 4: Setting an integer value in the configuration viper.Set("server.port", 9000)In these examples, we can see how the GetInt method is used to read integer values from the configuration file. By providing a default value or checking for errors, we can ensure that our application behaves correctly even if the configuration file is missing or invalid. We can also use sub-configuration to read values from nested sections of the file, and set values using the Set method. Overall, the go github.com/spf13/viper package is a powerful and flexible tool for managing configuration in Go applications. Its comprehensive feature set and easy-to-use API make it a popular choice for developers in a range of industries, from web development to IoT and beyond.