Hoja de referencia de Go

Referencia rápida de Go para desarrolladores con ejemplos prácticos. Descubre soluciones de desarrollo a medida, IA, ciberseguridad y Power BI con Q2BSTUDIO.

23 sept 2025 • 3 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Hoja de referencia de Go pensada para desarrolladores y equipos técnicos. En Q2BSTUDIO ofrecemos servicios de desarrollo de aplicaciones a medida y software a medida, y aplicamos conocimientos de inteligencia artificial e IA para empresas para resolver retos reales. Si buscas soluciones a medida para tu negocio revisa nuestra propuesta de desarrollo de aplicaciones y software multiplataforma y nuestras capacidades en inteligencia artificial en servicios de inteligencia artificial.

1. Básicos package main import fmt func main() { fmt.Println(`Hello, Go!`) } Explicación: package main indica el punto de entrada del ejecutable, import trae paquetes y func main() es el punto de arranque del programa.

2. Variables y constantes Declaración explícita: var name string = `Mie` Declaración corta dentro de funciones: age := 35 Constante inmutable: const Pi = 3.14 Notas: var para declaración explícita, := ayuda a la inferencia de tipos y const define valores inmutables.

3. Estructuras de control if x > 10 { fmt.Println(`Big`) } else { fmt.Println(`Small`) } Bucle for clásico: for i := 0; i < 5; i++ { fmt.Println(i) } Iteración sobre colecciones: for _, v := range []string{`a`,`b`,`c`} { fmt.Println(v) } switch day { case `Mon`: fmt.Println(`Start`) default: fmt.Println(`Other`) }

4. Funciones Función simple: func add(a int, b int) int { return a + b } Múltiples retornos: func swap(x, y string) (string, string) { return y, x } Retornos nombrados: func split(sum int) (x, y int) { x = sum * 4 / 9 y = sum - x return }

5. Structs y métodos type Person struct { Name string Age int } Método con receptor por valor: func (p Person) Greet() { fmt.Println(`Hello, my name is`, p.Name) } Método con receptor por puntero: func (p *Person) HaveBirthday() { p.Age++ }

6. Arrays, slices y mapas Array fijo: arr := [3]int{1,2,3} Slice dinámico: slice := []int{1,2,3} slice = append(slice, 4) Mapas: m := map[string]int{`a`:1,`b`:2} fmt.Println(m[`a`]) delete(m, `b`)

7. Punteros x := 10 p := &x // puntero a x fmt.Println(*p) // desreferenciar *p = 20 fmt.Println(x) // ahora 20

8. Interfaces type Speaker interface { Speak() string } type Dog struct{} func (d Dog) Speak() string { return `Woof!` } func main() { var s Speaker = Dog{} fmt.Println(s.Speak()) }

9. Manejo de errores import errors func div(a, b int) (int, error) { if b == 0 { return 0, errors.New(`division by zero`) } return a / b, nil } func main() { res, err := div(10, 0) if err != nil { fmt.Println(`Error:`, err) return } fmt.Println(`Result:`, res) }

Consejos rápidos: aprovecha slices en lugar de arrays fijos en la mayoría de casos, usa interfaces para diseñar APIs flexibles y maneja errores explícitamente para servicios fiables. En Q2BSTUDIO combinamos buenas prácticas de Go con experiencia en ciberseguridad y pentesting para entregar software seguro y escalable, además de ofrecer servicios cloud aws y azure y soluciones de servicios inteligencia de negocio y power bi que aceleran la toma de decisiones. Si te interesa impulsar la automatización y agentes IA para tu organización podemos ayudarte a diseñar agentes IA y pipelines de datos que integren Power BI y otras herramientas.

Q2BSTUDIO es una empresa de desarrollo de software, aplicaciones a medida y especialistas en inteligencia artificial, ciberseguridad y servicios cloud aws y azure. Ofrecemos software a medida, servicios de inteligencia de negocio y soluciones de IA para empresas que incluyen agentes IA y proyectos con power bi para visualización y análisis avanzado.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.

Live Chat