[Go] Developing a Go Web project, stepping on some "pits"

Source: Internet
Author: User

Note: These "pits" are not bugs, but they were not understood at the time.

The frame used is Beego

1, the dictionary map is "reference type", itself is a pointer, as a parameter to pass the map variable name directly (do not pass the map variable pointer).

Within the calling method, if the map variable value is modified, the value of the external map variable will be changed!

For example Beego Controller attribute data, if other places need to use this variable, directly into the data variable name, the reference code is as follows:

# # in-controller code

preprocessing func (c *passportcontroller) Prepare () {    //Check User session state (whether logged in)    res: = Passportservice.managercheckloginsession (C.ctx, C.data)    println (res. MSG)}

# # method to call to

Func (S *passportservice) managercheckloginsession (Ctx *context. Context, Data map[interface{}]interface{}) *beego. Result {    //... Code omitted}

2, go file can not be prefixed with "_", otherwise go to the bottom will ignore its existence (that is, the file does not work, the code will not work)

For example:_templatefunc.go This file is invalid

[Go] Developing a Go Web project, stepping on some "pits"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.