GithubHelp home page GithubHelp logo

bonfy / go-mega Goto Github PK

View Code? Open in Web Editor NEW
743.0 20.0 126.0 19.98 MB

✨🤟✨Go-Mega Tutorial for Go Web Develop | Demo: https://go-mega.herokuapp.com

Home Page: https://go-mega.bonfy.im

License: Other

Go 100.00%
go tutorial go-mega

go-mega's Issues

关于第八章、第九章例子前端页面无法完整显示的问题

Hello,作者您好!我在学习您这个项目过程中自己仿照了一个项目(代码基本一样,结构稍有改动)。在第八章第九章的例子中我使用您项目中的前段代码,发现在渲染的时候没有出现 followold 等关注、分页的按钮。为了避免是自己的问题,我做了以下检查:

  • 前端代码有误导致渲染失败?直接复制原项目代码后还是一样的结果。
  • 是不是没有把数据写入数据库?查询后发现数据插入成功。

后来想可能是兼容问题?(前端一点都不了解,瞎猜的)直接在 url 后面加类似于 ?page=2 这样的参数,发现能成功显示分页的内容。

结果如下图所示,第一张是不加 page 参数的截图,第二张是加了 page 参数的截图,第三张是 followunfollow 按钮无法正常显示出来的页面:

image
image
image

综上,想请教一下作者怎么修改才能完整地显示您教程上面的前端页面?十分感谢!

第二章 Template Basic 中 templates 路径位置问题

第二章提到的 templates 没有说明在哪里创建

$ mkdir templates

比如我是在 main.go 所在的目录创建的,这样的话直接运行会报错,需要把路径改成相对路径:

tpl, _ := template.ParseFiles("./templates/index.html")

想请问下关于gorm多对多关系的问题

使用gorm 自引用多对多关系,如何反向查询呢?
比如:用户互相关注的表

Followers     []*User        `gorm:"many2many:follower;association_jointable_foreignkey:follow_id"` //用户关注表,自引用多对多关系。

查询用户的关注列表好做,如何查询关注用户(也就是用户的粉丝)列表?

关于第二章中struct属性名和template{{属性名}}的问题

//struct User 的属性 username小写
type User struct {
	username string
}
user := User{username: "sizz"}
// template中也是小写
<h1>Hello,{{.username}}!</h1>

之后页面如下:
QQ截图20190515165329

我的全部代码贴上:
QQ截图20190515165617

将username换成Username之后就可以出现正常结果。想请问下,为什么首字母一定要大写。
谢谢。

反引号

可以提一下html字符串的反引号:用来创建原生的字符串字面量,这些字符串可能由多行组成(不支持任何转义序列),原生的字符串字面量多用于书写多行消息、HTML以及正则表达式

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.