Skip to content

Commit

Permalink
initial templating work
Browse files Browse the repository at this point in the history
  • Loading branch information
osangenis committed Sep 3, 2023
1 parent 960afe1 commit 1bbc428
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Generate services

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
GPT_API: https://api.github.com

permissions:
contents: write
pull-requests: write

jobs:
hello-service:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v2
with:
go-version: '1.19.3' # Important to have the minor
- name: generate_prompt


Binary file added bin/go-generator-cli
Binary file not shown.
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/osangenis/pap/v2

go 1.20
Empty file added go.sum
Empty file.
1 change: 1 addition & 0 deletions hello/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
in: hello {{ .data.thing }}
18 changes: 18 additions & 0 deletions hello/hello.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Hello World API service
*
* Just an experimenting API that will ping what you send
*/
syntax = "proto3";

package hello;

option go_package = "github.com/osangenis/hello";


// Hello Service
service HelloService {
// Returns the same string that was sent
rpc Ping(string) returns (string);
}

25 changes: 25 additions & 0 deletions hello/prompt.gpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
As a senior golang engineer, write a gRPC API service that implements the service described in the file `hello.proto` that has the following content:

``` /**
* Hello World API service
*
* Just an experimenting API that will ping what you send
*/
syntax = "proto3";

package hello;

option go_package = "github.com/osangenis/hello";


// Hello Service
service HelloService {
// Returns the same string that was sent
rpc Ping(string) returns (string);
}
```

The service must be implemented in the file `hello.go`.
The service must be able to be run with the command `go run hello.go`.
The service should listen on port 8080 if the environment variable `PORT` is not defined. Otherwise should run in the port defined by the environment variable `PORT`

8 changes: 8 additions & 0 deletions hello/prompt.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
As a senior golang engineer, write a gRPC API service that implements the service described in the file `hello.proto` that has the following content:

``` {{ template "./hello/hello.proto" }} ```

The service must be implemented in the file `hello.go`.
The service must be able to be run with the command `go run hello.go`.
The service should listen on port 8080 if the environment variable `PORT` is not defined. Otherwise should run in the port defined by the environment variable `PORT`

15 changes: 15 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
GO_GENERATOR_BIN_URL=https://github.com/StephanHCB/go-generator-cli/releases/download/v1.3.2/go-generator-cli_1.3.2_Darwin_x86_64
GO_GENERATOR_BIN=./bin/go-generator-cli

install-gomplate-macos:
brew install gomplate

install-templating-macos:
mkdir -p bin
brew install wget
wget ${GO_GENERATOR_BIN_URL} -O ${GO_GENERATOR_BIN}
chmod +x ${GO_GENERATOR_BIN}

hello-service:
# ${GO_GENERATOR_BIN} --generator=./hello --target=./hello --render
gomplate -f ./hello/prompt.tmpl -o ./hello/prompt.gpt --template ./hello/hello.proto

0 comments on commit 1bbc428

Please sign in to comment.