How to import and use different packages of the same name

前端 未结 2 1218
名媛妹妹
名媛妹妹 2020-12-13 05:36

For example, I want to use both text/template and html/template in one source file. But the code below throw errors.

import (
    \"fmt\"
    \"net/http\"
          


        
2条回答
  •  眼角桃花
    2020-12-13 05:46

    import (
        "text/template"
        htemplate "html/template" // this is now imported as htemplate
    )
    

    Read more about it in the spec.

提交回复
热议问题