Questions tagged [beego]

Beego is an open-source, high-performance, modular, full-stack web framework for the Go programming language.

Beego is a Web framework for rapid development of Go applications. It can be used to develop APIs, web apps and backend services quickly. It is a RESTful framework. It is inspired by Tornado, Sinatra and Flask and has integrated some of Go-specific features such as interfaces and struct embedding.

Features

  • RESTful support
  • MVC architecture
  • Modularity
  • Auto API documents
  • Annotation router
  • Namespace
  • Powerful development tools
  • Full stack for Web & API

Useful links

Official documentation

Github repo

Beego community

Beego Books

285 questions
100
votes
2 answers

Go templates: How do I access array item (arr[2]) in templates?

How do I access an array item (e.g. a[2]) in templates? Whenever I do this I get "bad character U+005B '['" {{ .a[2] }}
Glstunna
  • 1,993
  • 3
  • 18
  • 27
10
votes
4 answers

How to validate JSON input using Golang?

I'm using Beego framework to build a web application in Go. I have to validate the incoming JSON in an API request. I can unmarshal the JSON into a struct which works fine, but I want to validate the data as well. For example, if the type doesn't…
anshuraj
  • 332
  • 1
  • 5
  • 16
8
votes
1 answer

Is there a way to force refresh hosts in go?

I am running a Beego application that relies on updates in /etc/hosts (via Docker links) to find other servers. /etc/hosts updates fine but the application will not use new hosts unless it is either restarted or after it has waited way too long.…
Diablojoe
  • 231
  • 1
  • 8
7
votes
2 answers

How to write test cases for beego app?

How to approach writing test cases for Beego app. As i can see on Beego website, they have model test case but what about controllers? Any Framework which can help?
Sandeep Singh
  • 71
  • 1
  • 3
7
votes
1 answer

Beego: Creating a new orm before every request?

Currently I'm using following commands at the beginning of each function that accesses the database. o := orm.NewOrm() o.Using("default") // Using default, you can use other database It feels like I should do that only once at router…
Michael
  • 6,823
  • 11
  • 54
  • 84
6
votes
1 answer

CORS fetch from Firefox to Beego server stops after pre-flight

I have an ecmascript 7 browser application running on http://localhost:3000 in a Firefox 44.0.2 browser. It is posting to a Beego 1.6.0 server running on https://localdev.net:8443. The 'localdev.net' is on the same box and resolves to the localhost…
James Fremen
  • 2,170
  • 2
  • 20
  • 29
6
votes
1 answer

Beego POST request body always empty

I'm working with Beego's convenience methods for parsing request body values and have the following: Router file: apiNamespace := beego.NewNamespace("/api") apiNamespace.Router("/sessions/google/new", &controllers.SessionsController{},…
rawfish.dev
  • 319
  • 3
  • 13
5
votes
2 answers

How do I return string value as json object in golang?

I am using golang with beego framework and I have problem with serving strings as json. EventsByTimeRange returns a string value in json format this.Data["json"] = dao.EventsByTimeRange(request) // this -> beego…
user2616232
  • 661
  • 1
  • 9
  • 14
4
votes
1 answer

How write effective save and update function in beego?

I have the following function in the BaseModel that I can use anywhere. func (d *Dummy) Save() (int64, error) { o := orm.NewOrm() var err error var count int64 if d.Id == 0 { count, err = o.Insert(d) } else { …
open source guy
  • 2,727
  • 8
  • 38
  • 61
4
votes
1 answer

Beego ORM MySQL: default addr for network '...' unknown

My database link is a domain name instead of an IP address, and I don't use the ip address. Below is my configuration. orm.RegisterDataBase("default", "mysql", "root:root@*******.aliyuncs.com:3308/dbname?charset=utf8") Error Message: register db…
张文健
  • 43
  • 1
  • 4
4
votes
3 answers

How to run/debug a beego app using Gogland (go language)

Im using Gogland (IDE from JetBrains. Version 1.0 Preview/EAP Feb, 10 2017) to create a Beego web app. I can run it from command line with: bee run and everything works. However if I run it from the IDE with the following configuration when I…
rafahoro
  • 1,237
  • 13
  • 19
4
votes
1 answer

How to add filters in beego

I have started developing web application where the back end is Go. I'm using beego framework to develop this application.Previously i used to program in java. Java has a filter function to filter the request by url. I came to know that we can…
Rajesh Kumar
  • 207
  • 1
  • 6
  • 12
4
votes
2 answers

How to use gorm with Beego

Beego ORM is somehow incomplete for now (for example it doesn't support foreign key constraints). So I've decided to use gorm with Beego. What is proper way of doing that? I've seen the sample code from gorm: import ( "github.com/jinzhu/gorm" …
hamidfzm
  • 4,595
  • 8
  • 48
  • 80
4
votes
2 answers

Array of struct in templates

Please, help me. I have type with struct type myType struct { ID string Name Test } And have array of type var List []MyType; How to i can print in template my List with all struct fields? Thank you!
4
votes
1 answer

beego not finding layout tpl file with bee run

I've built a rudimentary layout based site in golang with beego, I've split my page layout into a file called views/_layout.tpl and referenced it as below from a controller. func (c *BuyerController) Get() { ... c.Layout = "_layout.tpl" …
Tim Abell
  • 11,186
  • 8
  • 79
  • 110
1
2 3
18 19