Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8699721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:01:11+00:00 2026-06-13T02:01:11+00:00

In the Go programming language, why after importing a package do I still have

  • 0

In the Go programming language, why after importing a package do I still have to prefix a method within that package with the package name?

i.e.

import "io/ioutil"

func main() { 
    content, err = iotuil.ReadFile("somefile.txt")
    // etc..
}

Isn’t this redundant? In Java, for example, you can do things like importing Files.readAllLines etc without having Files imported.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:01:12+00:00Added an answer on June 13, 2026 at 2:01 am

    I guess this doesn’t really answer your question, but if you want, you can actually call the methods without explicitly stating the package – just import with a . in front of the names (but this is not recommended; see below):

    package main
    
    import (
      . "fmt"
      . "io/ioutil"
    )
    
    func main () {
      content, err := ReadFile("testfile")
      if err != nil {
        Println("Errors")
      }
      Println("My file:\n", string(content))
    }
    

    Note @jimt’s comment below – this practice is not advised outside of tests as it could cause name conflicts with future releases. Also, definitely agree with @DavidGrayson’s point of being nicer to read/see where things come from.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Programming language: Java Ok, so I want to have a BufferedImage that keeps rotating
After extensive reading of ISO/IEC 14882, Programming language – C++ I'm still unsure why
Programming language books usually explain that value types are created on the stack, and
My programming language is C# .Net 3.5 and I may have to install my
In The C++ Programming Language, Bjarne writes that the null pointer is not the
From the Wikipedia defination, Programming language is Scripting languages are languages that allow you
Some people say that every programming language has its complexity budget which it can
I am learning OOP with the pascal programming language.After googling the Internet, I found
After The C Programming Language by Brian Kernighan and Dennis Ritchie, some of the
I've been experimenting with programming language design, and have come to the point of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.