search
HomeBackend DevelopmentGolangGetting Started with INFINI Framework - Our homemade framework for building enterprise golang applications

Getting Started with INFINI Framework - Our homemade framework for building enterprise golang applications

We recently open-sourced our homemade framework for building enterprise golang applications, called INFINI Framework.

The github repo is https://github.com/infinilabs/framework.

In this article, I will show you how to get started with INFINI Framework.

Create New Application

Let's use the NewAPP as the new project for example.

Create the project folder

Use the name new_app as the project id, and create the project folder as below:

cd ~/go/src/infini.sh/
mkdir new_app

Note: Ensure that new_app is located in the same directory as the framework folder. This structure is required for the Makefile to function correctly.

Create the main file

Create a empty main.go file, and paste the code as below:

package main

import (
        "infini.sh/framework"
        "infini.sh/framework/core/module"
        "infini.sh/framework/core/util"
        "infini.sh/framework/modules/api"
        "infini.sh/new_app/config"
)

func main() {

        terminalHeader := ("     __               _      ___  ___ \n")
        terminalHeader += ("  /\ \ \_____      __/_\    / _ \/ _ \\n")
        terminalHeader += (" /  \/ / _ \ \ /\ / //_\\  / /_)/ /_)/\n")
        terminalHeader += ("/ /\  /  __/\ V  V /  _  \/ ___/ ___/ \n")
        terminalHeader += ("\_\ \/ \___| \_/\_/\_/ \_/\/   \/     \n\n")

        terminalFooter := ("Goodbye~")
        app := framework.NewApp("new_app", "Make a golang application is such easy~.",
                util.TrimSpaces(config.Version), util.TrimSpaces(config.BuildNumber), util.TrimSpaces(config.LastCommitLog), util.TrimSpaces(config.BuildDate), util.TrimSpaces(config.EOLDate), terminalHeader, terminalFooter)
        app.IgnoreMainConfigMissing()
        app.Init(nil)
        defer app.Shutdown()
        if app.Setup(func() {
                module.RegisterSystemModule(&api.APIModule{})
                module.Start()
        }, func() {
        }, nil) {
                app.Run()
        }
}

We use this online tool to generate a beauty ASCII based terminal header.

Create the config file

touch new_app.yml

Create the makefile

create a empty Makefile, and paste the code as below:

SHELL=/bin/bash

# APP info
APP_NAME := new_app
APP_VERSION := 1.0.0_SNAPSHOT
APP_CONFIG := $(APP_NAME).yml
APP_EOLDate ?= "2025-12-31T10:10:10Z"
APP_STATIC_FOLDER := .public
APP_STATIC_PACKAGE := public
APP_UI_FOLDER := ui
APP_PLUGIN_FOLDER := plugins
PREFER_MANAGED_VENDOR=fase

include ../framework/Makefile

Build the application

➜  new_app OFFLINE_BUILD=true make build
building new_app 1.0.0_SNAPSHOT main
/Users/medcl/go/src/infini.sh/new_app
framework path:  /Users/medcl/go/src/infini.sh/framework
fatal: not a git repository (or any of the parent directories): .git
update generated info
update configs
(cd ../framework/  && make update-plugins) || true # build plugins in framework
GOPATH=~/go:~/go/src/infini.sh/framework/../vendor/ CGO_ENABLED=0 GRPC_GO_REQUIRE_HANDSHAKE=off  GO15VENDOREXPERIMENT="1" GO111MODULE=off go build -a  -gcflags=all="-l -B"  -ldflags '-static' -ldflags='-s -w' -gcflags "-m"  --work  -o /Users/medcl/go/src/infini.sh/new_app/bin/new_app
WORK=/var/folders/j5/qd4qt3n55dz053d93q2mswfr0000gn/T/go-build435280758
# infini.sh/new_app
./main.go:17:9: can inline main.deferwrap1
./main.go:21:12: can inline main.func2
./main.go:18:22: func literal does not escape
./main.go:19:45: &api.APIModule{} escapes to heap
./main.go:21:12: func literal escapes to heap
restore generated info

Run the application

➜  new_app git:(main) ✗ ./bin/new_app
     __               _      ___  ___
  /\ \ \_____      __/_\    / _ \/ _ \
 /  \/ / _ \ \ /\ / //_\  / /_)/ /_)/
/ /\  /  __/\ V  V /  _  \/ ___/ ___/
\_\ \/ \___| \_/\_/\_/ \_/\/   \/

[NEW_APP] Make a golang application is such easy~.
[NEW_APP] 1.0.0_SNAPSHOT#001, 2024-12-16 06:15:10, 2025-12-31 10:10:10, HEAD
[12-16 14:15:19] [INF] [env.go:203] configuration auto reload enabled
[12-16 14:15:19] [INF] [env.go:209] watching config: /Users/medcl/go/src/infini.sh/new_app/config
[12-16 14:15:19] [INF] [app.go:311] initializing new_app, pid: 64426
[12-16 14:15:19] [INF] [app.go:312] using config: /Users/medcl/go/src/infini.sh/new_app/new_app.yml
[12-16 14:15:19] [INF] [api.go:214] local ips: 192.168.3.17
[12-16 14:15:19] [INF] [api.go:312] api server listen at: http://0.0.0.0:2900
[12-16 14:15:19] [INF] [module.go:159] started module: api
[12-16 14:15:19] [INF] [module.go:184] all modules are started
[12-16 14:15:19] [INF] [instance.go:101] workspace: /Users/medcl/go/src/infini.sh/new_app/data/new_app/nodes/ctfs8hbq50kevmkb3m6g
[12-16 14:15:19] [INF] [app.go:537] new_app is up and running now.
^C
[NEW_APP] got signal: interrupt, start shutting down
[12-16 14:15:23] [INF] [module.go:213] all modules are stopped
[12-16 14:15:23] [INF] [app.go:410] new_app now terminated.
[NEW_APP] 1.0.0_SNAPSHOT, uptime: 4.13334s

Goodbye~

Conclusion

The demo code can be found here.

By leveraging the INFINI Framework, creating a Go application becomes significantly simpler and more efficient.
The framework provides built-in commands and modules, streamlining the development process and enabling you to focus on building your application's core functionality.

Follow us AT: https://github.com/infinilabs

The above is the detailed content of Getting Started with INFINI Framework - Our homemade framework for building enterprise golang applications. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Golang vs. Python: Concurrency and MultithreadingGolang vs. Python: Concurrency and MultithreadingApr 17, 2025 am 12:20 AM

Golang is more suitable for high concurrency tasks, while Python has more advantages in flexibility. 1.Golang efficiently handles concurrency through goroutine and channel. 2. Python relies on threading and asyncio, which is affected by GIL, but provides multiple concurrency methods. The choice should be based on specific needs.

Golang and C  : The Trade-offs in PerformanceGolang and C : The Trade-offs in PerformanceApr 17, 2025 am 12:18 AM

The performance differences between Golang and C are mainly reflected in memory management, compilation optimization and runtime efficiency. 1) Golang's garbage collection mechanism is convenient but may affect performance, 2) C's manual memory management and compiler optimization are more efficient in recursive computing.

Golang vs. Python: Applications and Use CasesGolang vs. Python: Applications and Use CasesApr 17, 2025 am 12:17 AM

ChooseGolangforhighperformanceandconcurrency,idealforbackendservicesandnetworkprogramming;selectPythonforrapiddevelopment,datascience,andmachinelearningduetoitsversatilityandextensivelibraries.

Golang vs. Python: Key Differences and SimilaritiesGolang vs. Python: Key Differences and SimilaritiesApr 17, 2025 am 12:15 AM

Golang and Python each have their own advantages: Golang is suitable for high performance and concurrent programming, while Python is suitable for data science and web development. Golang is known for its concurrency model and efficient performance, while Python is known for its concise syntax and rich library ecosystem.

Golang vs. Python: Ease of Use and Learning CurveGolang vs. Python: Ease of Use and Learning CurveApr 17, 2025 am 12:12 AM

In what aspects are Golang and Python easier to use and have a smoother learning curve? Golang is more suitable for high concurrency and high performance needs, and the learning curve is relatively gentle for developers with C language background. Python is more suitable for data science and rapid prototyping, and the learning curve is very smooth for beginners.

The Performance Race: Golang vs. CThe Performance Race: Golang vs. CApr 16, 2025 am 12:07 AM

Golang and C each have their own advantages in performance competitions: 1) Golang is suitable for high concurrency and rapid development, and 2) C provides higher performance and fine-grained control. The selection should be based on project requirements and team technology stack.

Golang vs. C  : Code Examples and Performance AnalysisGolang vs. C : Code Examples and Performance AnalysisApr 15, 2025 am 12:03 AM

Golang is suitable for rapid development and concurrent programming, while C is more suitable for projects that require extreme performance and underlying control. 1) Golang's concurrency model simplifies concurrency programming through goroutine and channel. 2) C's template programming provides generic code and performance optimization. 3) Golang's garbage collection is convenient but may affect performance. C's memory management is complex but the control is fine.

Golang's Impact: Speed, Efficiency, and SimplicityGolang's Impact: Speed, Efficiency, and SimplicityApr 14, 2025 am 12:11 AM

Goimpactsdevelopmentpositivelythroughspeed,efficiency,andsimplicity.1)Speed:Gocompilesquicklyandrunsefficiently,idealforlargeprojects.2)Efficiency:Itscomprehensivestandardlibraryreducesexternaldependencies,enhancingdevelopmentefficiency.3)Simplicity:

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools